1LATEXMK(1) General Commands Manual LATEXMK(1)
2
3
4
6 latexmk - generate LaTeX document
7
9 latexmk [options] [file ...]
10
12 Latexmk completely automates the process of compiling a LaTeX document.
13 Essentially, it is like a specialized relative of the general make
14 utility, but one which determines dependencies automatically and has
15 some other very useful features. In its basic mode of operation la‐
16 texmk is given the name of the primary source file for a document, and
17 it issues the appropriate sequence of commands to generate a .dvi, .ps,
18 .pdf and/or hardcopy version of the document.
19
20 By default latexmk will run the commands necessary to generate a .dvi
21 file, which copies the behavior of earlier versions when only latex was
22 available.
23
24 Latexmk can also be set to run continuously with a suitable previewer.
25 In that case the latex program (or one of its relatives), etc, are re‐
26 run whenever one of the source files is modified, and the previewer au‐
27 tomatically updates the on-screen view of the compiled document.
28
29 Latexmk determines which are the source files by examining the log
30 file. (Optionally, it also examines the list of input and output files
31 generated by the -recorder option of modern versions of latex (and
32 pdflatex, xelatex, lualatex). See the documentation for the -recorder
33 option of latexmk below.) When latexmk is run, it examines properties
34 of the source files, and if any have been changed since the last docu‐
35 ment generation, latexmk will run the various LaTeX processing programs
36 as necessary. In particular, it will repeat the run of latex (or a re‐
37 lated program)) often enough to resolve all cross references; depending
38 on the macro packages used. With some macro packages and document
39 classes, four, or even more, runs may be needed. If necessary, latexmk
40 will also run bibtex, biber, and/or makeindex. In addition, latexmk
41 can be configured to generate other necessary files. For example, from
42 an updated figure file it can automatically generate a file in encapsu‐
43 lated postscript or another suitable format for reading by LaTeX.
44
45 Latexmk has two different previewing options. With the simple -pv op‐
46 tion, a dvi, postscript or pdf previewer is automatically run after
47 generating the dvi, postscript or pdf version of the document. The
48 type of file to view is selected according to configuration settings
49 and command line options.
50
51 The second previewing option is the powerful -pvc option (mnemonic:
52 "preview continuously"). In this case, latexmk runs continuously, reg‐
53 ularly monitoring all the source files to see if any have changed. Ev‐
54 ery time a change is detected, latexmk runs all the programs necessary
55 to generate a new version of the document. A good previewer will then
56 automatically update its display. Thus the user can simply edit a file
57 and, when the changes are written to disk, latexmk completely automates
58 the cycle of updating the .dvi (and/or the .ps and .pdf) file, and re‐
59 freshing the previewer's display. It's not quite WYSIWYG, but usefully
60 close.
61
62 For other previewers, the user may have to manually make the previewer
63 update its display, which can be (e.g., with some versions of xdvi and
64 gsview) as simple as forcing a redraw of its display.
65
66 Latexmk has the ability to print a banner in gray diagonally across
67 each page when making the postscript file. It can also, if needed,
68 call an external program to do other postprocessing on generated dvi
69 and postscript files. (See the options -dF and -pF, and the documenta‐
70 tion for the $dvi_filter and $ps_filter configuration variables.)
71 These capabilities are leftover from older versions of latexmk, but are
72 currently non-functional. More flexibility can be obtained in current
73 versions, since the command strings for running *latex can now be con‐
74 figured to run multiple commands. This also extends the possibility of
75 postprocessing generated files.
76
77 Latexmk is highly configurable, both from the command line and in con‐
78 figuration files, so that it can accommodate a wide variety of user
79 needs and system configurations. Default values are set according to
80 the operating system, so latexmk often works without special configura‐
81 tion on MS-Windows, cygwin, Linux, OS-X, and other UNIX systems. See
82 the section "Configuration/Initialization (rc) Files", and then the
83 later sections "How to Set Variables in Initialization Files", "Format
84 of Command Specifications", "List of Configuration Variables Usable in
85 Initialization Files", "Custom Dependencies", and "Advanced Configura‐
86 tion"
87
88 A very annoying complication handled very reliably by latexmk, is that
89 LaTeX is a multiple pass system. On each run, LaTeX reads in informa‐
90 tion generated on a previous run, for things like cross referencing and
91 indexing. In the simplest cases, a second run of LaTeX suffices, and
92 often the log file contains a message about the need for another pass.
93 However, there is a wide variety of add-on macro packages to LaTeX,
94 with a variety of behaviors. The result is to break simple-minded de‐
95 terminations of how many runs are needed and of which programs. La‐
96 texmk has a highly general and efficient solution to these issues. The
97 solution involves retaining between runs information on the source
98 files, and a symptom is that latexmk generates an extra file (with ex‐
99 tension .fdb_latexmk, by default) that contains the source file infor‐
100 mation.
101
102
104 In general the command line to invoke latexmk has the form
105
106 latexmk [options] [file]
107
108 All options can be introduced by single or double "-" characters, e.g.,
109 "latexmk -help" or "latexmk --help".
110
111 Note 1: In the documentation, '*latex' means any of the supported en‐
112 gines, i.e., currently latex, lualatex, pdflatex, xelatex. Mention of
113 a specific one of these normally refers that specific engines. Earlier
114 versions of this documentation weren't so consistent. Which of these
115 is used to compile a document, depends on the configuration and the
116 command line arguments.
117
118 Note 2: In addition to the options in the list below, latexmk recog‐
119 nizes almost all the options recognized by the *latex programs in their
120 current TeXLive and MiKTeX implementations. Some of the options for
121 these programs trigger special action or behavior by latexmk, in which
122 case they have specific explanations in this document; in this case
123 they may or may not be passed to *latex as well.
124
125 Run latexmk with the -showextraoptions to get a list of the options
126 that latexmk accepts and that are simply passed through to *latex. See
127 also the explanation of the -showextraoptions option for more informa‐
128 tion.
129
130
131 Definitions of options and arguments
132
133
134 file One or more files can be specified. If no files are specified,
135 latexmk will, by default, run on all files in the current work‐
136 ing directory with a ".tex" extension. This behavior can be
137 changed: see the description concerning the @default_files vari‐
138 able in the section "List of configuration variables usable in
139 initialization files".
140
141 If a file is specified without an extension, then the ".tex" ex‐
142 tension is automatically added, just as LaTeX does. Thus, if
143 you specify:
144
145 latexmk foo
146
147 then latexmk will operate on the file "foo.tex".
148
149 There are certain restrictions on what characters can be in a
150 filename; certain characters are either prohibited or problem‐
151 atic for the latex etc programs. These characters are: "$",
152 "%", "\", "~", the double quote character, and the control char‐
153 acters null, tab, form feed, carriage return, line feed, and
154 delete. In addition "&" is prohibited when it is the first
155 character of a filename.
156
157 Latexmk gives a fatal error when it detects any of the above
158 characters in the TeX filename(s) specified on the command line.
159 However before testing for illegal characters, latexmk removes
160 matching pairs of double quotes from a filename. This matches
161 the behavior of latex etc, and deals with problems that occa‐
162 sionally result from filenames that have been incorrectly quoted
163 on the command line. In addition, under Microsoft Windows, the
164 forward slash character "\" is a directory separator, so latexmk
165 replaces it by a backward slash "/", which is also a legal di‐
166 rectory separator in Windows, and is accepted by latex etc.
167
168
169 -auxdir=FOO or -aux-directory=FOO
170 Sets the directory for auxiliary output files of *latex (.aux,
171 .log etc). These are all the generated files, with the excep‐
172 tion of final output files (.dvi, .ps, .pdf, .synctex.gz, .sync‐
173 tex). See the -outdir/-output-directory option for directories
174 for the final output files.
175
176 If the directory specified for the -aux/-aux-directory option is
177 blank, then the default is used, which is to be the same as the
178 output directory.
179
180 If you also use the -cd option, and the specified auxiliary out‐
181 put directory is a relative path, then the path is interpreted
182 relative to the document directory.
183
184 See the section AUXILIARY AND OUTPUT DIRECTORIES for more de‐
185 tails.
186
187
188 -bibtex
189 When the source file uses bbl files for bibliography, run bibtex
190 or biber as needed to regenerate the bbl files.
191
192 This property can also be configured by setting the $bibtex_use
193 variable to 2 in a configuration file.
194
195
196 -bibtex-
197 Never run bibtex or biber. Also, always treat .bbl files as
198 precious, i.e., do not delete them in a cleanup operation.
199
200 A common use for this option is when a document comes from an
201 external source, complete with its bbl file(s), and the user
202 does not have the corresponding bib files available. In this
203 situation use of the -bibtex- option will prevent latexmk from
204 trying to run bibtex or biber, which would result in overwriting
205 of the bbl files.
206
207 This property can also be configured by setting the $bibtex_use
208 variable to 0 in a configuration file.
209
210
211 -bibtex-cond
212 When the source file uses a bbl file for the bibliography and
213 bibtex is used to generate the bibliography, run bibtex as
214 needed to regenerate the bbl files only if the relevant bib
215 file(s) exist. Thus when the bib file(s) are not available,
216 bibtex is not run, thereby avoiding overwriting of the bbl file.
217 Also, always treat .bbl files as precious, i.e., do not delete
218 them in a cleanup operation.
219
220 This is the default setting. It can also be configured by set‐
221 ting the $bibtex_use variable to 1 in a configuration file.
222
223 The reason for using this setting is first to allow automatic
224 switching between the use and non-use of bibtex depending on the
225 existence or not of a bib file. In addition, when submitting
226 articles to a scientific journal, it is common to submit only
227 .tex and .bbl files (plus graphics files), but not a .bib file.
228 Hence it is often useful to treat .bbl files as true source
229 files, that should be preserved under a clean up operation.
230
231 This property can also be configured by setting the $bibtex_use
232 variable to 1 in a configuration file.
233
234 Note that when biber is used, and a bib file doesn't exist, this
235 option does not currently prevent biber from being run. See the
236 documentation on $bibtex_use for more details. However, a bbl
237 file is treated as precious.
238
239
240 -bibtex-cond1
241 The same as -bibtex-cond except that .bbl files are only treated
242 as precious if one or more bibfiles fails to exist.
243
244 Thus if all the bib files exist, bibtex is run to generate .bbl
245 files as needed, and then it is appropriate to delete the bbl
246 files in a cleanup operation since they can be re-generated.
247
248 This property can also be configured by setting the $bibtex_use
249 variable to 1.5 in a configuration file.
250
251 Note that when biber is used, and a bib file doesn't exist, this
252 option does not currently prevent biber from being run. See the
253 documentation on $bibtex_use for more details.
254
255
256 -bibtexfudge or -bibfudge
257 Turn on the change-directory fudge for bibtex. See documenta‐
258 tion of $bibtex_fudge for details.
259
260
261 -bibtexfudge- or -bibfudge-
262 Turn off the change-directory fudge for bibtex. See documenta‐
263 tion of $bibtex_fudge for details.
264
265
266 -bm <message>
267 A banner message to print diagonally across each page when con‐
268 verting the dvi file to postscript. The message must be a sin‐
269 gle argument on the command line so be careful with quoting spa‐
270 ces and such.
271
272 Note that if the -bm option is specified, the -ps option is as‐
273 sumed.
274
275
276 -bi <intensity>
277 How dark to print the banner message. A decimal number between
278 0 and 1. 0 is black and 1 is white. The default is 0.95, which
279 is OK unless your toner cartridge is getting low.
280
281
282 -bs <scale>
283 A decimal number that specifies how large the banner message
284 will be printed. Experimentation is necessary to get the right
285 scale for your message, as a rule of thumb the scale should be
286 about equal to 1100 divided by the number of characters in the
287 message. The default is 220.0 which is just right for 5 charac‐
288 ter messages.
289
290
291 -commands
292 List the commands used by latexmk for processing files, and then
293 exit.
294
295
296 -c Clean up (remove) all regeneratable files generated by latex and
297 bibtex or biber except dvi, postscript and pdf. These files are
298 a combination of log files, aux files, latexmk's database file
299 of source file information, and those with extensions specified
300 in the @generated_exts configuration variable. In addition,
301 files specified by the $clean_ext and @generated_exts configura‐
302 tion variables are removed.
303
304 This cleanup is instead of a regular make. See the -gg option
305 if you want to do a cleanup followed by a make.
306
307 Treatment of .bbl files: If $bibtex_use is set to 0 or 1, bbl
308 files are always treated as non-regeneratable. If $bibtex_use
309 is set to 1.5, bbl files are counted as non-regeneratable condi‐
310 tionally: If the bib file exists, then bbl files are regenerat‐
311 able, and are deleted in a clean up. But if $bibtex_use is 1.5
312 and a bib file doesn't exist, then the bbl files are treated as
313 non-regeneratable and hence are not deleted.
314
315 In contrast, if $bibtex_use is set to 2, bbl files are always
316 treated as regeneratable, and are deleted in a cleanup.
317
318 Treatment of files generated by custom dependencies: If
319 $cleanup_includes_cusdep_generated is nonzero, regeneratable
320 files are considered as including those generated by custom de‐
321 pendencies and are also deleted. Otherwise these files are not
322 deleted.
323
324
325 -C Clean up (remove) all regeneratable files generated by latex and
326 bibtex or biber. This is the same as the -c option with the ad‐
327 dition of dvi, postscript and pdf files, and those specified in
328 the $clean_full_ext configuration variable.
329
330 This cleanup is instead of a regular make. See the -gg option
331 if you want to do a cleanup followed by a make.
332
333 See the -c option for the specification of whether or not .bbl
334 files are treated as non-regeneratable or regeneratable.
335
336 If $cleanup_includes_cusdep_generated is nonzero, regeneratable
337 files are considered as including those generated by custom de‐
338 pendencies and are also deleted. Otherwise these files are not
339 deleted.
340
341
342 -CA (Obsolete). Now equivalent to the -C option. See that option
343 for details.
344
345
346 -cd Change to the directory containing the main source file before
347 processing it. Then all the generated files (.aux, .log, .dvi,
348 .pdf, etc) will be relative to the source file.
349
350 This option is particularly useful when latexmk is invoked from
351 a GUI configured to invoke latexmk with a full pathname for the
352 source file.
353
354 This option works by setting the $do_cd configuration variable
355 to one; you can set that variable if you want to configure la‐
356 texmk to have the effect of the -cd option without specifying it
357 on the command line. See the documentation for that variable.
358
359
360 -cd- Do NOT change to the directory containing the main source file
361 before processing it. Then all the generated files (.aux, .log,
362 .dvi, .pdf, etc) will be relative to the current directory
363 rather than the source file.
364
365 This is the default behavior and corresponds to the behavior of
366 the *latex programs. However, it is not desirable behavior when
367 latexmk is invoked by a GUI configured to invoke latexmk with a
368 full pathname for the source file. See the -cd option.
369
370 This option works by setting the $do_cd configuration variable
371 to zero. See the documentation for that variable for more in‐
372 formation.
373
374
375 -CF Remove the file containing the database of source file informa‐
376 tion, before doing the other actions requested.
377
378
379 -d Set draft mode. This prints the banner message "DRAFT" across
380 your page when converting the dvi file to postscript. Size and
381 intensity can be modified with the -bs and -bi options. The -bm
382 option will override this option as this is really just a short
383 way of specifying:
384
385 latexmk -bm DRAFT
386
387 Note that if the -d option is specified, the -ps option is as‐
388 sumed.
389
390
391 -deps Show a list of dependent files after processing. This is in the
392 form of a dependency list of the form used by the make program,
393 and it is therefore suitable for use in a Makefile. It gives an
394 overall view of the files without listing intermediate files, as
395 well as latexmk can determine them.
396
397 By default the list of dependent files is sent to stdout (i.e.,
398 normally to the screen unless you've redirected latexmk's out‐
399 put). But you can set the filename where the list is sent by the
400 -deps-out= option.
401
402 See the section "USING latexmk WITH make" for an example of how
403 to use a dependency list with make.
404
405 Users familiar with GNU automake and gcc will find that the
406 -deps option is very similar in its purpose and results to the
407 -M option to gcc. (In fact, latexmk also has options -M, -MF,
408 and -MP options that behave like those of gcc.)
409
410
411 -dependents
412 Equivalent to -deps.
413
414
415 -deps- Do not show a list of dependent files after processing. (This
416 is the default.)
417
418
419 -dependents-
420 Equivalent to -deps-.
421
422
423 -deps-escape=<string>
424 Set the kind of escaping used for spaces in the dependency list.
425 The possible values are "none", "unix", "nmake", corresponding
426 respectively to no escaping, escaping with a "\" suitable for
427 standard Unix make, and escaping with "^", suitable for Micro‐
428 soft's nmake.
429
430
431 -deps-out=FILENAME
432 Set the filename to which the list of dependent files is writ‐
433 ten. If the FILENAME argument is omitted or set to "-", then
434 the output is sent to stdout.
435
436 Use of this option also turns on the output of the list of de‐
437 pendent files after processing.
438
439
440 -dF Dvi file filtering. The argument to this option is a filter
441 which will generate a filtered dvi file with the extension
442 ".dviF". All extra processing (e.g. conversion to postscript,
443 preview, printing) will then be performed on this filtered dvi
444 file.
445
446 Example usage: To use dviselect to select only the even pages of
447 the dvi file:
448
449 latexmk -dF "dviselect even" foo.tex
450
451
452 -diagnostics
453 Print detailed diagnostics during a run. This may help for de‐
454 bugging problems or to understand latexmk's behavior in diffi‐
455 cult situations.
456
457
458 -dir-report
459 For each .tex file processed, list the settings for aux and out
460 directories, after they have been normalized from the settings
461 specified during initialization. See the description of the
462 variable $aux_out_dir_report for more details.
463
464
465 -dir-report-
466 Do not report the settings for aux and out directories. (De‐
467 fault)
468
469
470 -dvi Generate dvi version of document using latex.
471
472
473 -dvilua
474 Generate dvi version of document using lualatex instead of la‐
475 tex.
476
477
478 -dvi- Turn off generation of dvi version of document. (This may get
479 overridden, if some other file is made (e.g., a .ps file) that
480 is generated from the dvi file, or if no generated file at all
481 is requested.)
482
483
484 -dvilualatex="COMMAND"
485 This sets the string specifying the command to run dvi lualatex.
486 It behaves like the -pdflatex option, but sets the variable
487 $dvilualatex.
488
489 Note: This option when provided with the COMMAND argument only
490 sets the command for invoking dvilualatex; it does not turn on
491 the use of dvilualatex. That is done by other options or in an
492 initialization file.
493
494
495 -e <code>
496 Execute the specified initialization code before processing.
497 The code is Perl code of the same form as is used in latexmk's
498 initialization files. For more details, see the information on
499 the -r option, and the section about "Configuration/initializa‐
500 tion (RC) files". The code is typically a sequence of assign‐
501 ment statements separated by semicolons.
502
503 The code is executed when the -e option is encountered during
504 latexmk's parsing of its command line. See the -r option for a
505 way of executing initialization code from a file. An error re‐
506 sults in latexmk stopping. Multiple instances of the -r and -e
507 options can be used, and they are executed in the order they ap‐
508 pear on the command line.
509
510 Some care is needed to deal with proper quoting of special char‐
511 acters in the code on the command line. For example, suppose
512 you want to set the latex command to use its -shell-escape op‐
513 tion, then under UNIX/Linux you could use the line
514
515 latexmk -e '$latex=q/latex %O -shell-escape %S/' file.tex
516
517 Note that the single quotes block normal UNIX/Linux command
518 shells from treating the characters inside the quotes as spe‐
519 cial. (In this example, the q/.../ construct is a Perl idiom
520 equivalent to using single quotes. This avoids the complica‐
521 tions of getting a quote character inside an already quoted
522 string in a way that is independent of both the shell and the
523 operating-system.)
524
525 The above command line will NOT work under MS-Windows with
526 cmd.exe or command.com or 4nt.exe. For MS-Windows with these
527 command shells you could use
528
529 latexmk -e "$latex=q/latex %O -shell-escape %S/" file.tex
530
531 or
532
533 latexmk -e "$latex='latex %O -shell-escape %S'" file.tex
534
535 The last two examples will NOT work with UNIX/Linux command
536 shells.
537
538 (Note: the above examples show are to show how to use the -e to
539 specify initialization code to be executed. But the particular
540 effect can be achieved also by the use of the -latex option with
541 less problems in dealing with quoting.)
542
543
544 -emulate-aux-dir
545 Emulate the use of an aux directory instead of leaving it to the
546 *latex programs to do it. (MiKTeX supports -aux-directory, but
547 TeXLive doesn't.)
548
549 See the section AUXILIARY AND OUTPUT DIRECTORIES for more de‐
550 tails.
551
552
553 -emulate-aux-dir-
554 Turn off emulation to implement an aux directory and leave it to
555 the *latex program to handle the case that the aux directory is
556 different from the output directory. Note that if you use
557 TeXLive, which doesn't support -aux-directory, latexmk will au‐
558 tomatically switch aux_dir emulation on after the first run of
559 *latex, because it will find the .log file in the wrong place.
560
561
562 -f Force latexmk to continue document processing despite errors.
563 Normally, when latexmk detects that LaTeX or another program has
564 found an error which will not be resolved by further processing,
565 no further processing is carried out.
566
567 Note: "Further processing" means the running of other programs
568 or the rerunning of latex (etc) that would be done if no errors
569 had occurred. If instead, or additionally, you want the latex
570 (etc) program not to pause for user input after an error, you
571 should arrange this by an option that is passed to the program,
572 e.g., by latexmk's option -interaction=nonstopmode (which la‐
573 texmk passes to *latex).
574
575
576 -f- Turn off the forced processing-past-errors such as is set by the
577 -f option. This could be used to override a setting in a con‐
578 figuration file.
579
580
581 -g Force latexmk to process document fully, even under situations
582 where latexmk would normally decide that no changes in the
583 source files have occurred since the previous run. This option
584 is useful, for example, if you change some options and wish to
585 reprocess the files.
586
587
588 -g- Turn off -g.
589
590
591 -gg "Super go mode" or "clean make": clean out generated files as if
592 -C had been given, and then do a regular make.
593
594
595 -h or-non-help
596 Print help information.
597
598
599 -jobname=STRING
600 Set the basename of output files(s) to STRING, instead of the
601 default, which is the basename of the specified TeX file. (At
602 present, STRING should not contain spaces.)
603
604 This is like the same option for current implementations of the
605 *latex, and the passing of this option to these programs is part
606 of latexmk's implementation of -jobname.
607
608 There is one enhancement, that the STRING may contain the place‐
609 holder '%A'. This will be substituted by the basename of the TeX
610 file. The primary purpose is when multiple files are specified
611 on the command line to latexmk, and you wish to use a jobname
612 with a different file-dependent value for each file. For exam‐
613 ple, suppose you had .tex files test1.tex and test2.tex, and you
614 wished to compare the results of compilation by *latex and those
615 with xelatex. Then under a unix-type operating system you could
616 use the command line
617
618 latexmk -pdf -jobname=%A-pdflatex *.tex
619 latexmk -pdfxe -jobname=%A-xelatex *.tex
620
621 Then the .aux, .log, and .pdf files from the use of pdflatex
622 would have basenames test1-pdflatex and test2-pdflatex, while
623 from xelatex, the basenames would be test1-xelatex and test2-xe‐
624 latex.
625
626 Under MS-Windows with cmd.exe, you would need to double the per‐
627 cent sign, so that the percent character is passed to latexmk
628 rather than being used to substitute an environment variable:
629
630 latexmk -pdf -jobname=%%A-pdflatex *.tex
631 latexmk -pdfxe -jobname=%%A-xelatex *.tex
632
633
634 -l Run in landscape mode, using the landscape mode for the preview‐
635 ers and the dvi to postscript converters. This option is not
636 normally needed nowadays, since current previewers normally de‐
637 termine this information automatically.
638
639
640 -l- Turn off -l.
641
642
643 -latex This sets the generation of dvi files by latex, and turns off
644 the generation of pdf and ps files.
645
646 Note: to set the command used when latex is specified, see the
647 -latex="COMMAND" option.
648
649
650 -latex="COMMAND"
651 This sets the string specifying the command to run latex, and is
652 typically used to add desired options. Since the string nor‐
653 mally contains spaces, it should be quoted, e.g.,
654
655 latexmk -latex="latex --shell-escape %O %S" foo.tex
656
657 The specification of the contents of the string are the same as
658 for the $latex configuration variable. Depending on your oper‐
659 ating system and the command-line shell you are using, you may
660 need to change the single quotes to double quotes (or something
661 else).
662
663 Note: This option when provided with the COMMAND argument only
664 sets the command for invoking latex; it does not turn on the use
665 of latex. That is done by other options or in an initialization
666 file.
667
668 To set the command for running pdflatex (rather than the command
669 for latex) see the -pdflatex option.
670
671
672 -logfilewarninglist
673 -logfilewarnings After a run of *latex, give a list of warnings
674 about undefined citations and references (unless silent mode is
675 on).
676
677 See also the $silence_logfile_warnings configuration variable.
678
679
680 -logfilewarninglist-
681 -logfilewarnings- After a run of *latex, do not give a list of
682 warnings about undefined citations and references. (Default)
683
684 See also the $silence_logfile_warnings configuration variable.
685
686
687 -lualatex
688 Use lualatex. That is, use lualatex to process the source
689 file(s) to pdf. The generation of dvi and postscript files is
690 turned off.
691
692 This option is equivalent to using the following set of options
693
694 -pdflua -dvi- -ps-
695
696 (Note: Note that the method of implementation of this option,
697 but not its intended effect, differ from some earlier versions
698 of latexmk.)
699
700
701 -lualatex="COMMAND"
702 This sets the string specifying the command to run lualatex. It
703 behaves like the -pdflatex option, but sets the variable $luala‐
704 tex.
705
706 Note: This option when provided with the COMMAND argument only
707 sets the command for invoking lualatex; it does not turn on the
708 use of lualatex. That is done by other options or in an initial‐
709 ization file.
710
711
712 -M Show list of dependent files after processing. This is equiva‐
713 lent to the -deps option.
714
715
716 -MF file
717 If a list of dependents is made, the -MF specifies the file to
718 write it to.
719
720
721 -MP If a list of dependents is made, include a phony target for each
722 source file. If you use the dependents list in a Makefile, the
723 dummy rules work around errors the program make gives if you re‐
724 move header files without updating the Makefile to match.
725
726
727 -makeindexfudge
728 Turn on the change-directory fudge for makeindex. See documen‐
729 tation of $makeindex_fudge for details.
730
731
732 -makeindexfudge-
733 Turn off the change-directory fudge for makeindex. See documen‐
734 tation of $makeindex_fudge for details.
735
736
737 -MSWinBackSlash
738 This option only has an effect when latexmk is running under MS-
739 Windows. This is that when latexmk runs a command under MS-Win‐
740 dows, the Windows standard directory separator "\" is used to
741 separate directory components in a file name. Internally, la‐
742 texmk uses "/" for the directory separator character, which is
743 the character used by Unix-like systems.
744
745 This is the default behavior. However the default may have been
746 overridden by a configuration file (latexmkrc file) which sets
747 $MSWin_back_slash=0.
748
749
750 -MSWinBackSlash-
751 This option only has an effect when latexmk is running under MS-
752 Windows. This is that when latexmk runs a command under MS-Win‐
753 dows, the substitution of "\" for the separator character be‐
754 tween directory components of a file name is not done. Instead
755 the forward slash "/" is used, the same as on Unix-like systems.
756 This is acceptable in most situations under MS-Windows, provided
757 that filenames are properly quoted, as latexmk does by default.
758
759 See the documentation for the configuration variable
760 $MSWin_back_slash for more details.
761
762
763 -new-viewer
764 When in continuous-preview mode, always start a new viewer to
765 view the generated file. By default, latexmk will, in continu‐
766 ous-preview mode, test for a previously running previewer for
767 the same file and not start a new one if a previous previewer is
768 running. However, its test sometimes fails (notably if there is
769 an already-running previewer that is viewing a file of the same
770 name as the current file, but in a different directory). This
771 option turns off the default behavior.
772
773
774 -new-viewer-
775 The inverse of the -new-viewer option. It puts latexmk in its
776 normal behavior that in preview-continuous mode it checks for an
777 already-running previewer.
778
779
780 -nobibtex
781 Never run bibtex or biber. Equivalent to the -bibtex- option.
782
783
784 -nobibtexfudge or -nobibfudge
785 Turn off the change-directory fudge for bibtex. See documenta‐
786 tion of $bibtex_fudge for details.
787
788
789 -noemulate-aux-dir
790 Turn aux_dir emulation off. Same as -emulate-aux-dir-.
791
792
793 -nomakeindexfudge
794 Turn off the change-directory fudge for makeindex. See documen‐
795 tation of $makeindex_fudge for details.
796
797
798 -norc Turn off the automatic reading of initialization (rc) files.
799
800 N.B. Normally the initialization files are read and obeyed, and
801 then command line options are obeyed in the order they are en‐
802 countered. But -norc is an exception to this rule: it is acted
803 on first, no matter where it occurs on the command line.
804
805
806 -outdir=FOO or -output-directory=FOO
807
808 Sets the directory for the output files of *latex.
809
810 If the aux directory is not set or is the same as the output di‐
811 rectory, then all output files of *latex are sent to the output
812 directory.
813
814 If the aux directory is set, e.g., by the option -auxdir, and is
815 not equal to the output directory, then only final output files
816 (.dvi, .ps, .pdf, .synctex, .synctex.gz) are sent to the output
817 directory. Other generated files are sent to the aux directory.
818
819 See the section AUXILIARY AND OUTPUT DIRECTORIES for more de‐
820 tails.
821
822
823 -output-format=FORMAT
824 This option is one that is allowed for latex, lualatex, and
825 pdflatex. But it is not passed to these programs. Instead la‐
826 texmk emulates it in a way suitable for the context of latexmk
827 and its workflows.
828
829 If FORMAT is dvi, then dvi output is turned on, and postscript
830 and pdf output are turned off. This is equivalent to using the
831 options -dvi -ps- -pdf-.
832
833 If FORMAT is pdf, then pdf output is turned on, and dvi and
834 postscript output are turned off. This is equivalent to using
835 the options -pdf -ps- -dvi-.
836
837 If FORMAT is anything else, latexmk gives an error.
838
839
840 -p Print out the document. By default the file to be printed is
841 the first in the list postscript, pdf, dvi that is being made.
842 But you can use the -print=... option to change the type of file
843 to be printed, and you can configure this in a start up file (by
844 setting the $print_type variable).
845
846 However, printing is enabled by default only under UNIX/Linux
847 systems, where the default is to use the lpr command and only on
848 postscript files. In general, the correct behavior for printing
849 very much depends on your system's software. In particular, un‐
850 der MS-Windows you must have suitable program(s) available, and
851 you must have configured the print commands used by latexmk.
852 This can be non-trivial. See the documentation on the $lpr,
853 $lpr_dvi, and $lpr_pdf configuration variables to see how to set
854 the commands for printing.
855
856 This option is incompatible with the -pv and -pvc options, so it
857 turns them off.
858
859
860 -pdf Generate pdf version of document using pdflatex. (If you wish
861 to use lualatex or xelatex, you can use whichever of the options
862 -pdflua, -pdfxe, -lualatex or -xelatex applies.) To configure
863 latexmk to have such behavior by default, see the section on
864 "Configuration/initialization (rc) files".
865
866
867 -pdfdvi
868 Generate dvi file and then pdf version of document from the dvi
869 file, by default using dvipdf.
870
871 The program used to compile the document to dvi is latex by de‐
872 fault, but this can be changed to dvilulatex by the use of the
873 -dvilua option or by setting $dvi_mode to 2.
874
875
876 -pdflua
877 Generate pdf version of document using lualatex.
878
879
880 -pdfps Generate dvi file, ps file from the dvi file, and then pdf file
881 from the ps file.
882
883 The program used to compile the document to dvi is latex by de‐
884 fault, but this can be changed to dvilulatex by the use of the
885 -dvilua option or by setting $dvi_mode to 2.
886
887
888 -pdfxe Generate pdf version of document using xelatex. Note that to
889 optimize processing time, latexmk uses xelatex to generate an
890 .xdv file rather than a pdf file directly. Only after possibly
891 multiple runs to generate a fully up-to-date .xdv file does la‐
892 texmk then call xdvipdfmx to generate the final .pdf file.
893
894 (Note: The reason why latexmk arranges for xelatex to make an
895 .xdv file instead of the xelatex's default of a .pdf file is as
896 follows: When the document includes large graphics files, espe‐
897 cially .png files, the production of a .pdf file can be quite
898 time consuming, even when the creation of the .xdv file by xela‐
899 tex is fast. So the use of the intermediate .xdv file can re‐
900 sult in substantial gains in procesing time, since the .pdf file
901 is produced once rather than on every run of xelatex.)
902
903
904 -pdf- Turn off generation of pdf version of document. (This can be
905 used to override a setting in a configuration file. It may get
906 overridden if some other option requires the generation of a pdf
907 file.)
908
909 If after all options have been processed, pdf generation is
910 still turned off, then generation of a dvi file will be turned
911 on, and then the program used to compiled a document will be la‐
912 tex (or, more precisely, whatever program is configured to be
913 used in the $latex configuration variable).
914
915
916 -pdflatex
917 This sets the generation of pdf files by pdflatex, and turns off
918 the generation of dvi and ps files.
919
920 Note: to set the command used when pdflatex is specified, see
921 the -pdflatex="COMMAND" option.
922
923
924 -pdflatex="COMMAND"
925 This sets the string specifying the command to run pdflatex, and
926 is typically used to add desired options. Since the string nor‐
927 mally contains spaces, it should be quoted, e.g.,
928
929 latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S"
930 foo.tex
931
932 The specification of the contents of the string are the same as
933 for the $pdflatex configuration variable. (The option -pdflatex
934 in fact sets the variable $pdflatex.) Depending on your operat‐
935 ing system and the command-line shell you are using, you may
936 need to change the single quotes to double quotes (or something
937 else).
938
939 Note: This option when provided with the COMMAND argument only
940 sets the command for invoking pdflatex; it does not turn on the
941 use of pdflatex. That is done by other options or in an initial‐
942 ization file.
943
944 To set the command for running latex (rather than the command
945 for pdflatex) see the -latex option.
946
947
948 -pdflualatex="COMMAND"
949 Equivalent to -lualatex="COMMAND".
950
951
952 -pdfxelatex="COMMAND"
953 Equivalent to -xelatex="COMMAND".
954
955
956 -pretex=CODE
957
958 Given that CODE is some TeX code, this options sets that code to
959 be executed before inputting source file. This only works if
960 the command for invoking the relevant *latex is suitably config‐
961 ured. See the documentation of the variable $pre_tex_code, and
962 the substitution strings %P and %U for more details. This op‐
963 tion works by setting the variable $pre_tex_code.
964
965 See also the -usepretex option.
966
967 An example:
968
969 latexmk -pretex='\AtBeginDocument{Message\par}' -usepretex
970 foo.tex
971
972 But this is better written
973
974 latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
975
976 If you already have a suitable command configured, you only need
977
978 latexmk -pretex='\AtBeginDocument{Message\par}' foo.tex
979
980
981 -print=dvi, -print=ps, -print=pdf, -print=auto,
982 Define which kind of file is printed. This option also ensures
983 that the requisite file is made, and turns on printing.
984
985 The (default) case -print=auto determines the kind of print file
986 automatically from the set of files that is being made. The
987 first in the list postscript, pdf, dvi that is among the files
988 to be made is the one used for print out.
989
990
991 -ps Generate postscript version of document.
992
993
994 -ps- Turn off generation of postscript version of document. This can
995 be used to override a setting in a configuration file. (It may
996 get overridden by some other option that requires a postscript
997 file, for example a request for printing.)
998
999
1000 -pF Postscript file filtering. The argument to this option is a
1001 filter which will generate a filtered postscript file with the
1002 extension ".psF". All extra processing (e.g. preview, printing)
1003 will then be performed on this filtered postscript file.
1004
1005 Example of usage: Use psnup to print two pages on the one page:
1006
1007 latexmk -ps -pF 'psnup -2' foo.tex
1008
1009 or
1010
1011 latexmk -ps -pF "psnup -2" foo.tex
1012
1013 Whether to use single or double quotes round the "psnup -2" will
1014 depend on your command interpreter, as used by the particular
1015 version of perl and the operating system on your computer.
1016
1017
1018 -pv Run file previewer. If the -view option is used, that will se‐
1019 lect the kind of file to be previewed (.pdf, .ps or .dvi). Oth‐
1020 erwise the viewer views the "highest" kind of output file that
1021 is made, with the ordering being .pdf, .ps, .dvi (high to low).
1022 This option is incompatible with the -p and -pvc options, so it
1023 turns them off.
1024
1025
1026 -pv- Turn off -pv.
1027
1028
1029 -pvc Run a file previewer and continually update the .dvi, .ps,
1030 and/or .pdf files whenever changes are made to source files (see
1031 the Description above). Which of these files is generated and
1032 which is viewed is governed by the other options, and is the
1033 same as for the -pv option. The preview-continuous option -pvc
1034 can only work with one file. So in this case you will normally
1035 only specify one filename on the command line. It is also in‐
1036 compatible with the -p and -pv options, so it turns these op‐
1037 tions off.
1038
1039 The -pvc option also turns off force mode (-f), as is normally
1040 best for continuous preview mode. If you really want force
1041 mode, use the options in the order -pvc -f.
1042
1043 With a good previewer the display will be automatically updated.
1044 (Under some but not all versions of UNIX/Linux "gv -watch" does
1045 this for postscript files; this can be set by a configuration
1046 variable. This would also work for pdf files except for an ap‐
1047 parent bug in gv that causes an error when the newly updated pdf
1048 file is read.) Many other previewers will need a manual update.
1049
1050 Important note: the acroread program on MS-Windows locks the pdf
1051 file, and prevents new versions being written, so it is a bad
1052 idea to use acroread to view pdf files in preview-continuous
1053 mode. It is better to use a different viewer: SumatraPDF and
1054 gsview are good possibilities.
1055
1056 There are some other methods for arranging an update, notably
1057 useful for many versions of xdvi and xpdf. These are best set
1058 in latexmk's configuration; see below.
1059
1060 Note that if latexmk dies or is stopped by the user, the
1061 "forked" previewer will continue to run. Successive invocations
1062 with the -pvc option will not fork new previewers, but latexmk
1063 will normally use the existing previewer. (At least this will
1064 happen when latexmk is running under an operating system where
1065 it knows how to determine whether an existing previewer is run‐
1066 ning.)
1067
1068
1069 -pvc- Turn off -pvc.
1070
1071
1072 -pvctimeout
1073 Do timeout in pvc mode after period of inactivity, which is 30
1074 min. by default. Inactivity means a period when latexmk has de‐
1075 tected no file changes and hence has not taken any actions like
1076 compiling the document.
1077
1078
1079 -pvctimeout-
1080 Don't do timeout in pvc mode after inactivity.
1081
1082
1083 -pvctimeoutmins=<time>
1084 Set period of inactivity in minutes for pvc timeout.
1085
1086
1087 -quiet Same as -silent
1088
1089
1090 -r <rcfile>
1091 Read the specified initialization file ("RC file") before pro‐
1092 cessing.
1093
1094 Be careful about the ordering: (1) Standard initialization files
1095 -- see the section below on "Configuration/initialization (RC)
1096 files" -- are read first. (2) Then the options on the command
1097 line are acted on in the order they are given. Therefore if an
1098 initialization file is specified by the -r option, it is read
1099 during this second step. Thus an initialization file specified
1100 with the -r option can override both the standard initialization
1101 files and previously specified options. But all of these can be
1102 overridden by later options.
1103
1104 The contents of the RC file just comprise a piece of code in the
1105 Perl programming language (typically a sequence of assignment
1106 statements); they are executed when the -r option is encountered
1107 during latexmk's parsing of its command line. See the -e option
1108 for a way of giving initialization code directly on latexmk's
1109 command line. An error results in latexmk stopping. Multiple
1110 instances of the -r and -e options can be used, and they are ex‐
1111 ecuted in the order they appear on the command line.
1112
1113
1114 -rc-report
1115 After initialization, give a list of the RC files read. (De‐
1116 fault)
1117
1118
1119 -rc-report-
1120 After initialization, do not give a list of the RC files read.
1121
1122
1123 -recorder
1124 Give the -recorder option with *latex. In (most) modern ver‐
1125 sions of these programs, this results in a file of extension
1126 .fls containing a list of the files that these programs have
1127 read and written. Latexmk will then use this file to improve
1128 its detection of source files and generated files after a run of
1129 *latex. This is the default setting of latexmk, unless overrid‐
1130 den in an initialization file.
1131
1132 For further information, see the documentation for the $recorder
1133 configuration variable.
1134
1135
1136 -recorder-
1137 Do not supply the -recorder option with *latex.
1138
1139
1140 -rules Show a list of latemk's rules and dependencies after processing.
1141
1142
1143 -rules-
1144 Do not show a list of latexmk's rules and dependencies after
1145 processing. (This is the default.)
1146
1147
1148 -showextraoptions
1149 Show the list of extra *latex options that latexmk recognizes,
1150 but that it simply passes through to the programs *latex when
1151 they are run. These options are (currently) a combination of
1152 those allowed by the TeXLive and MiKTeX implementations. (If a
1153 particular option is given to latexmk but is not handled by the
1154 particular implementation of *latex that is being used, that
1155 program will probably give a warning or an error.) These op‐
1156 tions are very numerous, but are not listed in this documenta‐
1157 tion because they have no effect on latexmk's actions.
1158
1159 There are a few options (e.g., -includedirectory=dir, -initial‐
1160 ize, -ini) that are not recognized, either because they don't
1161 fit with latexmk's intended operations, or because they need
1162 special processing by latexmk that isn't implemented (at least,
1163 not yet).
1164
1165 There are certain options for *latex (e.g., -recorder) that
1166 trigger special actions or behavior by latexmk itself. Depending
1167 on the action, they may also be passed in some form to the
1168 called *latex program, and/or may affect other programs as well.
1169 These options do have entries in this documentation. Among
1170 these options are: -jobname=STRING, -aux-directory=dir, -output-
1171 directory=DIR, -quiet, and -recorder.
1172
1173 There are also options that are accepted by *latex, but instead
1174 trigger actions purely by latexmk: -help, -version.
1175
1176
1177 -silent
1178 Run commands silently, i.e., with options that reduce the amount
1179 of diagnostics generated. For example, with the default set‐
1180 tings, the command "latex -interaction=batchmode" is used for
1181 latex, and similarly for its friends.
1182
1183 See also the -logfilewarninglist and -logfilewarninglist- op‐
1184 tions.
1185
1186 Also reduce the number of informational messages that latexmk
1187 itself generates.
1188
1189 To change the options used to make the commands run silently,
1190 you need to configure latexmk with changed values of its config‐
1191 uration variables, the relevant ones being $bib‐
1192 tex_silent_switch, $biber_silent_switch, $dvipdf_silent_switch,
1193 $dvips_silent_switch, $dvilualatex_silent_switch, $la‐
1194 tex_silent_switch, $lualatex_silent_switch $makein‐
1195 dex_silent_switch, $pdflatex_silent_switch, and $xela‐
1196 tex_silent_switch
1197
1198
1199 -stdtexcmds
1200 Sets the commands for latex, etc, so that they are the standard
1201 ones. This is useful to override special configurations.
1202
1203 The result is that $latex = 'latex %O %S', and similarly for
1204 $pdflatex, $lualatex, and $xelatex. (The option -no-pdf needed
1205 for $xelatex is provided automatically, given that %O appears in
1206 the definition.)
1207
1208
1209 -time Show time used. (On MS Windows, what is shown is clock time; on
1210 other systems CPU time.) See also the configuration variable
1211 $show_time.
1212
1213
1214 -time- Do not show time used. See also the configuration variable
1215 $show_time.
1216
1217
1218 -use-make
1219 When after a run of *latex, there are warnings about missing
1220 files (e.g., as requested by the LaTeX \input, \include, and
1221 \includgraphics commands), latexmk tries to make them by a cus‐
1222 tom dependency. If no relevant custom dependency with an appro‐
1223 priate source file is found, and if the -use-make option is set,
1224 then as a last resort latexmk will try to use the make program
1225 to try to make the missing files.
1226
1227 Note that the filename may be specified without an extension,
1228 e.g., by \includegraphics{drawing} in a LaTeX file. In that
1229 case, latexmk will try making drawing.ext with ext set in turn
1230 to the possible extensions that are relevant for latex (or as
1231 appropriate pdflatex, lualatex, xelatex).
1232
1233 See also the documentation for the $use_make_for_missing_files
1234 configuration variable.
1235
1236
1237 -use-make-
1238 Do not use the make program to try to make missing files. (De‐
1239 fault.)
1240
1241
1242 -usepretex
1243 Sets the command lines for latex, etc, so that they use the code
1244 that is defined by the variable $pre_tex_code or that is set by
1245 the option -pretex=CODE to execute the specified TeX code before
1246 the source file is read. This option overrides any previous
1247 definition of the command lines.
1248
1249 The result is that $latex = 'latex %O %P', and similarly for
1250 $pdflatex, $lualatex, and $xelatex. (The option -no-pdf needed
1251 for $xelatex is provided automatically, given that %O appears in
1252 the definition.)
1253
1254
1255 -usepretex=CODE
1256 Equivalent to -pretex=CODE -usepretex. Example
1257
1258 latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
1259
1260
1261 -v or -version
1262 Print version number of latexmk.
1263
1264
1265 -verbose
1266 Opposite of -silent. This is the default setting.
1267
1268
1269 -view=default, -view=dvi, -view=ps, -view=pdf, -view=none
1270 Set the kind of file used when previewing is requested (e.g., by
1271 the -pv or -pvc switches). The default is to view the "highest"
1272 kind of requested file (in the low-to-high order .dvi, .ps,
1273 .pdf).
1274
1275 Note the possibility -view=none where no viewer is opened at
1276 all. One example of is use is in conjunction with the -pvc op‐
1277 tion, when you want latexmk to do a compilation automatically
1278 whenever source file(s) change, but do not want a previewer to
1279 be opened.
1280
1281
1282 -Werror
1283 This causes latexmk to return a non-zero status code if any of
1284 the files processed gives a warning about problems with cita‐
1285 tions or references (i.e., undefined citations or references or
1286 about multiply defined references). This is after latexmk has
1287 completed all the runs it needs to try and resolve references
1288 and citations. Thus -Werror causes latexmk to treat such warn‐
1289 ings as errors, but only when they occur on the last run of *la‐
1290 tex and only after processing is complete. Also can be set by
1291 the configuration variable $warnings_as_errors.
1292
1293
1294 -xdv Generate xdv version of document using xelatex.
1295
1296
1297 -xelatex
1298 Use xelatex. That is, use xelatex to process the source file(s)
1299 to pdf. The generation of dvi and postscript files is turned
1300 off.
1301
1302 This option is equivalent to using the following set of options
1303
1304 -pdfxe -dvi- -ps-
1305
1306 [Note: Note that the method of implementation of this option,
1307 but not its intended primary effect, differ from some earlier
1308 versions of latexmk. Latexmk first uses xelatex to make an .xdv
1309 file, and does all the extra runs needed (including those of
1310 bibtex, etc). Only after that does it make the pdf file from
1311 the .xdv file, using xdvipdfmx. See the documentation for the
1312 -pdfxe for why this is done.]
1313
1314
1315 -xelatex="COMMAND"
1316 This sets the string specifying the command to run xelatex. It
1317 sets the variable $xelatex.
1318
1319 Warning: It is important to ensure that the -no-pdf is used when
1320 xelatex is invoked, since latexmk expects xelatex to produce an
1321 .xdv file, not a .pdf file. If you provide %O in the command
1322 specification, this will be done automatically. See the docu‐
1323 mentation for the -pdfxe option for why latexmk makes a .xdv
1324 file rather than a .pdf file when xelatex is used.
1325
1326 An example of the use of the -pdfxelatex option:
1327
1328 latexmk -pdfxe -pdfxelatex="xelatex --shell-escape %O %S"
1329 foo.tex
1330
1331 Note: This option when provided with the COMMAND argument only
1332 sets the command for invoking lualatex; it does not turn on the
1333 use of lualatex. That is done by other options or in an initial‐
1334 ization file.
1335
1336
1337 Compatibility between options
1338
1339 The preview-continuous option -pvc can only work with one file. So in
1340 this case you will normally only specify one filename on the command
1341 line.
1342
1343 Options -p, -pv and -pvc are mutually exclusive. So each of these op‐
1344 tions turns the others off.
1345
1346
1348 % latexmk thesis # run latex enough times to resolve
1349 cross-references
1350
1351 % latexmk -pvc -ps thesis# run latex enough times to resolve
1352 cross-references, make a postscript
1353 file, start a previewer. Then
1354 watch for changes in the source
1355 file thesis.tex and any files it
1356 uses. After any changes rerun latex
1357 the appropriate number of times and
1358 remake the postscript file. If latex
1359 encounters an error, latexmk will
1360 keep running, watching for
1361 source file changes.
1362
1363 % latexmk -c # remove .aux, .log, .bbl, .blg, .dvi,
1364 .pdf, .ps & .bbl files
1365
1366
1367
1369 Some possibilities:
1370
1371 a. If you get a strange error, do look carefully at the output that is
1372 on the screen and in log files. While there is much that is notori‐
1373 ously verbose in the output of latex (and that is added to by latexmk),
1374 the verbosity is there for a reason: to enable the user to diagnose
1375 problems. Latexmk does repeat some messages at the end of a run that
1376 it thinks would otherwise be easy to miss in the middle of other out‐
1377 put.
1378
1379 b. Generally, remember that latexmk does its work by running other pro‐
1380 grams. Your first priority in dealing with errors should be to examine
1381 what went wrong with the individual programs. Then you need to correct
1382 the causes of errors in the runs of these programs. (Often these come
1383 from errors in the source document, but they could also be about miss‐
1384 ing LaTeX packages, etc.)
1385
1386 c. If latexmk doesn't run the programs the way you would like, then you
1387 need to look in this documentation at the list of command line options
1388 and then at the sections on configuration/initialization files. A lot
1389 of latexmk's behavior is configurable to deal with particular situa‐
1390 tions. (But there is a lot of reading!)
1391
1392 The remainder of these notes consists of ideas for dealing with more
1393 difficult situations.
1394
1395 d. Further tricks can involve replacing the standard commands that la‐
1396 texmk runs by other commands or scripts.
1397
1398 e. For possible examples of code for use in an RC file, see the direc‐
1399 tory example_rcfiles in the distribution of latexmk (e.g., at
1400 http://mirror.ctan.org/support/latexmk/example_rcfiles). Even if these
1401 examples don't do what you want, they may provide suitable inspiration.
1402
1403 f. There's a useful trick that can be used when you use lualatex in‐
1404 stead of pdflatex (and in some related situations). The problem is
1405 that latexmk won't notice a dependency on a file, bar.baz say, that is
1406 input by the lua code in your document instead of by the LaTeX part.
1407 (Thus if you change bar.baz and rerun latexmk, then latexmk will think
1408 no files have changed and not rerun lualatex, whereas if you had '\in‐
1409 put{bar.baz}' in the LaTeX part of the document, latexmk would notice
1410 the change.) One solution is just to put the following somewhere in
1411 the LaTeX part of the document:
1412
1413 \typeout{(bar.baz)}
1414
1415 This puts a line in the log file that latexmk will treat as implying
1416 that the file bar.baz was read. (At present I don't know a way of do‐
1417 ing this automatically.) Of course, if the file has a different name,
1418 change bar.baz to the name of your file.
1419
1420 g. See also the section "Advanced Configuration: Some extra resources".
1421
1422 h. Look on tex.stackexchange, i.e., at http://tex.stackex‐
1423 change.com/questions/tagged/latexmk Someone may have already solved
1424 your problem.
1425
1426 i. Ask a question at tex.stackexchange.com.
1427
1428 j. Or ask me (the author of latexmk). My e-mail is at the end of this
1429 documentation.
1430
1431
1432
1434 Running *latex and the associated programs generate a number of files,
1435 it is often convenient to arrange for the generated files to be in a
1436 different directory than the source file(s) of a document. For our
1437 purposes here, we identify two classes of generated file.
1438
1439 One class is what one may term the final output files, for example, the
1440 .pdf file generated by running pdflatex, or the .dvi file from latex.
1441 Also in this class is the ps file generated by applying dvips to a .dvi
1442 file. There are also .synctec or .synctex.gz files that can be used by
1443 programs that display .pdf files and the like to relate positions in
1444 them to positions in source files.
1445
1446 The second class of file is composed of all other generated files:
1447 These include notably .aux files that are used for implementing cross
1448 referencing, and are both generated on one run and read on a later run.
1449 Many packages generate yet more such intermediate files, as well as
1450 programs like bibtex, makeindex, etc. There are also .log files from
1451 *latex and corresponding files from other programs.
1452
1453 Let us use the term "output directory" for the directory that receives
1454 the final output files, and "aux directory" for the directory for the
1455 other generated files. If no special options are provided to the *la‐
1456 tex programs, these directories default to the current directory, and
1457 then the generated files aren't segregated. If the two directories are
1458 the same, as is the simplest situation, then all generated files are
1459 written to the same directory, and one often simply refers to the out‐
1460 put directory, without mentioning a separate aux directory.
1461
1462 Support for them is provided for them in the *latex programs: by the
1463 single option -output-directory for the TeXLive implementations, and by
1464 the options -aux-directory and -output-directory for the MiKTeX imple‐
1465 mentations. Special support like this is needed for two reasons: First
1466 is that there are many packages that write files and it needs to be ar‐
1467 ranged that these are automatically written to the appropriate direc‐
1468 tory without any rewriting of the packages' code. Second is that the
1469 files are often read in again on subsequent runs of *latex, and it is
1470 necessary that the program knows where to find the files.
1471
1472 A complication is that the TeXLive implementation does not allow for
1473 separate aux and output directories. Latexmk deals with this by being
1474 able to emulating a separate aux directory: In this method it invokes
1475 *latex with just an -output-directory option, with the directory set
1476 not to the desired output directory, but to the aux directory. After
1477 running *latex, it moves the relevant final output file(s) to the in‐
1478 tended output directory. Emulation can be turned on by setting the
1479 configuration variable $emulate_aux to one in a configuration file or
1480 by using latexmk's -emulate-aux-dir option. The emulation method works
1481 equally well if MiKTeX is used.
1482
1483 Latexmk also turns emulation on if it is found to be needed, as fol‐
1484 lows. Suppose emulation is initially off, but the aux and output di‐
1485 rectories are different. Then latexmk invokes *latex with an -aux-di‐
1486 rectory option and after the run finds that it hasn't been obeyed, no‐
1487 tably because the .log file is in the output directory rather than the
1488 aux directory. Latexmk then sets emulation on, and retries. Conceiv‐
1489 ably, it could move all the appropriate generated files from the output
1490 directory to the aux directory; but there is such a large variety of
1491 possibilities for these files that this is hard to identify all of them
1492 reliably except for simple cases.
1493
1494 Note that the emulation issue only arises when the user has arranged
1495 for the the aux and output directories to be different. When instead
1496 they are equal, e.g., because the user only set the $out_dir variable,
1497 then latexmk invokes *latex with only an -output-directory option,
1498 which works as intended with both TeXLive and MiKTeX.
1499
1500 In addition, latexmk arranges the invocations of any auxiliary programs
1501 like bibtex and makeindex so that they will read and write the relevant
1502 files from and to the aux directory. Programs like dvips, dvipdf,
1503 ps2pdf, and xdvipdfmx are invoked so that they read from the appropri‐
1504 ate places and write their output to the output directory.
1505
1506 Files considered as final output files, i.e., those that belong in the
1507 output directory rather than the aux directory: These have the exten‐
1508 sions .dvi, .ps., .pdf, .synctex, and .synctex.gz. A special case, be‐
1509 cause of compatibility issues, is of .fls files: See below.
1510
1511 Note that xelatex when invoked with its -no-pdf option, as latexmk
1512 does, generates an .xdv file, which would appear to have the same sta‐
1513 tus as a .dvi file generated by latex. Nevertheless, latexmk treats
1514 .xdv as an intermediate file that is found in the aux directory. This
1515 is to match MiKTeX's treatment of the -aux-directory option. As fur‐
1516 ther justification, one can say that under modern conditions an .xdv
1517 file is (almost) always an intermediate file. Historically, the situa‐
1518 tion with .dvi files from latex was different, and currently dvi pre‐
1519 viewers do exist.
1520
1521
1522 Variables and options for directories: The variables for setting the
1523 aux and output directories are $aux_dir and $out_dir, with correspond‐
1524 ing command line options -auxdir (or -aux-directory) and -outdir (or
1525 -output-directory). When a value for these is blank (which is the de‐
1526 fault value), it implies the use of a default: For the aux directory,
1527 the default is to set it equal to the output directory. For the output
1528 directory, the default is to be the current directory.
1529
1530 For the turning on and off of the emulation mode, there is the configu‐
1531 ration variable $emulate_aux and the options -emulate-aux-dir, -emu‐
1532 late-aux-dir-, -noemulate-aux-dir.
1533
1534
1535 Interaction with -cd option: When the -cd option is used (or the equiv‐
1536 alent setting of $do_cd variable), then latexmk changes the working di‐
1537 rectory to the document directory before invoking *latex. If the aux
1538 and/or output directories are given by relative paths, e.g., by -out‐
1539 dir=output for a directory named "output", then the directories are
1540 relative to the document directory, rather than relative to the working
1541 directory that was in effect when latexmk was invoked. This matches the
1542 behavior of *latex as invoked with the provided command line directory
1543 argument(s) after the change of working directory to the document di‐
1544 rectory.
1545
1546 Automatic creation of aux and output directories: Unlike *latex, if la‐
1547 texmk finds the requested directory/ies don't exist, it creates
1548 it/them, thereby avoiding errors when *latex is invoked.
1549
1550 If the document uses the \include macro to read a .tex file from a sub‐
1551 directory, *latex will attempt to write an extra aux file to the corre‐
1552 sponding subdirectory of the aux directory. If the subdirectory
1553 doesn't exist, then *latex will complain that it can't write the aux
1554 file. After the run of *latex, latexmk detects this situation, creates
1555 the necessary directory, and reruns *latex with the error situation
1556 corrected.
1557
1558 Choice of aux and output directories: Often the aux and output directo‐
1559 ries are given as subdirectories of the document directory, e.g., by
1560 -outdir=output. But it is possible to provide, for example, an absolute
1561 path or a path relative to a parent directory, e.g., "/tmp/foo" or
1562 "../output". Be aware that in general this can cause problems, notably
1563 with makeindex or bibtex. This is because modern versions of these
1564 programs, by default, will refuse to work when they find that they are
1565 asked to write to a file in a directory that appears not to be the cur‐
1566 rent working directory or one of its subdirectories. This is part of
1567 security measures by the whole TeX system that try to prevent malicious
1568 or errant TeX documents from incorrectly messing with a user's files.
1569
1570 By default, latexmk evades this issue: Before running bibtex and make‐
1571 index, latexmk changes working directory to the aux directory, with ap‐
1572 propriate settings of search paths. The use or non-use of this trick
1573 is governed by the variables $bibtex_fudge and $makeindex_fudge. Un‐
1574 fortunately, the trick sometimes makes bibtex and makeindex unable to
1575 find files.
1576
1577 If necessary the trick can be turned off. But this is incompatible with
1578 an aux directory like, "/tmp/foo" of "../output"). If you really have
1579 to deal with this situation, and only if you have to deal with it, then
1580 you need to disable the security measures (and assume any risks). One
1581 way of doing this is to temporarily set an operating system environment
1582 variable openout_any to "a" (as in "all"), to override the default
1583 "paranoid" setting.
1584
1585 Certain names of aux and output directories not allowed on Microsoft
1586 Windows: It is natural to want to use the name "aux" for the aux direc‐
1587 tory, e.g., by using the option -auxdir=aux. But on Microsoft operat‐
1588 ing systems "aux" is one of the names that is not allowed for a file or
1589 directory. I find it useful to standardize on a name like "auxdir"
1590 (e.g., by -auxdir=auxdir); this works independently of operating sys‐
1591 tem.
1592
1593 Location of .fls file: Much of the dependency information that latexmk
1594 uses comes from the .fls file generated when *latex is invoked with the
1595 -recorder option, which latexmk does by default. It may seem rational
1596 that this is written to the aux directory. But in fact versions of
1597 MiKTeX prior to Oct. 2020 wrote it to the output directory. Later ver‐
1598 sions do write it to the aux directory. To deal with this, latexmk
1599 does two things: First, if latexmk finds that the .fls file has only
1600 been generated in the "wrong" directory, then latexmk copies it to the
1601 expected directory, after which latexmk's operation continues correctly
1602 independently of the behavior of *latex. Second it allows its idea of
1603 the "correct" (or expected) directory to be configured by the variable
1604 $fls_uses_aux_dir. This defaults to zero, to correspond to MiKTeX's
1605 current behavior.
1606
1607
1608
1610 When one of the latex engines is run, the usual situation is that latex
1611 produces a .dvi file, while pdflatex and lualatex produce a .pdf file.
1612 For xelatex the default is to produce a .pdf file, but to optimize pro‐
1613 cessing time latexmk runs xelatex its -no-pdf option so that it pro‐
1614 duces an .xdv file. Further processing by latexmk takes this as a
1615 starting point.
1616
1617 However, the actual output file may differ from the normal expectation;
1618 and then latexmk can adjust its processing to accommodate this situa‐
1619 tion. The difference in output file type can happen for two reasons:
1620 One is that for latex, pdflatex and lualatex the document itself can
1621 override the defaults. The other is that there may be a configuration,
1622 or misconfiguration, such that the program that latexmk invokes to com‐
1623 pile the document is not the expected one, or is given options incom‐
1624 patible with what latexmk initially expects.
1625
1626 Under latex and pdflatex, control of the output format by the document
1627 is done by setting the \pdfoutput macro. Under lualatex, the \output‐
1628 mode macro is used instead.
1629
1630 One example of an important use-case for document control of the output
1631 format is a document that uses the psfrag package to insert graphical
1632 elements in the output file. The psfrag package achieves its effects by
1633 inserting postscript code in the output of the compilation of the docu‐
1634 ment. This entails the use of compilation to a .dvi file, followed by
1635 the use of conversion to a postscript file (either directly, as by
1636 dvips or implicitly, as an intermediate step by dvipdf). Then it is
1637 useful to force output to be of the .dvi format by inserting \pdfout‐
1638 put=0 in the preamble of the document.
1639
1640 Another example is where the document uses graphics file of the .pdf,
1641 .jpg, and png types. With the default setting for the graphicx pack‐
1642 age, these can be processed in compilation to .pdf but not with compi‐
1643 lation to .dvi. In this case, it is useful to insert \pdfoutput=1 in
1644 the preamble of the document to force compilation to .pdf output for‐
1645 mat.
1646
1647 In all of these cases, it is needed that latexmk has to adjust its pro‐
1648 cessing to deal with a mismatch between the actual output format (out
1649 of .pdf, .dvi, .xdv) and the initially expected output, if possible.
1650 Latexmk does this provided the following conditions are met.
1651
1652 The first is that latexmk's $allow_switch configuration variable is set
1653 to a non-zero value as it is by default. If this variable is zero, a
1654 mismatch of filetypes in the compilation results in an error.
1655
1656 The second condition for latexmk to be able to handle a change of out‐
1657 put type is that no explicit requests for .dvi or .ps output files are
1658 made. Explicit requests are by the -dvi and -ps, -print=dvi,
1659 -print=ps, -view=dvi, and -view=ps options, and by corresponding set‐
1660 tings of the $dvi_mode, $postscript_mode, $print_type, and $view con‐
1661 figuration variables. The print-type and view-type restrictions only
1662 apply when printing and viewing are explicitly requested, respectively.
1663 For this purpose, the use of the -pdfdvi and -pdfps options (and the
1664 corresponding setting of the $pdf_mode variable) does not count as an
1665 explicit request for the .dvi and .ps files; they are merely regarded
1666 as a request for making a .pdf file together with an initial proposal
1667 for the processing route to make it.
1668
1669 Note that when accommodating a change in output file type, there is in‐
1670 volved a substantial change in the network of rules that latexmk uses
1671 in its actions. The second condition applied to accommodate a change
1672 is to avoid situations where the change in the rule network is too rad‐
1673 ical to be readily handled automatically.
1674
1675
1676
1678 In this section is explained which configuration files are read by la‐
1679 texmk. Subsequent sections "How to Set Variables in Initialization
1680 Files", "Format of Command Specifications", "List of Configuration
1681 Variables Usable in Initialization Files", "Custom Dependencies", and
1682 "Advanced Configuration" give details on what can be configured and
1683 how.
1684
1685 Latexmk can be customized using initialization files, which are read at
1686 startup in the following order:
1687
1688 1) The system RC file, if it exists.
1689 On a UNIX system, latexmk searches the following directories for a
1690 system RC file, which may be named either "LatexMk" or "latexmkrc".
1691 The
1692 directories are searched in the following order, and latexmk uses
1693 the first such file it finds (if any):
1694 "/etc",
1695 "/opt/local/share/latexmk",
1696 "/usr/local/share/latexmk",
1697 "/usr/local/lib/latexmk".
1698 On a MS-Windows system it looks just in "C:\latexmk".
1699 On a cygwin system (i.e., a MS-Windows system in which Perl is that
1700 of cygwin), latexmk looks in the directories
1701 "/cygdrive/c/latexmk",
1702 "/etc",
1703 "/opt/local/share/latexmk",
1704 "/usr/local/share/latexmk",
1705 "/usr/local/lib/latexmk".
1706
1707 If the environment variable LATEXMKRCSYS is set, its value is used as
1708 the name of the system RC file, instead of any of the above.
1709
1710 2) The user's RC file, if it exists. This can be in one of two places.
1711 The traditional one is ".latexmkrc" in the user's home directory. The
1712 other possibility is "latexmk/latexmkrc" in the user's XDG configura‐
1713 tion home directory. The actual file read is the first of "$XDG_CON‐
1714 FIG_HOME/latexmk/latexmkrc" or "$HOME/.latexmkrc" which exists. (See
1715 https://specifications.freedesktop.org/basedir-spec/basedir-spec-lat‐
1716 est.html for details on the XDG Base Directory Specification.)
1717
1718 Here $HOME is the user's home directory. [Latexmk determines the
1719 user's home directory as follows: It is the value of the environment
1720 variable HOME, if this variable exists, which normally is the case on
1721 UNIX-like systems (including Linux and OS-X). Otherwise the environ‐
1722 ment variable USERPROFILE is used, if it exists, which normally is the
1723 case on MS-Windows systems. Otherwise a blank string is used instead of
1724 $HOME, in which case latexmk does not look for an RC file in it.]
1725
1726 $XDG_CONFIG_HOME is the value of the environment variable XDG_CON‐
1727 FIG_HOME if it exists. If this environment variable does not exist,
1728 but $HOME is non-blank, then $XDG_CONFIG_HOME is set to the default
1729 value of $HOME/.config. Otherwise $XDG_CONFIG_HOME is blank, and la‐
1730 texmk does not look for an RC file under it.
1731
1732
1733 3) The RC file in the current working directory. This file can be
1734 named either "latexmkrc" or ".latexmkrc", and the first of these to be
1735 found is used, if any.
1736
1737 4) Any RC file(s) specified on the command line with the -r option.
1738
1739 Each RC file is a sequence of Perl commands. Naturally, a user can use
1740 this in creative ways. But for most purposes, one simply uses a se‐
1741 quence of assignment statements that override some of the built-in set‐
1742 tings of Latexmk. Straightforward cases can be handled without knowl‐
1743 edge of the Perl language by using the examples in this document as
1744 templates. Comment lines are introduced by the "#" character.
1745
1746 Note that command line options are obeyed in the order in which they
1747 are written; thus any RC file specified on the command line with the -r
1748 option can override previous options but can be itself overridden by
1749 later options on the command line. There is also the -e option, which
1750 allows initialization code to be specified in latexmk's command line.
1751
1752 For possible examples of code for in an RC file, see the directory ex‐
1753 ample_rcfiles in the distribution of latexmk (e.g., at http://mir‐
1754 ror.ctan.org/support/latexmk/example_rcfiles).
1755
1756
1758 The important variables that can be configured are described in the
1759 section "List of configuration variables usable in initialization
1760 files". (See the earlier section "Configuration/Initialization (rc)
1761 Files" for the files where the configurations are done.) Syntax for
1762 setting these variables is of the following forms:
1763
1764 $bibtex = 'bibtex %O %S';
1765
1766 for the setting of a string variable,
1767
1768 $preview_mode = 1;
1769
1770 for the setting of a numeric variable, and
1771
1772 @default_files = ('paper', 'paper1');
1773
1774 for the setting of an array of strings. It is possible to append an
1775 item to an array variable as follows:
1776
1777 push @default_files, 'paper2';
1778
1779 Note that simple "scalar" variables have names that begin with a $
1780 character and array variables have names that begin with a @ character.
1781 Each statement ends with a semicolon.
1782
1783 Strings should be enclosed in single quotes. (You could use double
1784 quotes, as in many programming languages. But then the Perl program‐
1785 ming language brings into play some special rules for interpolating
1786 variables into strings. People not fluent in Perl will want to avoid
1787 these complications.)
1788
1789 You can do much more complicated things, but for this you will need to
1790 consult a manual for the Perl programming language.
1791
1792
1793
1794
1796 Some of the variables set the commands that latexmk uses for carrying
1797 out its work, for example to generate a .dvi file from a .tex file or
1798 to view a postscript file. This section describes some important fea‐
1799 tures of how the commands are specified. (Note that some of the possi‐
1800 bilities listed here do not apply to the $kpsewhich variable; see its
1801 documentation.)
1802
1803 Placeholders: Supposed you wanted latexmk to use the command elatex in
1804 place of the regular latex command, and suppose moreover that you
1805 wanted to give it the option "--shell-escape". You could do this by
1806 the following setting:
1807
1808 $latex = 'elatex --shell-escape %O %S';
1809
1810 The two items starting with the % character are placeholders. These
1811 are substituted by appropriate values before the command is run. Thus
1812 %S will be replaced by the source file that elatex will be applied to,
1813 and %O will be replaced by any options that latexmk has decided to use
1814 for this command. (E.g., if you used the -silent option in the invoca‐
1815 tion of latexmk, it results in the replacement of %O by "-interac‐
1816 tion=batchmode".)
1817
1818 The available placeholders are:
1819
1820 %A basename of the main tex file. Unlike %R, this is unaffected by
1821 the setting of a jobname by the -jobname option or the $jobname
1822 configuration value.
1823
1824 %B base of filename for current command. E.g., if a postscript
1825 file document.ps is being made from the dvi file document.dvi,
1826 then the basename is document.
1827
1828 %D destination file (e.g., the name of the postscript file when
1829 converting a dvi file to postscript).
1830
1831 %O options
1832
1833 %P If the variable $pre_tex_code is non-empty, then %P is substi‐
1834 tuted by the contents of $pre_tex_code followed by \in‐
1835 put{SOURCE}, where SOURCE stands for the name of the source
1836 file. Appropriate quoting is done. This enables TeX code to be
1837 passed to one of the *latex engines to be executed before the
1838 source file is read.
1839
1840 If the variable $pre_tex_code is the empty string, then %P is
1841 equivalent to %S.
1842
1843 %R root filename. This is the base name for the main tex file.
1844
1845 By default this is the basename of the main tex file. However
1846 the value can be changed by the use of the -jobname option or
1847 the $jobname configuration variable.
1848
1849 %S source file (e.g., the name of the dvi file when converting a
1850 .dvi file to ps).
1851
1852 %T The name of the primary tex file.
1853
1854 %U If the variable $pre_tex_code is non-empty, then its value is
1855 substituted for %U (appropriately quoted). Otherwise it is re‐
1856 placed by a null string.
1857
1858 %Y Name of directory for auxiliary output files (see the configura‐
1859 tion variable $aux_dir). A directory separation character ('/')
1860 is appended if $aux_dir is non-empty and does not end in a suit‐
1861 able character, with suitable characters being those appropriate
1862 to UNIX and MS-Windows, i.e., ':', '/' and '\'. Note that if
1863 after initialization, $out_dir is set, but $aux_dir is not set
1864 (i.e., it is blank), then latexmk sets $aux_dir to the same
1865 value $out_dir.
1866
1867 %Z Name of directory for output files (see the configuration vari‐
1868 able $out_dir). A directory separation character ('/') is ap‐
1869 pended if $out_dir is non-empty and does not end in a suitable
1870 character, with suitable characters being those appropriate to
1871 UNIX and MS-Windows, i.e., ':', '/' and '\'.
1872
1873 If for some reason you need a literal % character in your string not
1874 subject to the above rules, use "%%".
1875
1876 Appropriate quoting will be applied to the filename substitutions, so
1877 you mustn't supply them yourself even if the names of your files have
1878 spaces in them. (But if your TeX filenames have spaces in them, beware
1879 that some older versions of the TeX program cannot correctly handle
1880 filenames containing spaces.) In case latexmk's quoting does not work
1881 correctly on your system, you can turn it off -- see the documentation
1882 for the variable $quote_filenames.
1883
1884 See the default values in the section "List of configuration variables
1885 usable in initialization files" for what is normally the most appropri‐
1886 ate usage.
1887
1888 If you omit to supply any placeholders whatever in the specification of
1889 a command, latexmk will supply what its author thinks are appropriate
1890 defaults. This gives compatibility with configuration files for previ‐
1891 ous versions of latexmk, which didn't use placeholders.
1892
1893 "Detaching" a command: Normally when latexmk runs a command, it waits
1894 for the command to run to completion. This is appropriate for commands
1895 like latex, of course. But for previewers, the command should normally
1896 run detached, so that latexmk gets the previewer running and then re‐
1897 turns to its next task (or exits if there is nothing else to do). To
1898 achieve this effect of detaching a command, you need to precede the
1899 command name with "start ", as in
1900
1901 $dvi_previewer = 'start xdvi %O %S';
1902
1903 This will be translated to whatever is appropriate for your operating
1904 system.
1905
1906 Notes: (1) In some circumstances, latexmk will always run a command de‐
1907 tached. This is the case for a previewer in preview continuous mode,
1908 since otherwise previewing continuously makes no sense. (2) This pre‐
1909 cludes the possibility of running a command named start. (3) If the
1910 word start occurs more than once at the beginning of the command
1911 string, that is equivalent to having just one. (4) Under cygwin, some
1912 complications happen, since cygwin amounts to a complicated merging of
1913 UNIX and MS-Windows. See the source code for how I've handled the
1914 problem.
1915
1916 Command names containing spaces: Under MS-Windows it is common that the
1917 name of a command includes spaces, since software is often installed in
1918 a subdirectory of "C:\Program Files". Such command names should be en‐
1919 closed in double quotes, as in
1920
1921 $lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p
1922 %S';
1923 $pdf_previewer = 'start "c:/Program Files/SumatraPDF/Suma‐
1924 traPDF.exe" %O %S';
1925 $pdf_previewer = 'start "c:/Program Files/SumatraPDF (x86)/Suma‐
1926 traPDF.exe" %O %S';
1927
1928
1929 (Note about the above example: Under MS-Windows forward slashes are
1930 equivalent to backslashes in a filename under almost all circumstances,
1931 provided that the filename is inside double quotes. It is easier to
1932 use forward slashes in examples like the one above, since then one does
1933 not have to worry about the rules for dealing with forward slashes in
1934 strings in the Perl language.)
1935
1936 Command names under Cygwin: If latexmk is executed by Cygwin's Perl,
1937 be particularly certain that pathnames in commands have forward slashes
1938 not the usual backslashes for the separator of pathname components.
1939 See the above examples. Backslashes often get misinterpreted by the
1940 Unix shell used by Cygwin's Perl to execute external commands. Forward
1941 slashes don't suffer from this problem, and (when quoted, as above) are
1942 equally acceptable to MS-Windows.
1943
1944 Using MS-Windows file associations: A useful trick under modern ver‐
1945 sions of MS-Windows (e.g., WinXP) is to use just the command 'start' by
1946 itself:
1947
1948 $dvi_previewer = 'start %S';
1949
1950 Under MS-Windows, this will cause to be run whatever program the system
1951 has associated with dvi files. (The same applies for a postscript
1952 viewer and a pdf viewer.) But note that this trick is not always suit‐
1953 able for the pdf previwer, if your system has acroread for the default
1954 pdf viewer. As explained elsewhere, acroread under MS-Windows does not
1955 work well with latex and latexmk, because acroread locks the pdf file.
1956
1957 Not using a certain command: If a command is not to be run, the command
1958 name NONE is used, as in
1959
1960 $lpr = 'NONE lpr';
1961
1962 This typically is used when an appropriate command does not exist on
1963 your system. The string after the "NONE" is effectively a comment.
1964
1965 Options to commands: Setting the name of a command can be used not only
1966 for changing the name of the command called, but also to add options to
1967 command. Suppose you want latexmk to use latex with source specials
1968 enabled. Then you might use the following line in an initialization
1969 file:
1970
1971 $latex = 'latex --src-specials %O %S';
1972
1973 Running a subroutine instead of an external command: Use a specifica‐
1974 tion starting with "internal", as in
1975
1976 $latex = 'internal mylatex %O %S';
1977 sub mylatex {
1978 my @args = @_;
1979 # Possible preprocessing here
1980 return system 'latex', @args;
1981 }
1982
1983 For some of the more exotic possibilities that then become available,
1984 see the section "Advanced configuration: Some extra resources and ad‐
1985 vanced tricks". Also see some of the examples in the directory exam‐
1986 ple_rcfiles in the latexmk distribution.
1987
1988 Advanced tricks: Normally one specifies a single command for the com‐
1989 mands invoked by latexmk. Naturally, if there is some complicated ad‐
1990 ditional processing you need to do in your special situation, you can
1991 write a script (or batch file) to do the processing, and then configure
1992 latexmk to use your script in place of the standard program.
1993
1994 You can also use a Perl subroutine instead of a script -- see above.
1995 This is generally the most flexible and portable solution.
1996
1997 It is also possible to configure latexmk to run multiple commands. For
1998 example, if when running pdflatex to generate a pdf file from a tex
1999 file you need to run another program after pdflatex to perform some ex‐
2000 tra processing, you could do something like:
2001
2002 $pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk
2003 %B';
2004
2005 This definition assumes you are using a UNIX-like system (which in‐
2006 cludes Linux and OS-X), so that the two commands to be run are sepa‐
2007 rated by the semicolon in the middle of the string.
2008
2009 If you are using MS-Windows, you would replace the above line by
2010
2011 $pdflatex = 'cmd /c pdflatex --shell-escape %O %S'
2012 . '&& pst2pdf_for_latexmk %B';
2013
2014 Here, the UNIX command separator ; is replaced by &&. In addition,
2015 there is a problem that some versions of Perl on MS-Windows do not obey
2016 the command separator; this problem is overcome by explicitly invoking
2017 the MS-Windows command-line processor cmd.exe.
2018
2019
2021 In this section are specified the variables whose values can be ad‐
2022 justed to configure latexmk. (See the earlier section "Configura‐
2023 tion/Initialization (rc) Files" for the files where the configurations
2024 are done.)
2025
2026 Default values are indicated in brackets. Note that for variables that
2027 are boolean in character, concerning whether latexmk does or does not
2028 behave in a certain way, a non-zero value, normally 1, indicates true,
2029 i.e., the behavior occurs, while a zero value indicates a false value,
2030 i.e., the behavior does not occur.
2031
2032
2033 $allow_switch [1]
2034
2035 This controls what happens when the output extension of latex,
2036 pdflatex, lualatex or xelatex differs from what is expected.
2037 (The possible extensions are .dvi, .pdf, .xdv.) This can happen
2038 with the use of the \pdfoutput macro in a document compiled un‐
2039 der latex or pdflatex, or with the use of the \outputmode macro
2040 under lualatex. It can also happen with certain kinds of incor‐
2041 rect configuration.
2042
2043 In such a case, latexmk can appropriately adjust its network of
2044 rules. The adjustment is made if $allow_switch is on, and if no
2045 request for a dvi or ps file has been made.
2046
2047 See the section ALLOWING FOR CHANGE OF OUTPUT EXTENSION.
2048
2049
2050 $always_view_file_via_temporary [0]
2051 Whether .ps and .pdf files are initially to be made in a tempo‐
2052 rary directory and then moved to the final location. (This ap‐
2053 plies to dvips, dvipdf, and ps2pdf operations, and the filtering
2054 operators on .dvi and .ps files. It does not apply to pdflatex,
2055 unfortunately, since pdflatex provides no way of specifying a
2056 chosen name for the output file.)
2057
2058 This use of a temporary file solves a problem that the making of
2059 these files can occupy a substantial time. If a viewer (notably
2060 gv) sees that the file has changed, it may read the new file be‐
2061 fore the program writing the file has not yet finished its work,
2062 which can cause havoc.
2063
2064 See the $pvc_view_file_via_temporary variable for a setting that
2065 applies only if preview-continuous mode (-pvc option) is used.
2066 See $tmpdir for the setting of the directory where the temporary
2067 file is created.
2068
2069
2070 $analyze_input_log_always [1]
2071
2072 After a run of latex (etc), always analyze .log for input files
2073 in the <...> and (...) constructions. Otherwise, only do the
2074 analysis when fls file doesn't exist or is out of date.
2075
2076 Under normal circumstances, the data in the fls file is reli‐
2077 able, and the test of the log file gets lots of false positives;
2078 usually $analyze_input_log_always is best set to zero. But the
2079 test of the log file is needed at least in the following situa‐
2080 tion: When a user needs to persuade latexmk that a certain file
2081 is a source file, and latexmk doesn't otherwise find it. Then
2082 the user can write code that causes a line with (...) to be
2083 written to log file. One important case is for lualatex, which
2084 doesn't always generate lines in the .fls file for input lua
2085 files. (The situation with lualatex is HIGHLY version depen‐
2086 dent, e.g., there was a big change between TeXLive 2016 and
2087 TeXLive 2017.)
2088
2089 To keep backward compatibility with older versions of latexmk,
2090 the default is to set $analyze_input_log_always to 1.
2091
2092
2093 $auto_rc_use [1]
2094 Whether to automatically read the standard initialization (rc)
2095 files, which are the system RC file, the user's RC file, and the
2096 RC file in the current directory. The command line option -norc
2097 can be used to turn this setting off. Each RC file co2uld also
2098 turn this setting off, i.e., it could set $auto_rc_use to zero
2099 to prevent automatic reading of the later RC files.
2100
2101 This variable does not affect the reading of RC files specified
2102 on the command line by the -r option.
2103
2104 $aux_dir [""]
2105 The aux directory, i.e., the directory in which auxiliary files
2106 (aux, log, etc) are to be written by a run of *latex.
2107
2108 If this variable is not set, but $out_dir is set, then latexmk
2109 takes the aux directory to equal the output directory which is
2110 the directory to which final output files are to be written.
2111
2112 If neither variable is set, then the current directory when *la‐
2113 tex is invoked is used both for the aux and output directories.
2114
2115 If the aux and output directories are distinct, then the aux di‐
2116 rectory contains all generated files with the exception of "fi‐
2117 nal output files", which are defined to be .dvi, .ps, .pdf,
2118 .synctex, and .synctex.gz files.
2119
2120 See the section AUXILIARY AND OUTPUT DIRECTORIES for more de‐
2121 tails.
2122
2123
2124
2125 $aux_out_dir_report [0]
2126 For each primary .tex file processed, list the settings for aux
2127 and output directories, after they have been normalized from the
2128 settings specified during initialization.
2129
2130 This report gives a reminder of where to look for generated
2131 files.
2132
2133 The report has to be done per primary .tex file, because of pos‐
2134 sible directory changes for each file (when the -cd option is
2135 used). In the simplest cases, the directory names are the same
2136 as originally specified. But in general some clean up/normal‐
2137 ization is performed; this helps performance and cleans up out‐
2138 put to the screen.
2139
2140
2141
2142 $bad_warning_is_error [0]
2143 Whether to treat bad warnings reported by *latex in log file as
2144 errors. The specifications of the warning messages are in
2145 @bad_warnings.
2146
2147
2148 @bad_warnings
2149 Array of regular expressions specifying messages in log file
2150 that are officially treated as warnings rather than errors by
2151 *latex, but which a user may treat as errors: See $bad_warn‐
2152 ing_is_error.
2153
2154 Currently the default set of these warnings is those about \end
2155 occuring inside constructs.
2156
2157
2158 $banner [0]
2159 If nonzero, the banner message is printed across each page when
2160 converting the dvi file to postscript. Without modifying the
2161 variable $banner_message, this is equivalent to specifying the
2162 -d option.
2163
2164 Note that if $banner is nonzero, the $postscript_mode is assumed
2165 and the postscript file is always generated, even if it is newer
2166 than the dvi file.
2167
2168 $banner_intensity [0.95]
2169 Equivalent to the -bi option, this is a decimal number between 0
2170 and 1 that specifies how dark to print the banner message. 0 is
2171 black, 1 is white. The default is just right if your toner car‐
2172 tridge isn't running too low.
2173
2174 $banner_message ["DRAFT"]
2175 The banner message to print across each page when converting the
2176 dvi file to postscript. This is equivalent to the -bm option.
2177
2178 $banner_scale [220.0]
2179 A decimal number that specifies how large the banner message
2180 will be printed. Experimentation is necessary to get the right
2181 scale for your message, as a rule of thumb the scale should be
2182 about equal to 1100 divided by the number of characters in the
2183 message. The Default is just right for 5 character messages.
2184 This is equivalent to the -bs option.
2185
2186 @BIBINPUTS
2187 This is an array variable, now mostly obsolete, that specifies
2188 directories where latexmk should look for .bib files. By de‐
2189 fault it is set from the BIBINPUTS environment variable of the
2190 operating system. If that environment variable is not set, a
2191 single element list consisting of the current directory is set.
2192 The format of the directory names depends on your operating sys‐
2193 tem, of course. Examples for setting this variable are:
2194
2195 @BIBINPUTS = ( ".", "C:\\bibfiles" );
2196 @BIBINPUTS = ( ".", "\\server\bibfiles" );
2197 @BIBINPUTS = ( ".", "C:/bibfiles" );
2198 @BIBINPUTS = ( ".", "//server/bibfiles" );
2199 @BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" );
2200
2201 Note that under MS Windows, either a forward slash "/" or a
2202 backward slash "\" can be used to separate pathname components,
2203 so the first two and the second two examples are equivalent.
2204 Each backward slash should be doubled to avoid running afoul of
2205 Perl's rules for writing strings. Generally, it is simplest al‐
2206 ways to use forward slashes instead of backward slashes.
2207
2208 Important note: This variable is now mostly obsolete in the cur‐
2209 rent version of latexmk, since it now uses a better method of
2210 searching for files using the kpsewhich command. However, if
2211 your system is an unusual one without the kpsewhich command, you
2212 may need to set the variable @BIBINPUTS.
2213
2214
2215 $biber ["biber %O %S"]
2216 The biber processing program.
2217
2218
2219 $biber_silent_switch ["--onlylog"]
2220 Switch(es) for the biber processing program when silent mode is
2221 on.
2222
2223 $bibtex ["bibtex %O %S"]
2224 The BibTeX processing program.
2225
2226 $bibtex_fudge [1]
2227 When using bibtex, whether to change directory to $aux_dir be‐
2228 fore running bibtex.
2229
2230 The need arises as follows:
2231
2232 a. With bibtex before about 2019, if the filename given to it
2233 contains a path component, there was a bug that bibtex would not
2234 find extra aux files, as produced by the \include command in
2235 TeX.
2236
2237 b. With all moderately recent versions of bibtex, bibtex may
2238 refuse to write its bbl and blg files, for security reasons, for
2239 certain cases of the path component of the filename given to it.
2240
2241 However, there are also rare cases where the change-directory
2242 method prevents bibtex from finding certain bib or bst files.
2243 Then $bibtex_fudge needs to be set to 0.
2244
2245
2246 $bibtex_silent_switch ["-terse"]
2247 Switch(es) for the BibTeX processing program when silent mode is
2248 on.
2249
2250
2251 $bibtex_use [1]
2252 Under what conditions to run bibtex or biber. When latexmk dis‐
2253 covers from the log file that one (or more) bibtex/biber-gener‐
2254 ated bibliographies are used, it can run bibtex or biber when‐
2255 ever it appears necessary to regenerate the bbl file(s) from
2256 their source bib database file(s). But sometimes, the bib
2257 file(s) are not available (e.g., for a document obtained from an
2258 external archive), but the bbl files are provided. In that case
2259 use of bibtex or biber will result in incorrect overwriting of
2260 the precious bbl files. The variable $bibtex_use controls
2261 whether this happens, and also controls whether or not .bbl
2262 files are deleted in a cleanup operation.
2263
2264 The possible values of $bibtex_use are:
2265 0: never use bibtex or biber; never delete .bbl files in a
2266 cleanup.
2267 1: only use bibtex if the bib file(s) exist; never delete .bbl
2268 files in a cleanup.
2269 1.5: only use bibtex if the bib files exist; conditionally
2270 delete .bbl files in a cleanup (i.e., delete them only when the
2271 bib files all exist).
2272 2: run bibtex or biber whenever it appears necessary to update
2273 the bbl file(s), without testing for the existence of the bib
2274 files; always delete .bbl files in a cleanup.
2275
2276
2277 $cleanup_includes_cusdep_generated [0]
2278 If nonzero, specifies that cleanup also deletes files that are
2279 generated by custom dependencies. (When doing a clean up, e.g.,
2280 by use of the -C option, custom dependencies are those listed in
2281 the .fdb_latexmk file from a previous run.)
2282
2283
2284 $cleanup_includes_generated [0]
2285 If nonzero, specifies that cleanup also deletes files that are
2286 detected in the fls file (or failing that, in log file) as being
2287 generated. It will also include files made from these first
2288 generation generated files.
2289
2290 This operation is somewhat dangerous, and can have unintended
2291 consequences, since the files to be deleted are determined from
2292 a file created by *latex, which can contain erroneous informa‐
2293 tion. Therefore this variable is turned off by default, and then
2294 files to be deleted are restricted to those explicitly specified
2295 by patterns configured in the variables clean_ext,
2296 clean_full_ext, and @generated_exts. Standard cases (e.g., .log
2297 files) appear in latexmk's initial value for the array @gener‐
2298 ated_exts.
2299
2300 $cleanup_mode [0]
2301 If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for
2302 cleanup except for .dvi, .ps and .pdf files, 3 for cleanup ex‐
2303 cept for dep and aux files. (There is also extra cleaning as
2304 specified by the $clean_ext, $clean_full_ext and @generated_exts
2305 variables.)
2306
2307 This variable is equivalent to specifying one of the -c or -C
2308 options. But there should be no need to set this variable from
2309 an RC file.
2310
2311 $clean_ext [""]
2312 Extra extensions of files for latexmk to remove when any of the
2313 clean-up options (-c or -C) is selected. The value of this
2314 variable is a string containing the extensions separated by spa‐
2315 ces.
2316
2317 It is also possible to specify a more general pattern of file to
2318 be deleted, by using the place holder %R, as in commands, and it
2319 is also possible to use wildcards. Thus setting
2320
2321 $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-
2322 files-%R/*";
2323
2324 in an initialization file will imply that when a clean-up opera‐
2325 tion is specified, not only is the standard set of files
2326 deleted, but also files of the form FOO.out, FOO-blx.bib, FOO-
2327 figures*.log, and pythontex-files-FOO/*, where FOO stands for
2328 the basename of the file being processed (as in FOO.tex).
2329
2330 Most of the files to be deleted are relative to the directory
2331 specified by $aux_dir. Note that if $out_dir but not $aux_dir
2332 is set, then in its initialization, latexmk sets $aux_dir equal
2333 to $out_dir. A normal situation is therefore that $aux_dir
2334 equals $out_dir, which is the only case directly supported by
2335 TeXLive, unlike MiKTeX. Note that even with TeXLive latexmk
2336 does now support different values for the directories -- see the
2337 explanation of the $emulate_aux variable.
2338
2339 If $out_dir and $aux_dir different, latexmk actually deletes any
2340 files of the specified names in both $aux_dir and $out_dir; this
2341 is because under certain error conditions, the files may be put
2342 in $out_dir instead of $aux_dir. This also handles the case of
2343 deleting any fls file, since that file is in $out_dir.
2344
2345 The filenames specified for a clean-up operation can refer not
2346 only to regular files but also to directories. Directories are
2347 only deleted if they are empty. An example of an application is
2348 to pythontex, which creates files in a particular directory.
2349 You can arrange to remove both the files and the directory by
2350 setting
2351
2352 $clean_ext = "pythontex-files-%R/* pythontex-files-%R";
2353
2354 See also the (array) variable @generated_exts. In the past,
2355 this variable had certain uses beyond that of $clean_ext. But
2356 now, they accomplish the same things. In fact, after initial‐
2357 ization including the processing of command line options, la‐
2358 texmk simply appends the list of extensions in $clean_ext to the
2359 array @generated_exts.
2360
2361 $clean_full_ext [""]
2362 Extra extensions of files for latexmk to remove when the -C op‐
2363 tion is selected, i.e., extensions of files to remove when the
2364 .dvi, etc files are to be cleaned-up.
2365
2366 More general patterns are allowed, as for $clean_ext.
2367
2368 The files specified by $clean_full_ext to be deleted are rela‐
2369 tive to the directory specified by $out_dir.
2370
2371
2372 $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
2373 [""]
2374
2375 These variables specify commands that are executed at certain
2376 points of compilations. One motivation for their existence is
2377 to allow very useful convenient visual indications of compila‐
2378 tion status even when the window receiving the screen output of
2379 the compilation is hidden. This is particularly useful in pre‐
2380 view-continuous mode.
2381
2382 The commands are executed at the following points: $compil‐
2383 ing_cmd at the start of compilation, $success_cmd at the end of
2384 a completely successful compilation, $failure_cmd at the end of
2385 an unsuccessful compilation, $warning_cmd at the of an otherwise
2386 successful compilation that gives warnings about undefined cita‐
2387 tions or references or about multiply defined references. If any
2388 of above variables is undefined or blank (the default situa‐
2389 tion), then the corresponding command is not executed.
2390
2391 However, when $warning_cmd is not set, then in the case of a
2392 compilation with warnings about references or citations, but
2393 with no other error, one or other of $success_cmd or $fail‐
2394 ure_cmd is used (if it is set) according to the setting of
2395 $warnings_as_errors.
2396
2397 An example of a simple setting of these variables is as follows
2398
2399 $compiling_cmd = "xdotool search --name \"%D\" set_window
2400 --name \"%D compiling\"";
2401 $success_cmd = "xdotool search --name \"%D\" set_window
2402 --name \"%D OK\"";
2403 $warning_cmd = "xdotool search --name \"%D\" ".
2404 "set_window --name \"%D CITE/REF ISSUE\"";
2405 $failure_cmd = "xdotool search --name \"%D\" set_window
2406 --name \"%D FAILURE\"";
2407
2408 These assume that the program xdotool is installed, that the
2409 previewer is using an X-Window system for display, and that the
2410 title of the window contains the name of the displayed file, as
2411 it normally does. When the commands are executed, the place‐
2412 holder string %D is replaced by the name of the destination
2413 file, which is the previewed file. The above commands result in
2414 an appropriate string being appended to the filename in the win‐
2415 dow title: " compiling", " OK", or " FAILURE".
2416
2417 Other placeholders that can be used are %S, %T, and %R, with %S
2418 and %T normally being identical. These can be useful for a com‐
2419 mand changing the title of the edit window. The visual indica‐
2420 tion in a window title can useful, since the user does not have
2421 to keep shifting attention to the (possibly hidden) compilation
2422 window to know the status of the compilation.
2423
2424 More complicated situations can best be handled by defining a
2425 Perl subroutine to invoke the necessary commands, and using the
2426 "internal" keyword in the definitions to get the subroutine to
2427 be invoked. (See the section "Format of Command Specifications"
2428 for how to do this.)
2429
2430 Naturally, the above settings that invoke the xdotool program
2431 are only applicable when the X-Window system is used for the
2432 relevant window(s). For other cases, you will have to find what
2433 software solutions are available.
2434
2435
2436 @cus_dep_list [()]
2437 Custom dependency list -- see section on "Custom Dependencies".
2438
2439 @default_excluded_files [()]
2440 When latexmk is invoked with no files specified on the command
2441 line, then, by default, it will process all files in the current
2442 directory with the extension .tex. (In general, it will process
2443 the files specified in the @default_files variable.)
2444
2445 But sometimes you want to exclude particular files from this de‐
2446 fault list. In that case you can specify the excluded files in
2447 the array @default_excluded_files. For example if you wanted to
2448 process all .tex files with the exception of common.tex, which
2449 is a not a standard alone LaTeX file but a file input by some or
2450 all of the others, you could do
2451
2452 @default_files = ("*.tex");
2453
2454 @default_excluded_files = ("common.tex");
2455
2456 If you have a variable or large number of files to be processed,
2457 this method saves you from having to list them in detail in @de‐
2458 fault_files and having to update the list every time you change
2459 the set of files to be processed.
2460
2461 Notes: 1. This variable has no effect except when no files are
2462 specified on the latexmk command line. 2. Wildcards are allowed
2463 in @default_excluded_files.
2464
2465 @default_files [("*.tex")]
2466 Default list of files to be processed.
2467
2468 If no filenames are specified on the command line, latexmk pro‐
2469 cesses all tex files specified in the @default_files variable,
2470 which by default is set to all tex files ("*.tex") in the cur‐
2471 rent directory. This is a convenience: just run latexmk and it
2472 will process an appropriate set of files. But sometimes you
2473 want only some of these files to be processed. In this case you
2474 can list the files to be processed by setting @default_files in
2475 an initialization file (e.g., the file "latexmkrc" in the cur‐
2476 rent directory). Then if no files are specified on the command
2477 line then the files you specify by setting @default_files are
2478 processed.
2479
2480 Three examples:
2481
2482 @default_files = ("paper_current");
2483
2484 @default_files = ("paper1", "paper2.tex");
2485
2486 @default_files = ("*.tex", "*.dtx");
2487
2488 Note that more than file may be given, and that the default ex‐
2489 tension is ".tex". Wild cards are allowed. The parentheses are
2490 because @default_files is an array variable, i.e., a sequence of
2491 filename specifications is possible.
2492
2493 If you want latexmk to process all .tex files with a few excep‐
2494 tions, see the @default_excluded_files array variable.
2495
2496 $dependents_phony [0]
2497 If a list of dependencies is output, this variable determines
2498 whether to include a phony target for each source file. If you
2499 use the dependents list in a Makefile, the dummy rules work
2500 around errors make gives if you remove header files without up‐
2501 dating the Makefile to match.
2502
2503 $dependents_list [0]
2504 Whether to display a list(s) of dependencies at the end of a
2505 run.
2506
2507
2508 $deps_escape ["none"]
2509 This variable determines which kind of escaping of space charac‐
2510 ters to use in dependency lists. The possible values are "none",
2511 "unix", "nmake", corresponding respectively to no escaping, es‐
2512 caping with a "\" suitable for standard Unix make, and escaping
2513 with "^", suitable for Microsoft's nmake.
2514
2515 Currently the only character escaped is a space, since that is
2516 particularly common in file names and directory names. There
2517 are other characters that would need escaping if a dependency
2518 list is to be used as-is by a make program; but those characters
2519 (e.g., "$") commonly cause difficulties when used for .tex docu‐
2520 ments. Moreover, the detailed rules for which characters need
2521 to be escaped depends on the version of make.
2522
2523
2524 $deps_file ["-"]
2525 Name of file to receive list(s) of dependencies at the end of a
2526 run, to be used if $dependents_list is set. If the filename is
2527 "-", then the dependency list is set to stdout (i.e., normally
2528 the screen).
2529
2530
2531 $do_cd [0]
2532 Whether to change working directory to the directory specified
2533 for the main source file before processing it. The default be‐
2534 havior is not to do this, which is the same as the behavior of
2535 *latex programs. This variable is set by the -cd and -cd- op‐
2536 tions on latexmk's command line.
2537
2538 $dvi_filter [empty]
2539 The dvi file filter to be run on the newly produced dvi file be‐
2540 fore other processing. Equivalent to specifying the -dF option.
2541
2542
2543 $dvilualatex ["dvilualatex %O %S"]
2544 Specifies the command line to invoke the dvilualatex program.
2545 Note that as with other programs, you can use this variable not
2546 just to change the name of the program used, but also specify
2547 options to the program. E.g.,
2548
2549 $dvilualatex = "dvilualatex --src-specials
2550 %O %S";
2551
2552 To do a coordinated setting of all of $dvilualatex, $latex,
2553 $pdflatex, $lualatex, and $xelatex, see the section "Advanced
2554 Configuration".
2555
2556
2557 $dvi_mode [See below for default]
2558 If one, generate a dvi version of the document by use of latex.
2559 Equivalent to the -dvi option.
2560
2561 If 2, generate a dvi version of the document by use of dviluala‐
2562 tex. Equivalent to the -dvilua option.
2563
2564 The variable $dvi_mode defaults to 0, but if no explicit re‐
2565 quests are made for other types of file (postscript, pdf), then
2566 $dvi_mode will be set to 1. In addition, if a request for a
2567 file for which a .dvi file is a prerequisite and $dvi_mode is
2568 zero, then $dvi_mode is set to 1.
2569
2570
2571
2572 $dvilualatex_silent_switch ["-interaction=batchmode"]
2573 Switch(es) for the dvilualatex program (specified in the vari‐
2574 able $dvilualatex) when silent mode is on.
2575
2576 See details of the $latex_silent_switch for other information
2577 that equally applies to $dvilualatex_silent_switch.
2578
2579
2580 $dvi_previewer ["start xdvi %O %S" under UNIX]
2581 The command to invoke a dvi-previewer. [Under MS-Windows the
2582 default is "start"; then latexmk arranges to use the MS-Windows
2583 start program, which will cause to be run whatever command the
2584 system has associated with .dvi files.]
2585
2586 Important note: Normally you will want to have a previewer run
2587 detached, so that latexmk doesn't wait for the previewer to ter‐
2588 minate before continuing its work. So normally you should pre‐
2589 fix the command by "start ", which flags to latexmk that it
2590 should do the detaching of the previewer itself (by whatever
2591 method is appropriate to the operating system). But sometimes
2592 letting latexmk do the detaching is not appropriate (for a vari‐
2593 ety of non-trivial reasons), so you should put the "start " bit
2594 in yourself, whenever it is needed.
2595
2596 $dvi_previewer_landscape ["start xdvi %O %S"]
2597 The command to invoke a dvi-previewer in landscape mode. [Under
2598 MS-Windows the default is "start"; then latexmk arranges to use
2599 the MS-Windows start program, which will cause to be run what‐
2600 ever command the system has associated with .dvi files.]
2601
2602 $dvipdf ["dvipdf -dALLOWPSTRANSPARENCY %O %S %D"]
2603 Command to convert .dvi to .pdf file. A common reconfiguration
2604 is to use the dvipdfm command, which needs its arguments in a
2605 different order:
2606
2607 $dvipdf = "dvipdfm %O -o %D %S";
2608
2609 WARNING: The default dvipdf script generates pdf files with
2610 bitmapped fonts, which do not look good when viewed by acroread.
2611 That script should be modified to give dvips the options "-P
2612 pdf" to ensure that type 1 fonts are used in the pdf file.
2613
2614 $dvipdf_silent_switch ["-q"]
2615 Switch(es) for dvipdf program when silent mode is on.
2616
2617 N.B. The standard dvipdf program runs silently, so adding the
2618 silent switch has no effect, but is actually innocuous. But if
2619 an alternative program is used, e.g., dvipdfmx, then the silent
2620 switch has an effect. The default setting is correct for
2621 dvipdfm and dvipdfmx.
2622
2623 $dvips ["dvips %O -o %D %S"]
2624 The program to used as a filter to convert a .dvi file to a .ps
2625 file. If pdf is going to be generated from pdf, then the value
2626 of the $dvips_pdf_switch variable -- see below -- will be in‐
2627 cluded in the options substituted for "%O".
2628
2629 $dvips_landscape ["dvips -tlandscape %O -o %D %S"]
2630 The program to used as a filter to convert a .dvi file to a .ps
2631 file in landscape mode.
2632
2633 $dvips_pdf_switch ["-P pdf"]
2634 Switch(es) for dvips program when pdf file is to be generated
2635 from .ps file.
2636
2637 $dvips_silent_switch ["-q"]
2638 Switch(es) for dvips program when silent mode is on.
2639
2640 $dvi_update_command [""]
2641 When the dvi previewer is set to be updated by running a com‐
2642 mand, this is the command that is run. See the information for
2643 the variable $dvi_update_method for further information, and see
2644 information on the variable $pdf_update_method for an example
2645 for the analogous case of a pdf previewer.
2646
2647 $dvi_update_method [2 under UNIX, 1 under MS-Windows]
2648 How the dvi viewer updates its display when the dvi file has
2649 changed. The values here apply equally to the $pdf_up‐
2650 date_method and to the $ps_update_method variables.
2651 0 => update is automatic,
2652 1=> manual update by user, which may only mean a mouse click
2653 on the viewer's window or may mean a more serious action.
2654 2 => Send the signal, whose number is in the variable
2655 $dvi_update_signal. The default value under UNIX is suitable
2656 for xdvi.
2657 3 => Viewer cannot do an update, because it locks the file.
2658 (As with acroread under MS-Windows.)
2659 4 => run a command to do the update. The command is speci‐
2660 fied by the variable $dvi_update_command.
2661
2662 See information on the variable $pdf_update_method for an exam‐
2663 ple of updating by command.
2664
2665 $dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent
2666 value]
2667 The number of the signal that is sent to the dvi viewer when it
2668 is updated by sending a signal -- see the information on the
2669 variable $dvi_update_method. The default value is the one ap‐
2670 propriate for xdvi on a UNIX system.
2671
2672 $emulate_aux [0]
2673 Whether to emulate the use of aux directory when $aux_dir and
2674 $out_dir are different, rather than using the -aux-directory op‐
2675 tion for the *latex programs. (MiKTeX supports -aux-directory,
2676 but TeXLive doesn't.)
2677
2678 If you use a version of *latex that doesn't support -aux-direc‐
2679 tory, e.g., TeXLive, latexmk will automatically switch aux_dir
2680 emulation on after the first run of *latex, because it will find
2681 the .log file in the wrong place. But it is better to set $emu‐
2682 late_aux to 1 in an rc file, or equivalently to use the -emu‐
2683 late-aux-dir option. This emulation mode works equally well with
2684 MiKTeX.
2685
2686 Aux directory emulation means that when *latex is invoked, the
2687 output directory provided to *latex is set to be the desired aux
2688 directory. After that, any files that need to be in the output
2689 directory will be moved there by latexmk. (These are the files
2690 with extensions .dvi, .ps, .pdf, .synctex, .synctex.gz, and, de‐
2691 pending on the setting of the $fls_uses_out_dir variable, also
2692 the .fls file.)
2693
2694
2695 $failure_cmd [undefined]
2696 See the documentation for $compiling_cmd.
2697
2698
2699 $fdb_ext ["fdb_latexmk"]
2700 The extension of the file which latexmk generates to contain a
2701 database of information on source files. You will not normally
2702 need to change this.
2703
2704
2705 @file_not_found
2706 This an array of Perl regular expressions that are patterns to
2707 find messages in the .log file from a run of *latex that indi‐
2708 cate that a file was looked for and not found. To see the cur‐
2709 rent default set, you should look at the definition of
2710 @file_not_found in the latexmk.pl file.
2711
2712 In the regular expression, the string for the name of the miss‐
2713 ing file should be enclosed in parentheses. That carries the
2714 implication that after latexmk gets a succesful match to the
2715 pattern, the variable $1 is set to the filename, which is then
2716 picked up by latexmk.
2717
2718 If you happen to encounter a package that gives a missing file
2719 message of a different form than one that matches one of the
2720 built-in patterns, you can add another pattern to the array. An
2721 example would be
2722
2723 push @file_not_found, '^No file\\s+(.+)\\s*$';
2724
2725 The regular expression itself is
2726
2727 ^Missing file\s+(.+)\s*$
2728
2729 But the corresponding string specification in the push statement
2730 has to have the backslashes doubled.
2731
2732 This regular expression matches a line that starts with 'No
2733 file', then has one or more white space characters, then any
2734 number of characters forming the filename, then possible white
2735 space, and finally the end of the line. (See documentation on
2736 Perl regular expressions for details.)
2737
2738
2739 $fls_uses_out_dir [0]
2740 This variable determines whether or not the .fls file should be
2741 in the output directory instead of the natural directory, which
2742 is the aux directory. If the variable is nonzero, the .fls file
2743 is to be in the output directory. See the section AUXILIARY AND
2744 OUTPUT DIRECTORIES for more details about these directories.
2745 The rationale for the existence of the variable
2746 $fls_uses_aux_dir is explained there.
2747
2748 In all cases, if latexmk finds that an .fls file has been gener‐
2749 ated in the opposite directory to the one specified by
2750 $fls_uses_out_dir, it copies the file to the other directory
2751 (aux or output directory as appropriate). The file is copied
2752 rather than simply moved, to avoid potential clashes with other
2753 software that assumes the .fls file is generated in the direc‐
2754 tory it was written to by *latex. Thus the effect an incorrect
2755 setting of $fls_uses_out_dir is only to cause a superfluous copy
2756 of the .fls file to be generated.
2757
2758
2759 $force_mode [0]
2760 If nonzero, continue processing past minor latex errors includ‐
2761 ing unrecognized cross references. Equivalent to specifying the
2762 -f option.
2763
2764
2765 @generated_exts [( 'aux', 'bcf', 'fls', 'idx', 'ind', 'lof', 'lot',
2766 'out', 'toc', 'blg', 'ilg', 'log', 'xdv' )]
2767
2768 This contains a list of extensions for files that are generated
2769 during processing, and that should be deleted during a main
2770 clean up operation, as invoked by the command line option -c.
2771 (The use of -C or -gg gives this clean up and more.)
2772
2773 The default values are extensions for standard files generated
2774 by *latex, bibtex, and the like. (Note that the clean up also
2775 deletes the fdb_latexmk file, but that's separately coded into
2776 latexmk, currently.)
2777
2778 After initialization of latexmk and the processing of its com‐
2779 mand line, the items in clean_ext are appended to @gener‐
2780 ated_exts. So these two variables have the same meaning (con‐
2781 trary to older versions of latexmk).
2782
2783 The items in @generated_exts are normally extensions of files,
2784 whose base name is the same as the main tex file. But it is
2785 also possible to specify patterns including that basename ---
2786 see the explanation of the variable $clean_ext.
2787
2788 In addition to specifying files to be deleted in a clean up, la‐
2789 texmk uses the same specification to assist its examination of
2790 changes in source files: Under some situations it needs to find
2791 those changes in files (since a previous run) that are expected
2792 to be due to the user editing a file. This contrasts with the
2793 cases of files that are generated by some program run by latexmk
2794 and that differ from the results of the previous run. This use
2795 of @generated_exts is normally unimportant, given the usual ac‐
2796 curacy of latexmk's other ways of determining these generated
2797 files.
2798
2799 A convenient way to add an extra extension to the list, without
2800 losing the already defined ones is to use a push command in the
2801 line in an RC file. E.g.,
2802
2803 push @generated_exts, "end";
2804
2805 adds the extension "end" to the list of predefined generated ex‐
2806 tensions. (This extension is used by the RevTeX package, for
2807 example.)
2808
2809
2810 $go_mode [0]
2811 If nonzero, process files regardless of timestamps, and is then
2812 equivalent to the -g option.
2813
2814 %hash_calc_ignore_pattern
2815 !!!This variable is for experts only!!!
2816
2817 The general rule latexmk uses for determining when an extra run
2818 of some program is needed is that one of the source files has
2819 changed. But consider for example a latex package that causes
2820 an encapsulated postscript file (an "eps" file) to be made that
2821 is to be read in on the next run. The file contains a comment
2822 line giving its creation date and time. On the next run the
2823 time changes, latex sees that the eps file has changed, and
2824 therefore reruns latex. This causes an infinite loop, that is
2825 only terminated because latexmk has a limit on the number of
2826 runs to guard against pathological situations.
2827
2828 But the changing line has no real effect, since it is a comment.
2829 You can instruct latex to ignore the offending line as follows:
2830
2831 $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
2832
2833 This creates a rule for files with extension .eps about lines to
2834 ignore. The left-hand side is a Perl idiom for setting an item
2835 in a hash. Note that the file extension is specified without a
2836 period. The value, on the right-hand side, is a string contain‐
2837 ing a regular expression. (See documentation on Perl for how
2838 they are to be specified in general.) This particular regular
2839 expression specifies that lines beginning with "%%CreationDate:
2840 " are to be ignored in deciding whether a file of the given ex‐
2841 tension .eps has changed.
2842
2843 There is only one regular expression available for each exten‐
2844 sion. If you need more one pattern to specify lines to ignore,
2845 then you need to combine the patterns into a single regular ex‐
2846 pression. The simplest method is separate the different simple
2847 patterns by a vertical bar character (indicating "alternation"
2848 in the jargon of regular expressions). For example,
2849
2850 $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Ti‐
2851 tle: ';
2852
2853 causes lines starting with either "^%%CreationDate: " or "^%%Ti‐
2854 tle: " to be ignored.
2855
2856 It may happen that a pattern to be ignored is specified in, for
2857 example, in a system or user initialization file, and you wish
2858 to remove this in a file that is read later. To do this, you
2859 use Perl's delete function, e.g.,
2860
2861 delete $hash_calc_ignore_pattern{'eps'};
2862
2863
2864 $jobname [""]
2865
2866 This specifies the jobname, i.e., the basename that is used for
2867 generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
2868 variable is a null string, then the basename is the basename of
2869 the main tex file. (At present, the string in $jobname should
2870 not contain spaces.)
2871
2872 The placeholder '%A' is permitted. This will be substituted by
2873 the basename of the TeX file. The primary purpose is when a va‐
2874 riety of tex files are to be processed, and you want to use a
2875 different jobname for each but one that is distinct for each.
2876 Thus if you wanted to compare compilations of a set of files on
2877 different operating systems, with distinct filenames for all the
2878 cases, you could set
2879
2880 $jobname = "%A-$^O";
2881
2882 in an initialization file. (Here $^O is a variable provided by
2883 perl that contains perl's name for the operating system.)
2884
2885 Suppose you had .tex files test1.tex and test2.tex. Then when
2886 you run
2887
2888 latexmk -pdf *.tex
2889
2890 both files will be compiled. The .aux, .log, and .pdf files
2891 will have basenames test1-MSWin32 ante test2-MSWin32 on a MS-
2892 Windows system, test1-darwin and test2-darwin on an OS-X system,
2893 and a variety of similar cases on linux systems.
2894
2895
2896 $kpsewhich ["kpsewhich %S"]
2897 The program called to locate a source file when the name alone
2898 is not sufficient. Most filenames used by latexmk have suffi‐
2899 cient path information to be found directly. But sometimes, no‐
2900 tably when a .bib or a .bst file is found from the log file of a
2901 bibtex or biber run, only the base name of the file is known,
2902 but not its path. The program specified by $kpsewhich is used to
2903 find it.
2904
2905 (For advanced users: Because of the different way in which la‐
2906 texmk uses the command specified in $kpsewhich, some of the pos‐
2907 sibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do not
2908 apply. The internal and start keywords are not available. A
2909 simple command specification with possible options and then "%S"
2910 is all that is guaranteed to work. Note that for other com‐
2911 mands, "%S" is substituted by a single source file. In contrast,
2912 for $kpsewhich, "%S" may be substituted by a long list of space-
2913 separated filenames, each of which is quoted. The result on
2914 STDOUT of running the command is then piped to latexmk.)
2915
2916 See also the @BIBINPUTS variable for another way that latexmk
2917 also uses to try to locate files; it applies only in the case of
2918 .bib files.
2919
2920 $kpsewhich_show [0]
2921 Whether to show diagnostics about invocations of kpsewhich: the
2922 command line use to invoke it and the results. These diagnos‐
2923 tics are shown if $kpsewhich_show is non-zero or if diagnostics
2924 mode is on. (But in the second case, lots of other diagnostics
2925 are also shown.) Without these diagnostics there is nothing
2926 visible in latexmk's screen output about invocations of kpse‐
2927 which.
2928
2929 $landscape_mode [0]
2930 If nonzero, run in landscape mode, using the landscape mode pre‐
2931 viewers and dvi to postscript converters. Equivalent to the -l
2932 option. Normally not needed with current previewers.
2933
2934 $latex ["latex %O %S"]
2935 Specifies the command line for the LaTeX processing program.
2936 Note that as with other programs, you can use this variable not
2937 just to change the name of the program used, but also specify
2938 options to the program. E.g.,
2939
2940 $latex = "latex --src-specials %O %S";
2941
2942 To do a coordinated setting of all of $dvilualatex, $latex,
2943 $pdflatex, $lualatex, and $xelatex, see the section "Advanced
2944 Configuration".
2945
2946
2947 %latex_input_extensions
2948 This variable specifies the extensions tried by latexmk when it
2949 finds that a LaTeX run resulted in an error that a file has not
2950 been found, and the file is given without an extension. This
2951 typically happens when LaTeX commands of the form \input{file}
2952 or \includegraphics{figure}, when the relevant source file does
2953 not exist.
2954
2955 In this situation, latexmk searches for custom dependencies to
2956 make the missing file(s), but restricts it to the extensions
2957 specified by the variable %latex_input_extensions. The default
2958 extensions are 'tex' and 'eps'.
2959
2960 (For Perl experts: %latex_input_extensions is a hash whose keys
2961 are the extensions. The values are irrelevant.) Two subrou‐
2962 tines are provided for manipulating this and the related vari‐
2963 able %pdflatex_input_extensions, add_input_ext and remove_in‐
2964 put_ext. They are used as in the following examples are possi‐
2965 ble lines in an initialization file:
2966
2967 remove_input_ext( 'latex', 'tex' );
2968
2969 removes the extension 'tex' from latex_input_extensions
2970
2971 add_input_ext( 'latex', 'asdf' );
2972
2973 add the extension 'asdf to latex_input_extensions. (Naturally
2974 with such an extension, you should have made an appropriate cus‐
2975 tom dependency for latexmk, and should also have done the appro‐
2976 priate programming in the LaTeX source file to enable the file
2977 to be read. The standard extensions are handled by LaTeX and
2978 its graphics/graphicx packages.)
2979
2980 $latex_silent_switch ["-interaction=batchmode"]
2981 Switch(es) for the LaTeX processing program when silent mode is
2982 on.
2983
2984 If you use MikTeX, you may prefer the results if you configure
2985 the options to include -c-style-errors, e.g., by the following
2986 line in an initialization file
2987
2988 $latex_silent_switch = "-interaction=batchmode -c-style-er‐
2989 rors";
2990
2991
2992 $lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
2993 The command to print postscript files.
2994
2995 Under MS-Windows (unlike UNIX/Linux), there is no standard pro‐
2996 gram for printing files. But there are ways you can do it. For
2997 example, if you have gsview installed, you could use it with the
2998 option "/p":
2999
3000 $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
3001
3002 If gsview is installed in a different directory, you will need
3003 to make the appropriate change. Note the combination of single
3004 and double quotes around the name. The single quotes specify
3005 that this is a string to be assigned to the configuration vari‐
3006 able $lpr. The double quotes are part of the string passed to
3007 the operating system to get the command obeyed; this is neces‐
3008 sary because one part of the command name ("Program Files") con‐
3009 tains a space which would otherwise be misinterpreted.
3010
3011 $lpr_dvi ["NONE lpr_dvi"]
3012 The printing program to print dvi files.
3013
3014 $lpr_pdf ["NONE lpr_pdf"]
3015 The printing program to print pdf files.
3016
3017 Under MS-Windows you could set this to use gsview, if it is in‐
3018 stalled, e.g.,
3019
3020 $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
3021
3022 If gsview is installed in a different directory, you will need
3023 to make the appropriate change. Note the double quotes around
3024 the name: this is necessary because one part of the command name
3025 ("Program Files") contains a space which would otherwise be mis‐
3026 interpreted.
3027
3028 $lualatex ["lualatex %O %S"]
3029 Specifies the command line for the LaTeX processing program that
3030 is to be used when the lualatex program is called for (e.g., by
3031 the option -lualatex.
3032
3033 To do a coordinated setting of all of $dvilualatex, $latex,
3034 $pdflatex, $lualatex, and $xelatex, see the section "Advanced
3035 Configuration".
3036
3037
3038 %lualatex_input_extensions
3039 This variable specifies the extensions tried by latexmk when it
3040 finds that a lualatex run resulted in an error that a file has
3041 not been found, and the file is given without an extension.
3042 This typically happens when LaTeX commands of the form \in‐
3043 put{file} or \includegraphics{figure}, when the relevant source
3044 file does not exist.
3045
3046 In this situation, latexmk searches for custom dependencies to
3047 make the missing file(s), but restricts it to the extensions
3048 specified by the variable %pdflatex_input_extensions. The de‐
3049 fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
3050
3051 See details of the %latex_input_extensions for other information
3052 that equally applies to %lualatex_input_extensions.
3053
3054 $lualatex_silent_switch ["-interaction=batchmode"]
3055 Switch(es) for the lualatex program (specified in the variable
3056 $lualatex) when silent mode is on.
3057
3058 See details of the $latex_silent_switch for other information
3059 that equally applies to $lualatex_silent_switch.
3060
3061 $make ["make"]
3062 The make processing program.
3063
3064 $makeindex ["makeindex %O -o %D %S"]
3065 The index processing program.
3066
3067 $makeindex_fudge [0]
3068 When using makeindex, whether to change directory to $aux_dir
3069 before running makeindex. Set to 1 if $aux_dir is not an ex‐
3070 plicit subdirectory of current directory, otherwise makeindex
3071 will refuse to write its output and log files, for security rea‐
3072 sons.
3073
3074 $makeindex_silent_switch ["-q"]
3075 Switch(es) for the index processing program when silent mode is
3076 on.
3077
3078 $max_repeat [5]
3079 The maximum number of times latexmk will run *latex before de‐
3080 ciding that there may be an infinite loop and that it needs to
3081 bail out, rather than rerunning *latex again to resolve cross-
3082 references, etc. The default value covers all normal cases.
3083
3084 (Note that the "etc" covers a lot of cases where one run of *la‐
3085 tex generates files to be read in on a later run.)
3086
3087 $MSWin_back_slash [1]
3088 This configuration variable only has an effect when latexmk is
3089 running under MS-Windows. With the default value of 1 for this
3090 variable, when a command is executed under MS-Windows, latexmk
3091 substitutes "\" for the separator character between components
3092 of a directory name. Internally, latexmk uses "/" for the di‐
3093 rectory separator character, which is the character used by
3094 Unix-like systems.
3095
3096 For almost all programs and for almost all filenames under MS-
3097 Windows, both "\" and "/" are acceptable as the directory sepa‐
3098 rator character, provided at least that filenames are properly
3099 quoted. But it is possible that programs exist that only accept
3100 "\" on the command line, since that is the standard directory
3101 separator for MS-Windows. So for safety latexmk makes the sub‐
3102 stitution from "/" to "\", by default.
3103
3104 However there are also programs on MS-Windows for which a back
3105 slash "\" is interpreted differently than as a directory separa‐
3106 tor; for these the directory separator should be "/". Programs
3107 with this behavior include all the *latex programs in the
3108 TeXLive implementation (but not the MiKTeX implementation).
3109 Hence if you use TeXLive on MS-Windows, then $MSWin_back_slash
3110 should be set to zero.
3111
3112
3113 $new_viewer_always [0]
3114 This variable applies to latexmk only in continuous-preview
3115 mode. If $new_viewer_always is 0, latexmk will check for a pre‐
3116 viously running previewer on the same file, and if one is run‐
3117 ning will not start a new one. If $new_viewer_always is non-
3118 zero, this check will be skipped, and latexmk will behave as if
3119 no viewer is running.
3120
3121 $out_dir [""]
3122 If non-blank, this variable specifies the output directory.
3123
3124 This is the directory in which final output files are written
3125 (dvi, ps, pdf, synctex, synctex.gz). In addition, if the aux
3126 directory equals the output directory, as is the case by de‐
3127 fault, then other generated files are in effect written to the
3128 output directory.
3129
3130 If $out_dir is blank, the output directory is the current direc‐
3131 tory at the invocation of *latex; this is equivalent to setting
3132 $out_dir to '.'.
3133
3134 See the section AUXILIARY AND OUTPUT DIRECTORIES for more de‐
3135 tails.
3136
3137
3138
3139 $pdf_mode [0]
3140 If zero, do NOT generate a pdf version of the document. If
3141 equal to 1, generate a pdf version of the document using pdfla‐
3142 tex, using the command specified by the $pdflatex variable. If
3143 equal to 2, generate a pdf version of the document from the ps
3144 file, by using the command specified by the $ps2pdf variable.
3145 If equal to 3, generate a pdf version of the document from the
3146 dvi file, by using the command specified by the $dvipdf vari‐
3147 able. If equal to 4, generate a pdf version of the document us‐
3148 ing lualatex, using the command specified by the $lualatex vari‐
3149 able. If equal to 5, generate a pdf version (and an xdv ver‐
3150 sion) of the document using xelatex, using the commands speci‐
3151 fied by the $xelatex and xdvipdfmx variables.
3152
3153 In $pdf_mode=2, it is ensured that .dvi and .ps files are also
3154 made. In $pdf_mode=3, it is ensured that a .dvi file is also
3155 made. But this may be overridden by the document.
3156
3157 $pdflatex ["pdflatex %O %S"]
3158 Specifies the command line for the LaTeX processing program in a
3159 version that makes a pdf file instead of a dvi file.
3160
3161 An example use of this variable is to add certain options to the
3162 command line for the program, e.g.,
3163
3164 $pdflatex = "pdflatex --shell-escape %O %S";
3165
3166 (In some earlier versions of latexmk, you needed to use an as‐
3167 signment to $pdflatex to allow the use of lualatex or xelatex
3168 instead of pdflatex. There are now separate configuration vari‐
3169 ables for the use of lualatex or xelatex. See $lualatex and
3170 $xelatex.)
3171
3172 To do a coordinated setting of all of $dvilualatex, $latex,
3173 $pdflatex, $lualatex, and $xelatex, see the section "Advanced
3174 Configuration".
3175
3176
3177 %pdflatex_input_extensions
3178 This variable specifies the extensions tried by latexmk when it
3179 finds that a pdflatex run resulted in an error that a file has
3180 not been found, and the file is given without an extension.
3181 This typically happens when LaTeX commands of the form \in‐
3182 put{file} or \includegraphics{figure}, when the relevant source
3183 file does not exist.
3184
3185 In this situation, latexmk searches for custom dependencies to
3186 make the missing file(s), but restricts it to the extensions
3187 specified by the variable %pdflatex_input_extensions. The de‐
3188 fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
3189
3190 See details of the %latex_input_extensions for other information
3191 that equally applies to %pdflatex_input_extensions.
3192
3193 $pdflatex_silent_switch ["-interaction=batchmode"]
3194 Switch(es) for the pdflatex program (specified in the variable
3195 $pdflatex) when silent mode is on.
3196
3197 See details of the $latex_silent_switch for other information
3198 that equally applies to $pdflatex_silent_switch.
3199
3200 $pdf_previewer ["start acroread %O %S"]
3201 The command to invoke a pdf-previewer.
3202
3203 On MS-Windows, the default is changed to "cmd /c start """; un‐
3204 der more recent versions of Windows, this will cause to be run
3205 whatever command the system has associated with .pdf files. But
3206 this may be undesirable if this association is to acroread --
3207 see the notes in the explanation of the -pvc option.]
3208
3209 On OS-X the default is changed to "open %S", which results in
3210 OS-X starting up (and detaching) the viewer associated with the
3211 file. By default, for pdf files this association is to OS-X's
3212 preview, which is quite satisfactory.
3213
3214 WARNING: Problem under MS-Windows: if acroread is used as the
3215 pdf previewer, and it is actually viewing a pdf file, the pdf
3216 file cannot be updated. Thus makes acroread a bad choice of
3217 previewer if you use latexmk's previous-continuous mode (option
3218 -pvc) under MS-windows. This problem does not occur if, for ex‐
3219 ample, SumatraPDF or gsview is used to view pdf files.
3220
3221 Important note: Normally you will want to have a previewer run
3222 detached, so that latexmk doesn't wait for the previewer to ter‐
3223 minate before continuing its work. So normally you should pre‐
3224 fix the command by "start ", which flags to latexmk that it
3225 should do the detaching of the previewer itself (by whatever
3226 method is appropriate to the operating system). But sometimes
3227 letting latexmk do the detaching is not appropriate (for a vari‐
3228 ety of non-trivial reasons), so you should put the "start " bit
3229 in yourself, whenever it is needed.
3230
3231 $pdf_update_command [""]
3232 When the pdf previewer is set to be updated by running a com‐
3233 mand, this is the command that is run. See the information for
3234 the variable $pdf_update_method.
3235
3236 $pdf_update_method [1 under UNIX, 3 under MS-Windows]
3237 How the pdf viewer updates its display when the pdf file has
3238 changed. See the information on the variable $dvi_update_method
3239 for the codes. (Note that information needs be changed slightly
3240 so that for the value 4, to run a command to do the update, the
3241 command is specified by the variable $pdf_update_command, and
3242 for the value 2, to specify update by signal, the signal is
3243 specified by $pdf_update_signal.)
3244
3245 Note that acroread under MS-Windows (but not UNIX) locks the pdf
3246 file, so the default value is then 3.
3247
3248 Arranging to use a command to get a previewer explicitly updated
3249 requires three variables to be set. For example:
3250
3251 $pdf_previewer = "start xpdf -remote %R %O %S";
3252 $pdf_update_method = 4;
3253 $pdf_update_command = "xpdf -remote %R -reload";
3254
3255 The first setting arranges for the xpdf program to be used in
3256 its "remote server mode", with the server name specified as the
3257 rootname of the TeX file. The second setting arranges for up‐
3258 dating to be done in response to a command, and the third set‐
3259 ting sets the update command.
3260
3261 $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent
3262 value]
3263 The number of the signal that is sent to the pdf viewer when it
3264 is updated by sending a signal -- see the information on the
3265 variable $pdf_update_method. The default value is the one ap‐
3266 propriate for gv on a UNIX system.
3267
3268 $pid_position[1 under UNIX, -1 under MS-Windows]
3269 The variable $pid_position is used to specify which word in
3270 lines of the output from $pscmd corresponds to the process ID.
3271 The first word in the line is numbered 0. The default value of
3272 1 (2nd word in line) is correct for Solaris 2.6, Linux, and OS-X
3273 with their default settings of $pscmd.
3274
3275 Setting the variable to -1 is used to indicate that $pscmd is
3276 not to be used.
3277
3278 $postscript_mode [0]
3279 If nonzero, generate a postscript version of the document.
3280 Equivalent to the -ps option.
3281
3282 If some other request is made for which a postscript file is
3283 needed, then $postscript_mode will be set to 1.
3284
3285 $pre_tex_code ['']
3286
3287 Sets TeX code to be executed before inputting the source file.
3288 This works if the relevant one of $latex, etc contains a suit‐
3289 able command line with a %P or %U substitution. For example you
3290 could do
3291
3292 $latex = 'latex %O %P';
3293 $pre_tex_code = '\AtBeginDocument{An initial message\par}';
3294
3295 To set all of $latex, $pdflatex, $lualatex, and $xelatex you
3296 could use the subroutine alt_tex_cmds:
3297
3298 &alt_tex_cmds;
3299 $pre_tex_code = '\AtBeginDocument{An initial message\par}';
3300
3301
3302
3303 $preview_continuous_mode [0]
3304 If nonzero, run a previewer to view the document, and continue
3305 running latexmk to keep .dvi up-to-date. Equivalent to the -pvc
3306 option. Which previewer is run depends on the other settings,
3307 see the command line options -view=, and the variable $view.
3308
3309 $preview_mode [0]
3310 If nonzero, run a previewer to preview the document. Equivalent
3311 to the -pv option. Which previewer is run depends on the other
3312 settings, see the command line options -view=, and the variable
3313 $view.
3314
3315 $printout_mode [0]
3316 If nonzero, print the document using the command specified in
3317 the $lpr variable. Equivalent to the -p option. This is recom‐
3318 mended not to be set from an RC file, otherwise you could waste
3319 lots of paper.
3320
3321 $print_type = ["auto"]
3322 Type of file to printout: possibilities are "auto", "dvi",
3323 "none", "pdf", or "ps". See the option -print= for the meaning
3324 of the "auto" value.
3325
3326 $pscmd Command used to get all the processes currently run by the user.
3327 The -pvc option uses the command specified by the variable
3328 $pscmd to determine if there is an already running previewer,
3329 and to find the process ID (needed if latexmk needs to signal
3330 the previewer about file changes).
3331
3332 Each line of the output of this command is assumed to correspond
3333 to one process. See the $pid_position variable for how the
3334 process number is determined.
3335
3336 The default for pscmd is "NONE" under MS-Windows and cygwin
3337 (i.e., the command is not used), "ps -ww -u $ENV{USER}" under
3338 OS-X, and "ps -f -u $ENV{USER}" under other operating systems
3339 (including Linux). In these specifications "$ENV{USER}" is sub‐
3340 stituted by the username.
3341
3342 $ps2pdf ["ps2pdf -dALLOWPSTRANSPARENCY %O %S %D"]
3343 Command to convert .ps to .pdf file.
3344
3345 $ps_filter [empty]
3346 The postscript file filter to be run on the newly produced post‐
3347 script file before other processing. Equivalent to specifying
3348 the -pF option.
3349
3350 $ps_previewer ["start gv %O %S", but start %O %S under MS-Windows]
3351 The command to invoke a ps-previewer. (The default under MS-
3352 Windows will cause to be run whatever command the system has as‐
3353 sociated with .ps files.)
3354
3355 Note that gv could be used with the -watch option updates its
3356 display whenever the postscript file changes, whereas ghostview
3357 does not. However, different versions of gv have slightly dif‐
3358 ferent ways of writing this option. You can configure this
3359 variable appropriately.
3360
3361 WARNING: Linux systems may have installed one (or more) versions
3362 of gv under different names, e.g., ggv, kghostview, etc, but
3363 perhaps not one actually called gv.
3364
3365 Important note: Normally you will want to have a previewer run
3366 detached, so that latexmk doesn't wait for the previewer to ter‐
3367 minate before continuing its work. So normally you should pre‐
3368 fix the command by "start ", which flags to latexmk that it
3369 should do the detaching of the previewer itself (by whatever
3370 method is appropriate to the operating system). But sometimes
3371 letting latexmk do the detaching is not appropriate (for a vari‐
3372 ety of non-trivial reasons), so you should put the "start " bit
3373 in yourself, whenever it is needed.
3374
3375
3376 $ps_previewer_landscape ["start gv -swap %O %S", but start %O %S under
3377 MS-Windows]
3378 The command to invoke a ps-previewer in landscape mode.
3379
3380 $ps_update_command [""]
3381 When the postscript previewer is set to be updated by running a
3382 command, this is the command that is run. See the information
3383 for the variable $ps_update_method.
3384
3385 $ps_update_method [0 under UNIX, 1 under MS-Windows]
3386 How the postscript viewer updates its display when the .ps file
3387 has changed. See the information on the variable $dvi_up‐
3388 date_method for the codes. (Note that information needs be
3389 changed slightly so that for the value 4, to run a command to do
3390 the update, the command is specified by the variable $ps_up‐
3391 date_command, and for the value 2, to specify update by signal,
3392 the signal is specified by $ps_update_signal.)
3393
3394 $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent
3395 value]
3396 The number of the signal that is sent to the pdf viewer when it
3397 is updated by sending a signal -- see $ps_update_method. The
3398 default value is the one appropriate for gv on a UNIX system.
3399
3400 $pvc_timeout [0]
3401 If this variable is nonzero, there will be a timeout in pvc
3402 mode after a period of inactivity. Inactivity means a period
3403 when latexmk has detected no file changes and hence has not
3404 taken any actions like compiling the document. The period of in‐
3405 activity is in the variable $pvc_timeout_mins.
3406
3407
3408 $pvc_timeout_mins [30]
3409 The period of inactivity, in minutes, after which pvc mode times
3410 out. This is used if $pvc_timeout is nonzero.
3411
3412 $pvc_view_file_via_temporary [1]
3413 The same as $always_view_file_via_temporary, except that it only
3414 applies in preview-continuous mode (-pvc option).
3415
3416 $quote_filenames [1]
3417 This specifies whether substitutions for placeholders in command
3418 specifications (as in $pdflatex) are surrounded by double
3419 quotes. If this variable is 1 (or any other value Perl regards
3420 as true), then quoting is done. Otherwise quoting is omitted.
3421
3422 The quoting method used by latexmk is tested to work correctly
3423 under UNIX systems (including Linux and Mac OS-X) and under MS-
3424 Windows. It allows the use of filenames containing special
3425 characters, notably spaces. (But note that many versions of
3426 *latex cannot correctly deal with TeX files whose names contain
3427 spaces. Latexmk's quoting only ensures that such filenames are
3428 correctly treated by the operating system in passing arguments
3429 to programs.)
3430
3431 $rc_report [1]
3432 After initialization, whether to give a list of the RC files
3433 read.
3434
3435 $recorder [1]
3436 Whether to use the -recorder option to *latex. Use of this op‐
3437 tion results in a file of extension .fls containing a list of
3438 the files that these programs have read and written. Latexmk
3439 will then use this file to improve its detection of source files
3440 and generated files after a run of *latex.
3441
3442 It is generally recommended to use this option (or to configure
3443 the $recorder variable to be on.) But it only works if *latex
3444 supports the -recorder option, which is true for most current
3445 implementations
3446
3447 Note about the name of the .fls file: Most implementations of
3448 *latex produce an .fls file with the same basename as the main
3449 document's LaTeX, e.g., for Document.tex, the .fls file is Docu‐
3450 ment.fls. However, some implementations instead produce files
3451 named for the program, i.e., latex.fls or pdflatex.fls. In this
3452 second case, latexmk copies the latex.fls or pdflatex.fls to a
3453 file with the basename of the main LaTeX document, e.g., Docu‐
3454 ment.fls.
3455
3456 $search_path_separator [See below for default]
3457 The character separating paths in the environment variables TEX‐
3458 INPUTS, BIBINPUTS, and BSTINPUTS. This variable is mainly used
3459 by latexmk when the -outdir, -output-directory, -auxdir, and/or
3460 -aux-directory options are used. In that case latexmk needs to
3461 communicate appropriately modified search paths to bibtex,
3462 dvipdf, dvips, and *latex.
3463
3464 [Comment to technically savvy readers: *latex doesn't actually
3465 need the modified search path. But, surprisingly, dvipdf and
3466 dvips do, because sometimes graphics files get generated in the
3467 output or aux directories.]
3468
3469 The default under MSWin and Cygwin is ';' and under UNIX-like
3470 operating systems (including Linux and OS-X) is ':'. Normally
3471 the defaults give correct behavior. But there can be difficul‐
3472 ties if your operating system is of one kind, but some of your
3473 software is running under an emulator for the other kind of op‐
3474 erating system; in that case you'll need to find out what is
3475 needed, and set $search_path_separator explicitly. (The same
3476 goes, of course, for unusual operating systems that are not in
3477 the MSWin, Linux, OS-X, Unix collection.)
3478
3479 $show_time [0]
3480 Whether to show time used, both the total and for individual
3481 steps.
3482
3483 Note: On MS Windows, this is clock time. On other OSs it is the
3484 CPU time used (by latexmk and the child processes it invokes).
3485 The OS-dependence is because of a limitation of Windows. If you
3486 wish to force the use of clock instead of CPU time, you can set
3487
3488 $times_are_clock = 1;
3489
3490
3491
3492 $silence_logfile_warnings [0]
3493 Whether after a run of *latex to summarize warnings in the log
3494 file about undefined citations and references. Setting $si‐
3495 lence_logfile_warnings=0 gives the summary of warnings (provided
3496 silent mode isn't also set), and this is useful to locate unde‐
3497 fined citations and references without searching through the
3498 much more verbose log file or the screen output of *latex. But
3499 the summary can also be excessively annoying. The default is
3500 not to give these warnings. The command line options -si‐
3501 lence_logfile_warning_list and -silence_logfile_warning_list-
3502 also set this variable.
3503
3504 Note that multiple occurrences for the same undefined object on
3505 the same page and same line will be compressed to a single warn‐
3506 ing.
3507
3508 $silent [0]
3509 Whether to run silently. Setting $silent to 1 has the same ef‐
3510 fect as the -quiet of -silent options on the command line.
3511
3512 $sleep_time [2]
3513 The time to sleep (in seconds) between checking for source file
3514 changes when running with the -pvc option. This is subject to a
3515 minimum of one second delay, except that zero delay is also al‐
3516 lowed.
3517
3518 A value of exactly 0 gives no delay, and typically results in
3519 100% CPU usage, which may not be desirable.
3520
3521 $texfile_search [""]
3522 This is an obsolete variable, replaced by the @default_files
3523 variable.
3524
3525 For backward compatibility, if you choose to set $tex‐
3526 file_search, it is a string of space-separated filenames, and
3527 then latexmk replaces @default_files with the filenames in $tex‐
3528 file_search to which is added "*.tex".
3529
3530 $success_cmd [undefined]
3531 See the documentation for $compiling_cmd.
3532
3533 $tmpdir [See below for default]
3534 Directory to store temporary files that latexmk may generate
3535 while running.
3536
3537 The default under MSWindows (including cygwin), is to set $tm‐
3538 pdir to the value of the first of whichever of the system envi‐
3539 ronment variables TMPDIR or TEMP exists, otherwise to the cur‐
3540 rent directory. Under other operating systems (expected to be
3541 UNIX/Linux, including OS-X), the default is the value of the
3542 system environment variable TMPDIR if it exists, otherwise
3543 "/tmp".
3544
3545 $use_make_for_missing_files [0]
3546 Whether to use make to try and make files that are missing after
3547 a run of *latex, and for which a custom dependency has not been
3548 found. This is generally useful only when latexmk is used as
3549 part of a bigger project which is built by using the make pro‐
3550 gram.
3551
3552 Note that once a missing file has been made, no further calls to
3553 make will be made on a subsequent run of latexmk to update the
3554 file. Handling this problem is the job of a suitably defined
3555 Makefile. See the section "USING latexmk WITH make" for how to
3556 do this. The intent of calling make from latexmk is merely to
3557 detect dependencies.
3558
3559 $view ["default"]
3560 Which kind of file is to be previewed if a previewer is used.
3561 The possible values are "default", "dvi", "ps", "pdf". The
3562 value of "default" means that the "highest" of the kinds of file
3563 generated is to be used (among .dvi, .ps and .pdf).
3564
3565
3566 $warnings_as_errors [0]
3567 Normally latexmk copies the behavior of latex in treating unde‐
3568 fined references and citations and multiply defined references
3569 as conditions that give a warning but not an error. The vari‐
3570 able $warnings_as_errors controls whether this behavior is modi‐
3571 fied.
3572
3573 When the variable is non-zero, latexmk at the end of its run
3574 will return a non-zero status code to the operating system if
3575 any of the files processed gives a warning about problems with
3576 citations or references (i.e., undefined citations or references
3577 or multiply defined references). This is after latexmk has com‐
3578 pleted all the runs it needs to try and resolve references and
3579 citations. Thus $warnings_as_errors being nonzero causes la‐
3580 texmk to treat such warnings as errors, but only when they occur
3581 on the last run of *latex and only after processing is complete.
3582 A non-zero value $warnings_as_errors can be set by the command-
3583 line option -Werror.
3584
3585 The default behavior is normally satisfactory in the usual edit-
3586 compile-edit cycle. But, for example, latexmk can also be used
3587 as part of a build process for some bigger project, e.g., for
3588 creating documentation in the build of a software application.
3589 Then it is often sensible to treat citation and reference warn‐
3590 ings as errors that require the overall build process to be
3591 aborted. Of course, since multiple runs of *latex are generally
3592 needed to resolve references and citations, what matters is not
3593 the warnings on the first run, but the warnings on the last run;
3594 latexmk takes this into account appropriately.
3595
3596 In addition, when preview-continuous mode is used, a non-zero
3597 value for $warnings_as_errors changes the use of the commands
3598 $failure_cmd, $warning_cmd, and $success_cmd after a complia‐
3599 tion. If there are citation or reference warnings, but no other
3600 errors, the behavior is as follows. If $warning_cmd is set, it
3601 is used. If it is not set, then then if $warnings_as_errors is
3602 non-zero and $failure_cmd is set, then $failure_cmd. Otherwise
3603 $success_cmd is used, if it is set. (The foregoing explanation
3604 is rather complicated, because latexmk has to deal with the case
3605 that one or more of the commands isn't set.)
3606
3607
3608 $xdv_mode [0]
3609 If one, generate an xdv version of the document by use of xela‐
3610 tex.
3611
3612
3613 $xdvipdfmx ["xdvipdfmx -E -o %D %O %S"]
3614
3615 The program to make a pdf file from an xdv file (used in con‐
3616 junction with xelatex when $pdf_mode=5).
3617
3618 $xdvipdfmx_silent_switch ["-q"]
3619 Switch(es) for the xdvipdfmx program when silent mode is on.
3620
3621 $xelatex ["xelatex %O %S"]
3622 Specifies the command line for the LaTeX processing program of
3623 when the xelatex program is called for. See the documentation
3624 of the -xelatex option for some special properties of latexmk's
3625 use of xelatex.
3626
3627 Note about xelatex: latexmk uses xelatex to make an .xdv rather
3628 than .pdf file, with the .pdf file being created in a separate
3629 step. This is enforced by the use of the -no-pdf option. If %O
3630 is part of the command for invoking xelatex, then latexmk will
3631 insert the -no-pdf option automatically, otherwise you must pro‐
3632 vide the option yourself. See the documentation for the -pdfxe
3633 option for why latexmk makes a .xdv file rather than a .pdf file
3634 when xelatex is used.
3635
3636 To do a coordinated setting of all of $dvilualatex, $latex,
3637 $pdflatex, $lualatex, and $xelatex, see the section "Advanced
3638 Configuration".
3639
3640
3641 %xelatex_input_extensions
3642 This variable specifies the extensions tried by latexmk when it
3643 finds that an xelatex run resulted in an error that a file has
3644 not been found, and the file is given without an extension.
3645 This typically happens when LaTeX commands of the form \in‐
3646 put{file} or \includegraphics{figure}, when the relevant source
3647 file does not exist.
3648
3649 In this situation, latexmk searches for custom dependencies to
3650 make the missing file(s), but restricts it to the extensions
3651 specified by the variable %xelatex_input_extensions. The de‐
3652 fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
3653
3654 See details of the %latex_input_extensions for other information
3655 that equally applies to %xelatex_input_extensions.
3656
3657 $xelatex_silent_switch ["-interaction=batchmode"]
3658 Switch(es) for the xelatex program (specified in the variable
3659 $xelatex) when silent mode is on.
3660
3661 See details of the $latex_silent_switch for other information
3662 that equally applies to $xelatex_silent_switch.
3663
3664
3665
3666
3668 In any RC file a set of custom dependencies can be set up to convert a
3669 file with one extension to a file with another. An example use of this
3670 would be to allow latexmk to convert a .fig file to .eps to be included
3671 in the .tex file.
3672
3673
3674 Defining a custom dependency:
3675 The old method of configuring latexmk to use a custom dependency was to
3676 directly manipulate the @cus_dep_list array that contains information
3677 defining the custom dependencies. (See the section "Old Method of
3678 Defining Custom Dependencies" for details.) This method still works,
3679 but is no longer preferred.
3680
3681 A better method is to use the subroutines that allow convenient manipu‐
3682 lations of the custom dependency list. These are
3683
3684 add_cus_dep( fromextension, toextension, must, subroutine )
3685 remove_cus_dep( fromextension, toextension )
3686 show_cus_dep()
3687
3688 The arguments are as follows:
3689
3690 from extension:
3691 The extension of the file we are converting from (e.g. "fig").
3692 It is specified without a period.
3693
3694 to extension:
3695 The extension of the file we are converting to (e.g. "eps"). It
3696 is specified without a period.
3697
3698 must: If non-zero, the file from which we are converting must exist,
3699 if it doesn't exist latexmk will give an error message and exit
3700 unless the -f option is specified. If must is zero and the file
3701 we are converting from doesn't exist, then no action is taken.
3702 Generally, the appropriate value of must is zero.
3703
3704 function:
3705 The name of the subroutine that latexmk should call to perform
3706 the file conversion. The first argument to the subroutine is
3707 the base name of the file to be converted without any extension.
3708 The subroutines are declared in the syntax of Perl. The func‐
3709 tion should return 0 if it was successful and a nonzero number
3710 if it failed.
3711
3712
3713 Naturally add_cus_dep adds a custom dependency with the specified from
3714 and to extensions. If a custom dependency has been previously defined
3715 (e.g., in an rcfile that was read earlier), then it is replaced by the
3716 new one.
3717
3718 The subroutine remove_cus_dep removes the specified custom dependency.
3719 The subroutine show_cus_dep causes a list of the currently defined cus‐
3720 tom dependencies to be sent to the screen output.
3721
3722
3723 How custom dependencies are used:
3724 An instance of a custom dependency rule is created whenever latexmk de‐
3725 tects that a run of *latex needs to read a file, like a graphics file,
3726 whose extension is the to-extension of a custom dependency. Then la‐
3727 texmk examines whether a file exists with the same name, but with the
3728 corresponding from-extension, as specified in the custom-dependency.
3729 If it does, then a corresponding instance of the custom dependency is
3730 created, after which the rule is invoked whenever the destination file
3731 (the one with the to-extension) is out-of-date with respect to the cor‐
3732 responding source file.
3733
3734 To make the new destination file, the Perl subroutine specified in the
3735 rule is invoked, with an argument that is the base name of the files in
3736 question. Simple cases just involve a subroutine invoking an external
3737 program; this can be done by following the templates below, even by
3738 those without knowledge of the Perl programming language. Of course,
3739 experts could do something much more elaborate.
3740
3741 One item in the specification of each custom-dependency rule, labeled
3742 "must" above, specifies how the rule should be applied when the source
3743 file fails to exist.
3744
3745 When latex reports that an input file (e.g., a graphics file) does not
3746 exist, latexmk tries to find a source file and a custom dependency that
3747 can be used to make it. If it succeeds, then it creates an instance of
3748 the custom dependency and invokes it to make the missing file, after
3749 which the next pass of latex etc will be able to read the newly created
3750 file.
3751
3752 Note for advanced usage: The operating system's environment variable
3753 TEXINPUTS can be used to specify a search path for finding files by la‐
3754 tex etc. Correspondingly, when a missing file is reported, latexmk
3755 looks in the directories specified in TEXINPUTS as well as in the cur‐
3756 rent directory, to find a source file from which an instance of a cus‐
3757 tom dependency can be used to make the missing file.
3758
3759
3760 Function to implement custom dependency, traditional method:
3761 The function that implements a custom dependency gets the information
3762 on the files to be processed in two ways. The first is through its one
3763 argument; the argument contains the base name of the source and desti‐
3764 nation files. The second way is described later.
3765
3766 A simple and typical example of code in an initialization rcfile using
3767 the first method is:
3768
3769 add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
3770 sub fig2eps {
3771 system( "fig2dev -Leps \"$_[0].fig\" \"$_[0].eps\"" );
3772 }
3773
3774 The first line adds a custom dependency that converts a file with ex‐
3775 tension "fig", as created by the xfig program, to an encapsulated post‐
3776 script file, with extension "eps". The remaining lines define a sub‐
3777 routine that carries out the conversion. If a rule for converting
3778 "fig" to "eps" files already exists (e.g., from a previously read-in
3779 initialization file), the latexmk will delete this rule before making
3780 the new one.
3781
3782 Suppose latexmk is using this rule to convert a file "figure.fig" to
3783 "figure.eps". Then it will invoke the fig2eps subroutine defined in
3784 the above code with a single argument "figure", which is the basename
3785 of each of the files (possibly with a path component). This argument
3786 is referred to by Perl as $_[0]. In the example above, the subroutine
3787 uses the Perl command system to invoke the program fig2dev. The double
3788 quotes around the string are a Perl idiom that signify that each string
3789 of the form of a variable name, $_[0] in this case, is to be substi‐
3790 tuted by its value.
3791
3792 If the return value of the subroutine is non-zero, then latexmk will
3793 assume an error occurred during the execution of the subroutine. In
3794 the above example, no explicit return value is given, and instead the
3795 return value is the value returned by the last (and only) statement,
3796 i.e., the invocation of system, which returns the value 0 on success.
3797
3798 If you use pdflatex, lualatex or xelatex instead of latex, then you
3799 will probably prefer to convert your graphics files to pdf format, in
3800 which case you would replace the above code in an initialization file
3801 by
3802
3803 add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
3804 sub fig2pdf {
3805 system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
3806 }
3807
3808 Note 1: In the command lines given in the system commands in the above
3809 examples, double quotes have been inserted around the file names (im‐
3810 plemented by '\"' in the Perl language). They immunize the running of
3811 the program against special characters in filenames. Very often these
3812 quotes are not necessary, i.e., they can be omitted. But it is nor‐
3813 mally safer to keep them in. Even though the rules for quoting vary
3814 between operating systems, command shells and individual pieces of
3815 software, the quotes in the above examples do not cause problems in the
3816 cases I have tested.
3817
3818 Note 2: One case in which the quotes are important is when the files
3819 are in a subdirectory and your operating system is Microsoft Windows.
3820 Then the separator character for directory components can be either a
3821 forward slash '/' or Microsoft's more usual backward slash '\'. For‐
3822 ward slashes are generated by latexmk, to maintain its sanity from
3823 software like MiKTeX that mixes both directory separators; but their
3824 correct use normally requires quoted filenames. (See a log file from a
3825 run of MiKTeX (at least in v. 2.9) for an example of the use of both
3826 directory separators.)
3827
3828 Note 3: The subroutines implementing custom dependencies in the exam‐
3829 ples given just have a single line invoking an external program.
3830 That's the usual situation. But since the subroutines are in the Perl
3831 language, you can implement much more complicated processing if you
3832 need it.
3833
3834
3835 Removing custom dependencies, and when you might need to do this:
3836 If you have some general custom dependencies defined in the system or
3837 user initialization file, you may find that for a particular project
3838 they are undesirable. So you might want to delete the unneeded ones.
3839 A situation where this would be desirable is where there are multiple
3840 custom dependencies with the same from-extension or the same to-exten‐
3841 sion. In that case, latexmk might choose a different one from the one
3842 you want for a specific project. As an example, to remove any "fig" to
3843 "eps" rule you would use:
3844
3845 remove_cus_dep( 'fig', 'eps' );
3846
3847 If you have complicated sets of custom dependencies, you may want to
3848 get a listing of the custom dependencies. This is done by using the
3849 line
3850
3851 show_cus_dep();
3852
3853 in an initialization file.
3854
3855
3856 Function implementing custom dependency, alternative methods:
3857 So far the examples for functions to implement custom dependencies have
3858 used the argument of the function to specify the base name of converted
3859 file. This method has been available since very old versions of la‐
3860 texmk, and many examples can be found, e.g., on the web.
3861
3862 However in later versions of latexmk the internal structure of the im‐
3863 plementation of its "rules" for the steps of processing, including cus‐
3864 tom dependencies, became much more powerful. The function implementing
3865 a custom dependency is executed within a special context where a number
3866 of extra variables and subroutines are defined. Publicly documented
3867 ones, intended to be long-term stable, are listed below, under the
3868 heading "Variables and subroutines for processing a rule".
3869
3870 Examples of their use is given in the following examples, concerning
3871 multiple index files and glossaries.
3872
3873 The only index-file conversion built-in to latexmk is from an ".idx"
3874 file written on one run of *latex to an ".ind" file to be read in on a
3875 subsequent run. But with the index.sty package, for example, you can
3876 create extra indexes with extensions that you configure. Latexmk does
3877 not know how to deduce the extensions from the information it has. But
3878 you can easily write a custom dependency. For example if your latex
3879 file uses the command "\newindex{special}{ndx}{nnd}{Special index}" you
3880 will need to get latexmk to convert files with the extension .ndx to
3881 .nnd. The most elementary method is to define a custom dependency as
3882 follows:
3883
3884 add_cus_dep( 'ndx', 'nnd', 0, 'ndx2nnd' );
3885 sub ndx2nnd {
3886 return system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
3887 }
3888 push @generated_exts, 'ndx', 'nnd';
3889
3890 Notice the added line compared with earlier examples. The extra line
3891 gets the extensions "ndx" and "nnd" added to the list of extensions for
3892 generated files; then the extra index files will be deleted by clean-up
3893 operations
3894
3895 But if you have yet more indexes with yet different extensions, e.g.,
3896 "adx" and "and", then you will need a separate function for each pair
3897 of extensions. This is quite annoying. You can use the Run_subst
3898 function to simplify the definitions to use a single function:
3899
3900 add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
3901 add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
3902 sub dx2nd {
3903 return Run_subst( "makeindex -o %D %S" );
3904 }
3905 push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
3906
3907 You could also instead use
3908
3909 add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
3910 add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
3911 sub dx2nd {
3912 return Run_subst( $makeindex );
3913 }
3914 push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
3915
3916 This last example uses the command specification in $makeindex, and so
3917 any customization you have made for the standard index also applies to
3918 your extra indexes.
3919
3920 Similar techniques can be applied for glossaries.
3921
3922 Those of you with experience with Makefiles, may get concerned that the
3923 .ndx file is written during a run of *latex and is always later than
3924 the .nnd last read in. Thus the .nnd appears to be perpetually out-of-
3925 date. This situation, of circular dependencies, is endemic to latex,
3926 and is one of the issues that latexmk is programmed to overcome. It
3927 examines the contents of the files (by use of a checksum), and only
3928 does a remake when the file contents have actually changed.
3929
3930 Of course if you choose to write random data to the .nnd (or the .aux
3931 file, etc) that changes on each new run, then you will have a problem.
3932 For real experts: See the %hash_calc_ignore_pattern if you have to deal
3933 with such problems.
3934
3935
3936 Old Method of Defining Custom Dependencies:
3937 In much older versions of latexmk, the only method of defining custom
3938 dependencies was to directly manipulate the table of custom dependen‐
3939 cies. This is contained in the @cus_dep_list array. It is an array of
3940 strings, and each string in the array has four items in it, each sepa‐
3941 rated by a space, the from-extension, the to-extension, the "must"
3942 item, and the name of the subroutine for the custom dependency. These
3943 were all defined above.
3944
3945 An example of the old method of defining custom dependencies is as fol‐
3946 lows. It is the code in an RC file to ensure automatic conversion of
3947 .fig files to .eps files:
3948
3949 push @cus_dep_list, "fig eps 0 fig2eps";
3950 sub fig2eps {
3951 return system( "fig2dev -Lps \"$_[0].fig\" \"$_[0].eps\"" );
3952 }
3953
3954 This method still works, and is almost equivalent to the code given
3955 earlier that used the add_cus_dep subroutine. However, the old method
3956 doesn't delete any previous custom-dependency for the same conversion.
3957 So the new method is preferable.
3958
3959
3960
3962 For most purposes, simple configuration for latexmk along the lines of
3963 the examples given is sufficient. But sometimes you need something
3964 harder. In this section, I indicate some extra possibilities. Gener‐
3965 ally to use these, you need to be fluent in the Perl language, since
3966 this is what is used in the rc files.
3967
3968 See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See also the
3969 examples in the directory example_rcfiles in the latexmk distributions.
3970 Even if none of the examples apply to your case, they may give you use‐
3971 ful ideas
3972
3973
3974 Utility subroutines
3975 ensure_path( var, values ...)
3976
3977 The first parameter is the name of one of the system's environ‐
3978 ment variables for search paths. The remaining parameters are
3979 values that should be in the variable. For each of the value
3980 parameters, if it isn't already in the variable, then it is
3981 prepended to the variable; in that case the environment variable
3982 is created if it doesn't already exist. For separating values,
3983 the character appropriate the the operating system is used --
3984 see the configuration variable $search_path_separator.
3985
3986 Example:
3987
3988 ensure_path( 'TEXINPUTS', './custom_cls_sty_files//' );
3989
3990 (In this example, the trailing '//' is documented by TeX systems
3991 to mean that *latex search for files in the specified directory
3992 and in all subdirectories.)
3993
3994 Technically ensure_path works by setting Perl's variable
3995 $ENV{var}, where var is the name of the target variable. The
3996 changed value is then passed as an environment variable to any
3997 invoked programs.
3998
3999
4000 Variables and subroutines for processing a rule
4001 A step in the processing is called a rule. One possibility to implement
4002 the processing of a rule is by a Perl subroutine. This is always the
4003 case for custom dependencies. Also, for any other rule, you can use a
4004 subroutine by prefixing the command specification by the word "inter‐
4005 nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
4006
4007 When you use a subroutine for processing a rule, all the possibilities
4008 of Perl programming are available, of course. In addition, some of la‐
4009 texmk's internal variables and subroutines are available. The ones
4010 listed below are intended to be available to (advanced) users, and
4011 their specifications will generally have stability under upgrades. Gen‐
4012 erally, the variables should be treated as read-only: Changing their
4013 values can have bad consequences, since it is liable to mess up the
4014 consistency of what latexmk is doing.
4015
4016 $rule This variable has the name of the rule, as known to latexmk.
4017 Note that the exact contents of this variable for a given rule
4018 may be dependent on the version of latexmk
4019
4020 $$Psource
4021 This gives the name of the primary source file. Note the double
4022 dollar signs.
4023
4024 $$Pdest
4025 This gives the name of the main output file if any. Note the
4026 double dollar signs.
4027
4028
4029 pushd( path ), popd()
4030 These subroutines are used when it is needed to temporarily
4031 change the working directory, as in
4032
4033 pushd( 'some_directory' );
4034 ... Processing done with 'some_directory' as the working
4035 directory
4036 popd()
4037
4038 They perform exactly the same function as the commands of the
4039 same names in operating system command shells like bash on Unix,
4040 and cmd.exe on the Windows.
4041
4042
4043 rdb_add_generated( file, ... )
4044 This subroutine is to be used in the context of a rule, that is,
4045 from within a subroutine that is carrying out processing of a
4046 rule. Such is the case for the subroutine implementing a custom
4047 dependency, or the subroutine invoked by using the "internal"
4048 keyword in the command specification like that in the variable
4049 $latex.
4050
4051 Its arguments are a sequence of filenames which are generated
4052 during the running of the rule. The names might arise from an
4053 analysis of the results of the run, e.g., in a log file, or from
4054 knowledge of properties of the specific rule. Calling
4055 rdb_add_generated with these filenames ensures that these files
4056 are flagged as generated by the rule in latexmk's internal data
4057 structures. Basically, no action is taken if the files have al‐
4058 ready been flagged as generated.
4059
4060 A main purpose of using this subroutine is for the situation
4061 when a generated file is also the source file for some rule, so
4062 that latexmk can correctly link the dependency information in
4063 its network of rules.
4064
4065 Note: Unlike some other subroutines in this section, there is no
4066 argument for a rule for rdb_add_generated. Instead, the subrou‐
4067 tine is to be invoked during the processing of a rule when la‐
4068 texmk has set up an appropriate context (i.e., appropriate vari‐
4069 ables). In contrast, subroutines with a rule argument can be
4070 used also outside a rule context.
4071
4072
4073 rdb_ensure_file( $rule, file )
4074 This subroutine ensures that the given file is among the source
4075 files for the specified rule. It is typically used when, during
4076 the processing of a rule, it is known that a particular extra
4077 file is among the dependencies that latexmk should know, but its
4078 default methods don't find the dependency. Almost always the
4079 first argument is the name of the rule currently being pro‐
4080 cessed, so it is then appropriate to specify it by $rule.
4081
4082 For examples of its use, see some of the files in the directory
4083 example_rcfiles of latexmk's distribution. Currently the cases
4084 that use this subroutine are bib2gls-latexmkrc, exceltex_la‐
4085 texmkrc and texinfo-latexmkrc. These illustrate typical cases
4086 where latexmk's normal processing fails to detect certain extra
4087 source files.
4088
4089 Note that rdb_ensure_file only has one filename argument, unlike
4090 other subroutines in this section. If you want to apply its ac‐
4091 tion to multiple files, you will need one call to rdb_en‐
4092 sure_file for each file.
4093
4094
4095 rdb_remove_files( $rule, file, ... )
4096 This subroutine removes one or more files from the dependency
4097 list for the given rule.
4098
4099
4100 rdb_remove_generated( file, ... )
4101 This subroutine is to be used in the context of a rule, that is,
4102 from within a subroutine that is carrying out processing of a
4103 rule. It performs the opposite action to rdb_add_generated.
4104 Its effect is to ensure that the given filenames are not listed
4105 in latexmk's internal data structures as being generated by the
4106 rule.
4107
4108
4109 rdb_list_source( $rule )
4110 This subroutine returns the list of source files (i.e., the de‐
4111 pendency list) for the given rule.
4112
4113
4114 rdb_set_source( $rule, file, ... )
4115
4116
4117 rdb_set_source( $rule, @files )
4118 This subroutine sets the dependency list for the given rule to
4119 be the specified files. Files that are already in the list have
4120 unchanged information. Files that were not in the list are
4121 added to it. Files in the previous dependency list that are not
4122 in the newly specified list of files are removed from the depen‐
4123 dency list.
4124
4125
4126 Run_subst( command_spec )
4127 This subroutine runs the command specified by command_spec. The
4128 specification is a string in the format listed in the section
4129 "Format of Command Specifications". An important action of the
4130 Run_subst is to make substitutions of placeholders, e.g., %S and
4131 %D for source and destination files; these get substituted be‐
4132 fore the command is run. In addition, the command after substi‐
4133 tution is printed to the screen unless latexmk is running in
4134 silent mode.
4135
4136
4137 Coordinated Setting of Commands for *latex
4138 To set all of $dvilualatex, $latex, $pdflatex, $lualatex, and $xelatex
4139 to a common pattern, you can use one of the following subroutines,
4140 std_tex_cmds, alt_tex_cmds, and set_tex_cmds.
4141
4142 To get the standard commands, use
4143
4144 &std_tex_cmds;
4145
4146 This results in $latex = 'latex %O %S', and similarly for $dvilualatex,
4147 $pdflatex, $lualatex, and $xelatex. Note the ampersand in the invoca‐
4148 tion; this indicates to Perl that a subroutine is being called. (The
4149 use of this subroutine enables you to override previous redefinitions
4150 of the $latex, etc variables, which might have occurred in an earlier-
4151 read rc file.)
4152
4153 To be able to use the string provided by the -pretex option (if any),
4154 you can use
4155
4156 &alt_tex_cmds;
4157
4158 This results in $latex = 'latex %O %P', etc. Again note the ampersand
4159 in the invocation; this indicates to Perl that a subroutine is being
4160 called.
4161
4162 A more general way of specifying the variables is using
4163
4164 set_tex_cmds( 'CMD_SPEC' );
4165
4166 Here CMD_SPEC is the command line without the program name. This re‐
4167 sults in $latex = 'latex CMD_SPEC', and similarly for $pdflatex, etc.
4168 (An ampersand preceding the subroutine name is not necessary here,
4169 since the parentheses show Perl that a subroutine is being invoked.)
4170
4171 An example that provides the --interaction=batchmode option to the *la‐
4172 tex commands would be
4173
4174 set_tex_cmds( '--interaction=batchmode %O %S' );
4175
4176 This results in $latex = 'latex --interaction=batchmode %O %S ', etc.
4177 Note that when '%O' appears after the added option, as here, options
4178 provided on the command line to latexmk can override the supplied one.
4179
4180 A more general command line can be set up by using the placeholder '%C'
4181 in CMD_SPEC. The '%C' is substituted by the basic name of the command,
4182 i.e., whichever of 'latex', 'pdflatex', etc is appropriate. (More than
4183 one occurrence of '%C' is allowed.) For example to use the develop‐
4184 ment/pre-release versions of latex, etc, which have names, 'latex-dev',
4185 'pdflatex-dev', etc, you could use
4186
4187 set_tex_cmds( '%C-dev %O %S' );
4188
4189 This results in $latex = 'latex-dev %O %S', etc. (The pre-release pro‐
4190 grams latex-dev etc are provided in current distributions of TeXLive
4191 and MiKTeX.)
4192
4193
4194 Advanced configuration: Using latexmk with make
4195 This section is targeted only at advanced users who use the make pro‐
4196 gram for complex projects, as for software development, with the depen‐
4197 dencies specified by a Makefile.
4198
4199 Now the basic task of latexmk is to run the appropriate programs to
4200 make a viewable version of a LaTeX document. However, the usual make
4201 program is not suited to this purpose for at least two reasons. First
4202 is that the use of LaTeX involves circular dependencies (e.g., via .aux
4203 files), and these cannot be handled by the standard make program. Sec‐
4204 ond is that in a large document the set of source files can change
4205 quite frequently, particularly with included graphics files; in this
4206 situation keeping a Makefile manually updated is inappropriate and er‐
4207 ror-prone, especially when the dependencies can be determined automati‐
4208 cally. Latexmk solves both of these problems robustly.
4209
4210 Thus for many standard LaTeX documents latexmk can be used by itself
4211 without the make program. In a complex project it simply needs to be
4212 suitably configured. A standard configuration would be to define cus‐
4213 tom dependencies to make graphics files from their source files (e.g.,
4214 as created by the xfig program). Custom dependencies are latexmk's
4215 equivalent of pattern rules in Makefiles.
4216
4217 Nevertheless there are projects for which a Makefile is appropriate,
4218 and it is useful to know how to use latexmk from a Makefile. A typical
4219 example would be to generate documentation for a software project. Po‐
4220 tentially the interaction with the rest of the rules in the Makefile
4221 could be quite complicated, for example if some of the source files for
4222 a LaTeX document are generated by the project's software.
4223
4224 In this section, I give a couple of examples of how latexmk can be use‐
4225 fully invoked from a Makefile. The examples use specific features of
4226 current versions of GNU make, which is the default on both linux and
4227 OS-X systems. They may need modifications for other versions of make.
4228
4229 The simplest method is simply to delegate all the relevant tasks to la‐
4230 texmk, as is suitable for a straightforward LaTeX document. For this a
4231 suitable Makefile is like
4232
4233 .PHONY : FORCE_MAKE
4234 all : try.pdf
4235 %.pdf : %.tex FORCE_MAKE
4236 latexmk -pdf -dvi- -ps- $<
4237
4238 (Note: the last line must be introduced by a tab for the Makefile to
4239 function correctly!) Naturally, if making try.pdf from its associated
4240 LaTeX file try.tex were the only task to be performed, a direct use of
4241 latexmk without a Makefile would normally be better. The benefit of
4242 using a Makefile for a LaTeX document would be in a larger project,
4243 where lines such as the above would be only be a small part of a larger
4244 Makefile.
4245
4246 The above example has a pattern rule for making a .pdf file from a .tex
4247 file, and it is defined to use latexmk in the obvious way. There is a
4248 conventional default target named "all", with a prerequisite of
4249 try.pdf. So when make is invoked, by default it makes try.pdf. The
4250 only complication is that there may be many source files beyond
4251 try.tex, but these aren't specified in the Makefile, so changes in them
4252 will not by themselves cause latexmk to be invoked. Instead, the pat‐
4253 tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
4254 the effect of causing the rule to be always out-of-date, so that la‐
4255 texmk is always run. It is latexmk that decides whether any action is
4256 needed, e.g., a rerun of pdflatex. Effectively the Makefile delegates
4257 all decisions to latexmk, while make has no knowledge of the list of
4258 source files except for primary LaTeX file for the document. If there
4259 are, for example, graphics files to be made, these must be made by cus‐
4260 tom dependencies configured in latexmk.
4261
4262 But something better is needed in more complicated situations, for ex‐
4263 ample, when the making of graphics files needs to be specified by rules
4264 in the Makefile. To do this, one can use a Makefile like the follow‐
4265 ing:
4266
4267 TARGETS = document1.pdf document2.pdf
4268 DEPS_DIR = .deps
4269 LATEXMK = latexmk -recorder -use-make -deps \
4270 -e 'warn qq(In Makefile, turn off custom dependencies\n);' \
4271 -e '@cus_dep_list = ();' \
4272 -e 'show_cus_dep();'
4273 all : $(TARGETS)
4274 $(foreach file,$(TARGETS),$(eval -include $(DEPS_DIR)/$(file)P))
4275 $(DEPS_DIR) :
4276 mkdir $@
4277 %.pdf : %.tex
4278 if [ ! -e $(DEPS_DIR) ]; then mkdir $(DEPS_DIR); fi
4279 $(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
4280 %.pdf : %.fig
4281 fig2dev -Lpdf $< $@
4282
4283 (Again, the lines containing the commands for the rules should be
4284 started with tabs.) This example was inspired by how GNU automake han‐
4285 dles automatic dependency tracking of C source files.
4286
4287 After each run of latexmk, dependency information is put in a file in
4288 the .deps subdirectory. The Makefile causes these dependency files to
4289 be read by make, which now has the full dependency information for each
4290 target .pdf file. To make things less trivial it is specificed that
4291 two files document1.pdf and document2.pdf are the targets. The depen‐
4292 dency files are .deps/document1.pdfP and .deps/document2.pdfP.
4293
4294 There is now no need for the phony prerequisite for the rule to make
4295 .pdf files from .tex files. But I have added a rule to make .pdf files
4296 from .fig files produced by the xfig program; these are commonly used
4297 for graphics insertions in LaTeX documents. Latexmk is arranged to
4298 output a dependency file after each run. It is given the -recorder op‐
4299 tion, which improves its detection of files generated during a run of
4300 pdflatex; such files should not be in the dependency list. The -e op‐
4301 tions are used to turn off all custom dependencies, and to document
4302 this. Instead the -use-make is used to delegate the making of missing
4303 files to make itself.
4304
4305 Suppose in the LaTeX file there is a command \includegraphics{graph},
4306 and an xfig file "graph.fig" exists. On a first run, pdflatex reports
4307 a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
4308 by calling "make graph.pdf", and after completion of its work, it lists
4309 "fig.pdf" among the dependents of the file latexmk is making. Then let
4310 "fig.fig" be updated, and then let make be run. Make first remakes
4311 "fig.pdf", and only then reruns latexmk.
4312
4313 Thus we now have a method by which all the subsidiary processing is
4314 delegated to make.
4315
4316 Escaping of characters in dependency lists: There are certain special
4317 characters that need to be escaped when names of files and directories
4318 containing them appear in a dependency list used by a make program.
4319 Generally, such special characters are best avoided.
4320
4321 By default, latexmk does no escaping of this kind, and the user will
4322 have to arrange to deal with the issue separately, if the relevant spe‐
4323 cial characters are used. Note that the rules for escaping depend on
4324 which make program is used, and on its version.
4325
4326 One special case is of spaces, since those are particularly prevalent,
4327 notably in standard choices of name for a user's home directory. So
4328 latexmk does provide an option to escape spaces. See the option
4329 -deps_escape=... and the variable $deps_escape for details.
4330
4331
4332
4334 Modern operating systems and file systems allow non-ASCII characters in
4335 the names of files and directories that encompass the full Unicode
4336 range. Mostly, latexmk deals with these correctly. However, there are
4337 some situations in which there are problems, notably on Microsoft Win‐
4338 dows. Prior to version 4.77, latexmk had problems with non-ASCII file‐
4339 names on Windows, even though there were no corresponding problems on
4340 macOS and Linux. These problems are corrected in the present version.
4341
4342 DETAILS TO BE FILLED IN
4343
4344
4345
4347 latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
4348
4349
4351 Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
4352 its creation is started but before the file is complete. Work around:
4353 manually refresh (or reopen) display. Or use one of the other preview‐
4354 ers and update methods.
4355
4356 (The following isn't really a bug, but concerns features of preview‐
4357 ers.) Preview continuous mode only works perfectly with certain pre‐
4358 viewers: Xdvi on UNIX/Linux works for dvi files. Gv on UNIX/Linux
4359 works for both postscript and pdf. Ghostview on UNIX/Linux needs a
4360 manual update (reopen); it views postscript and pdf. Gsview under MS-
4361 Windows works for both postscript and pdf, but only reads the updated
4362 file when its screen is refreshed. Acroread under UNIX/Linux views
4363 pdf, but the file needs to be closed and reopened to view an updated
4364 version. Under MS-Windows, acroread locks its input file and so the
4365 pdf file cannot be updated. (Remedy: configure latexmk to use suma‐
4366 trapdf instead.)
4367
4369 Authors of previous versions. Many users with their feedback, and es‐
4370 pecially David Coppit (username david at node coppit.org) who made many
4371 useful suggestions that contributed to version 3, and Herbert Schulz.
4372 (Please note that the e-mail addresses are not written in their stan‐
4373 dard form to avoid being harvested too easily.)
4374
4376 Current version, by John Collins (Version 4.81). Report bugs etc to
4377 his e-mail (jcc8 at psu.edu).
4378
4379 Released version can be obtained from CTAN:
4380 <http://www.ctan.org/pkg/latexmk/>, and from the author's website
4381 <https://www.cantab.net/users/johncollins/latexmk/>.
4382 Modifications and enhancements by Evan McLean (Version 2.0)
4383 Original script called "go" by David J. Musliner (RCS Version 3.2)
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396 6 November 2023 LATEXMK(1)