@@ -28,15 +28,15 @@ def tex_to_svg_file(expression, environment=None, tex_template=None):
28
28
----------
29
29
expression : :class:`str`
30
30
String containing the TeX expression to be rendered, e.g. ``\\ sqrt{2}`` or ``foo``
31
- environment : :class:`str`
31
+ environment : Optional[ :class:`str`], optional
32
32
The string containing the environment in which the expression should be typeset, e.g. ``align*``
33
- Optional. If not set, the expression will be rendered in text mode.
34
- tex_template : :class:`TexTemplate`
35
- Template class used to typesetting.
36
- Optional. If not set, the default template will be used.
33
+ tex_template : Optional[:class:`TexTemplate`], optional
34
+ Template class used to typesetting. If not set, use default template set via `config["tex_template"]`
35
+
37
36
Returns
38
37
-------
39
- Path to generated SVG file.
38
+ :class:`str`
39
+ Path to generated SVG file.
40
40
"""
41
41
if tex_template is None :
42
42
tex_template = config ["tex_template" ]
@@ -47,24 +47,26 @@ def tex_to_svg_file(expression, environment=None, tex_template=None):
47
47
return convert_to_svg (dvi_file , tex_template .output_format )
48
48
49
49
50
- def generate_tex_file (expression , environment , tex_template ):
50
+ def generate_tex_file (expression , environment = None , tex_template = None ):
51
51
"""Takes a tex expression (and an optional tex environment),
52
52
and returns a fully formed tex file ready for compilation.
53
53
54
54
Parameters
55
55
----------
56
56
expression : :class:`str`
57
57
String containing the TeX expression to be rendered, e.g. ``\\ sqrt{2}`` or ``foo``
58
- environment : :class:`str`
58
+ environment : Optional[ :class:`str`], optional
59
59
The string containing the environment in which the expression should be typeset, e.g. ``align*``
60
- Optional. If not set, the expression will be rendered in text mode.
61
- tex_template : :class:`TexTemplate`
62
- Template class used to typesetting.
63
- Optional. If not set, the default template will be used.
60
+ tex_template : Optional[:class:`TexTemplate`], optional
61
+ Template class used to typesetting. If not set, use default template set via `config["tex_template"]`
62
+
64
63
Returns
65
64
-------
66
- Generated TeX file ready for compilation
65
+ :class:`string`
66
+ Path to generated TeX file
67
67
"""
68
+ if tex_template is None :
69
+ tex_template = config ["tex_template" ]
68
70
if environment is not None :
69
71
output = tex_template .get_texcode_for_expression_in_env (expression , environment )
70
72
else :
@@ -87,14 +89,15 @@ def tex_compilation_command(tex_compiler, output_format, tex_file, tex_dir):
87
89
String containing the compiler to be used, e.g. ``pdflatex`` or ``lualatex``
88
90
output_format : :class:`str`
89
91
String containing the output format generated by the compiler, e.g. ``.dvi`` or ``.pdf``
90
- Optional. If not set, the expression will be rendered in text mode.
91
92
tex_file : :class:`str`
92
93
File name of TeX file to be typeset.
93
94
tex_dir : :class:`str`
94
95
Path to the directory where compiler output will be stored.
96
+
95
97
Returns
96
98
-------
97
- Path to generated output file.
99
+ :class:`str`
100
+ Compilation command according to given parameters
98
101
"""
99
102
if tex_compiler in {"latex" , "pdflatex" , "luatex" , "lualatex" }:
100
103
commands = [
@@ -140,10 +143,11 @@ def compile_tex(tex_file, tex_compiler, output_format):
140
143
String containing the compiler to be used, e.g. ``pdflatex`` or ``lualatex``
141
144
output_format : :class:`str`
142
145
String containing the output format generated by the compiler, e.g. ``.dvi`` or ``.pdf``
143
- Optional. If not set, the expression will be rendered in text mode.
146
+
144
147
Returns
145
148
-------
146
- Path to generated output file.
149
+ :class:`str`
150
+ Path to generated output file in desired format (DVI, XDV or PDF).
147
151
"""
148
152
result = tex_file .replace (".tex" , output_format )
149
153
result = Path (result ).as_posix ()
@@ -173,13 +177,15 @@ def convert_to_svg(dvi_file, extension, regen_if_exists=False, page=1):
173
177
File name of the input file to be converted.
174
178
extension : :class:`str`
175
179
String containing the file extension and thus indicating the file type, e.g. ``.dvi`` or ``.pdf``
176
- regen_if_exists : `bool`
177
- Setting if SVG has to be regenerated even if it already exists. Optional, defaulting to False.
178
- page : `int`
179
- Page to be converted if input file is multi-page. Optional, defaulting to 1.
180
+ regen_if_exists : Optional[:class:`bool`], optional
181
+ Setting if SVG has to be regenerated even if it already exists.
182
+ page : Optional[:class:`int`], optional
183
+ Page to be converted if input file is multi-page.
184
+
180
185
Returns
181
186
-------
182
- Path to generated SVG file."""
187
+ :class:`str`
188
+ Path to generated SVG file."""
183
189
result = dvi_file .replace (extension , ".svg" )
184
190
result = Path (result ).as_posix ()
185
191
dvi_file = Path (dvi_file ).as_posix ()
0 commit comments