@@ -50,10 +50,11 @@ popular LaTeX distributions, like [TeX Live](https://www.tug.org/texlive/),
50
50
Compiling your PDF can be as simple as writing the following task.
51
51
52
52
``` python
53
+ from pathlib import Path
53
54
import pytask
54
55
55
56
56
- @pytask.mark.latex (script = " document.tex" , document = " document.pdf" )
57
+ @pytask.mark.latex (script = Path( " document.tex" ) , document = Path( " document.pdf" ) )
57
58
def task_compile_latex_document ():
58
59
pass
59
60
```
@@ -64,11 +65,24 @@ task module to the LaTeX file and the compiled document.
64
65
65
66
### Dependencies and Products
66
67
67
- Dependencies and products can be added as with a normal pytask task using the
68
- ` @pytask.mark.depends_on ` and ` @pytask.mark.produces ` decorators. which is explained in
69
- this
68
+ Dependencies and products can be added as usual. Read this
70
69
[ tutorial] ( https://pytask-dev.readthedocs.io/en/stable/tutorials/defining_dependencies_products.html ) .
71
70
71
+ For example, with the ` @pytask.task ` decorator. (The choice of the kwarg name, here
72
+ ` path ` , is arbitrary.)
73
+
74
+ ``` python
75
+ import pytask
76
+ from pytask import task
77
+ from pathlib import Path
78
+
79
+
80
+ @task (kwargs = {" path" : Path(" path_to_another_dependency.tex" )})
81
+ @pytask.mark.latex (script = Path(" document.tex" ), document = Path(" document.pdf" ))
82
+ def task_compile_latex_document ():
83
+ pass
84
+ ```
85
+
72
86
### Customizing the compilation
73
87
74
88
pytask-latex uses latexmk by default to compile the document because it handles most
@@ -77,8 +91,8 @@ decorator.
77
91
78
92
``` python
79
93
@pytask.mark.latex (
80
- script = " document.tex" ,
81
- document = " document.pdf" ,
94
+ script = Path( " document.tex" ) ,
95
+ document = Path( " document.pdf" ) ,
82
96
compilation_steps = " latexmk" ,
83
97
)
84
98
def task_compile_latex_document ():
@@ -95,8 +109,8 @@ from pytask_latex import compilation_steps as cs
95
109
96
110
97
111
@pytask.mark.latex (
98
- script = " document.tex" ,
99
- document = " document.pdf" ,
112
+ script = Path( " document.tex" ) ,
113
+ document = Path( " document.pdf" ) ,
100
114
compilation_steps = cs.latexmk(
101
115
options = (" --pdf" , " --interaction=nonstopmode" , " --synctex=1" , " --cd" )
102
116
),
@@ -113,8 +127,8 @@ an example for generating a `.dvi`.
113
127
114
128
``` python
115
129
@pytask.mark.latex (
116
- script = " document.tex" ,
117
- document = " document.pdf" ,
130
+ script = Path( " document.tex" ) ,
131
+ document = Path( " document.pdf" ) ,
118
132
compilation_steps = cs.latexmk(
119
133
options = (" --dvi" , " --interaction=nonstopmode" , " --synctex=1" , " --cd" )
120
134
),
@@ -157,23 +171,24 @@ The following task compiles two latex documents.
157
171
for i in range (2 ):
158
172
159
173
@pytask.mark.task
160
- @pytask.mark.latex (script = f " document_ { i} .tex " , document = f " document_ { i} .pdf " )
174
+ @pytask.mark.latex (
175
+ script = Path(f " document_ { i} .tex " ), document = Path(f " document_ { i} .pdf " )
176
+ )
161
177
def task_compile_latex_document ():
162
178
pass
163
179
```
164
180
165
181
If you want to compile the same document with different command line options, you have
166
- to include the latex decorator in the parametrization just like with
167
- ` @pytask.mark.depends_on ` and ` @pytask.mark.produces ` . Pass a dictionary for possible
182
+ to include the latex decorator in the parametrization. Pass a dictionary for possible
168
183
compilation steps and their options.
169
184
170
185
``` python
171
186
for format_ in (" pdf" , " dvi" ):
172
187
173
188
@pytask.mark.task
174
189
@pytask.mark.latex (
175
- script = " document.tex" ,
176
- document = f " document. { format_} " ,
190
+ script = Path( " document.tex" ) ,
191
+ document = Path( f " document. { format_} " ) ,
177
192
compilation_steps = cs.latexmk(
178
193
(f " -- { format_} " , " --interaction=nonstopmode" , " --synctex=1" , " --cd" )
179
194
),
0 commit comments