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