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, together with those very
2068 standard cases that are hardwired into latexmk (e.g., .log
2069 files).
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 The files to be deleted are relative to the directory specified
2102 by $aux_dir. (Note that if $out_dir but not $aux_dir is set,
2103 then in its initialization, latexmk sets $aux_dir equal to
2104 $out_dir. A normal situation is therefore that $aux_dir equals
2105 $out_dir, which is the only case supported by TeXLive, unlike
2106 MiKTeX.)
2107
2108 The filenames specified for a clean-up operation can refer not
2109 only to regular files but also to directories. Directories are
2110 only deleted if they are empty. An example of an application is
2111 to pythontex, which creates files in a particular directory.
2112 You can arrange to remove both the files and the directory by
2113 setting
2114
2115 $clean_ext = "pythontex-files-%R pythontex-files-%R";
2116
2117 See also the variable @generated_exts.
2118
2119 $clean_full_ext [""]
2120 Extra extensions of files for latexmk to remove when the -C op‐
2121 tion is selected, i.e., extensions of files to remove when the
2122 .dvi, etc files are to be cleaned-up.
2123
2124 More general patterns are allowed, as for $clean_ext.
2125
2126 The files specified by $clean_full_ext to be deleted are rela‐
2127 tive to the directory specified by $out_dir.
2128
2129
2130 $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
2131 [""]
2132
2133 These variables specify commands that are executed at certain
2134 points of compilations. One motivation for their existence is
2135 to allow very useful convenient visual indications of compila‐
2136 tion status even when the window receiving the screen output of
2137 the compilation is hidden. This is particularly useful in pre‐
2138 view-continuous mode.
2139
2140 The commands are executed at the following points: $compil‐
2141 ing_cmd at the start of compilation, $success_cmd at the end of
2142 a completely successful compilation, $failure_cmd at the end of
2143 an unsuccessful compilation, $warning_cmd at the of an otherwise
2144 successful compilation that gives warnings about undefined cita‐
2145 tions or references or about multiply defined references. If any
2146 of above variables is undefined or blank (the default situa‐
2147 tion), then the corresponding command is not executed.
2148
2149 However, when $warning_cmd is not set, then in the case of a
2150 compilation with warnings about references or citations, but
2151 with no other error, one or other of $success_cmd or $fail‐
2152 ure_cmd is used (if it is set) according to the setting of
2153 $warnings_as_errors.
2154
2155 An example of a simple setting of these variables is as follows
2156
2157 $compiling_cmd = "xdotool search --name \"%D\" set_window
2158 --name \"%D compiling\"";
2159 $success_cmd = "xdotool search --name \"%D\" set_window
2160 --name \"%D OK\"";
2161 $warning_cmd = "xdotool search --name \"%D\" ".
2162 "set_window --name \"%D CITE/REF ISSUE\"";
2163 $failure_cmd = "xdotool search --name \"%D\" set_window
2164 --name \"%D FAILURE\"";
2165
2166 These assume that the program xdotool is installed, that the
2167 previewer is using an X-Window system for display, and that the
2168 title of the window contains the name of the displayed file, as
2169 it normally does. When the commands are executed, the place‐
2170 holder string %D is replaced by the name of the destination
2171 file, which is the previewed file. The above commands result in
2172 an appropriate string being appended to the filename in the win‐
2173 dow title: " compiling", " OK", or " FAILURE".
2174
2175 Other placeholders that can be used are %S, %T, and %R, with %S
2176 and %T normally being identical. These can be useful for a com‐
2177 mand changing the title of the edit window. The visual indica‐
2178 tion in a window title can useful, since the user does not have
2179 to keep shifting attention to the (possibly hidden) compilation
2180 window to know the status of the compilation.
2181
2182 More complicated situations can best be handled by defining a
2183 Perl subroutine to invoke the necessary commands, and using the
2184 "internal" keyword in the definitions to get the subroutine to
2185 be invoked. (See the section "Format of Command Specifications"
2186 for how to do this.)
2187
2188 Naturally, the above settings that invoke the xdotool program
2189 are only applicable when the X-Window system is used for the
2190 relevant window(s). For other cases, you will have to find what
2191 software solutions are available.
2192
2193
2194 @cus_dep_list [()]
2195 Custom dependency list -- see section on "Custom Dependencies".
2196
2197 @default_excluded_files [()]
2198 When latexmk is invoked with no files specified on the command
2199 line, then, by default, it will process all files in the current
2200 directory with the extension .tex. (In general, it will process
2201 the files specified in the @default_files variable.)
2202
2203 But sometimes you want to exclude particular files from this de‐
2204 fault list. In that case you can specify the excluded files in
2205 the array @default_excluded_files. For example if you wanted to
2206 process all .tex files with the exception of common.tex, which
2207 is a not a standard alone LaTeX file but a file input by some or
2208 all of the others, you could do
2209
2210 @default_files = ("*.tex");
2211
2212 @default_excluded_files = ("common.tex");
2213
2214 If you have a variable or large number of files to be processed,
2215 this method saves you from having to list them in detail in @de‐
2216 fault_files and having to update the list every time you change
2217 the set of files to be processed.
2218
2219 Notes: 1. This variable has no effect except when no files are
2220 specified on the latexmk command line. 2. Wildcards are allowed
2221 in @default_excluded_files.
2222
2223 @default_files [("*.tex")]
2224 Default list of files to be processed.
2225
2226 If no filenames are specified on the command line, latexmk pro‐
2227 cesses all tex files specified in the @default_files variable,
2228 which by default is set to all tex files ("*.tex") in the cur‐
2229 rent directory. This is a convenience: just run latexmk and it
2230 will process an appropriate set of files. But sometimes you
2231 want only some of these files to be processed. In this case you
2232 can list the files to be processed by setting @default_files in
2233 an initialization file (e.g., the file "latexmkrc" in the cur‐
2234 rent directory). Then if no files are specified on the command
2235 line then the files you specify by setting @default_files are
2236 processed.
2237
2238 Three examples:
2239
2240 @default_files = ("paper_current");
2241
2242 @default_files = ("paper1", "paper2.tex");
2243
2244 @default_files = ("*.tex", "*.dtx");
2245
2246 Note that more than file may be given, and that the default ex‐
2247 tension is ".tex". Wild cards are allowed. The parentheses are
2248 because @default_files is an array variable, i.e., a sequence of
2249 filename specifications is possible.
2250
2251 If you want latexmk to process all .tex files with a few excep‐
2252 tions, see the @default_excluded_files array variable.
2253
2254 $dependents_phony [0]
2255 If a list of dependencies is output, this variable determines
2256 whether to include a phony target for each source file. If you
2257 use the dependents list in a Makefile, the dummy rules work
2258 around errors make gives if you remove header files without up‐
2259 dating the Makefile to match.
2260
2261 $dependents_list [0]
2262 Whether to display a list(s) of dependencies at the end of a
2263 run.
2264
2265 $deps_file ["-"]
2266 Name of file to receive list(s) of dependencies at the end of a
2267 run, to be used if $dependesnt_list is set. If the filename is
2268 "-", then the dependency list is set to stdout (i.e., normally
2269 the screen).
2270
2271
2272 $do_cd [0]
2273 Whether to change working directory to the directory specified
2274 for the main source file before processing it. The default be‐
2275 havior is not to do this, which is the same as the behavior of
2276 *latex programs. This variable is set by the -cd and -cd- op‐
2277 tions on latexmk's command line.
2278
2279 $dvi_filter [empty]
2280 The dvi file filter to be run on the newly produced dvi file be‐
2281 fore other processing. Equivalent to specifying the -dF option.
2282
2283 $dvi_mode [See below for default]
2284 If nonzero, generate a dvi version of the document. Equivalent
2285 to the -dvi option.
2286
2287 The variable $dvi_mode defaults to 0, but if no explicit re‐
2288 quests are made for other types of file (postscript, pdf), then
2289 $dvi_mode will be set to 1. In addition, if a request for a
2290 file for which a .dvi file is a prerequisite, then $dvi_mode
2291 will be set to 1.
2292
2293 $dvi_previewer ["start xdvi %O %S" under UNIX]
2294 The command to invoke a dvi-previewer. [Under MS-Windows the
2295 default is "start"; then latexmk arranges to use the MS-Windows
2296 start program, which will cause to be run whatever command the
2297 system has associated with .dvi files.]
2298
2299 Important note: Normally you will want to have a previewer run
2300 detached, so that latexmk doesn't wait for the previewer to ter‐
2301 minate before continuing its work. So normally you should pre‐
2302 fix the command by "start ", which flags to latexmk that it
2303 should do the detaching of the previewer itself (by whatever
2304 method is appropriate to the operating system). But sometimes
2305 letting latexmk do the detaching is not appropriate (for a vari‐
2306 ety of non-trivial reasons), so you should put the "start " bit
2307 in yourself, whenever it is needed.
2308
2309 $dvi_previewer_landscape ["start xdvi %O %S"]
2310 The command to invoke a dvi-previewer in landscape mode. [Under
2311 MS-Windows the default is "start"; then latexmk arranges to use
2312 the MS-Windows start program, which will cause to be run what‐
2313 ever command the system has associated with .dvi files.]
2314
2315 $dvipdf ["dvipdf -dALLOWPSTRANSPARENCY %O %S %D"]
2316 Command to convert .dvi to .pdf file. A common reconfiguration
2317 is to use the dvipdfm command, which needs its arguments in a
2318 different order:
2319
2320 $dvipdf = "dvipdfm %O -o %D %S";
2321
2322 WARNING: The default dvipdf script generates pdf files with
2323 bitmapped fonts, which do not look good when viewed by acroread.
2324 That script should be modified to give dvips the options "-P
2325 pdf" to ensure that type 1 fonts are used in the pdf file.
2326
2327 $dvipdf_silent_switch ["-q"]
2328 Switch(es) for dvipdf program when silent mode is on.
2329
2330 N.B. The standard dvipdf program runs silently, so adding the
2331 silent switch has no effect, but is actually innocuous. But if
2332 an alternative program is used, e.g., dvipdfmx, then the silent
2333 switch has an effect. The default setting is correct for
2334 dvipdfm and dvipdfmx.
2335
2336 $dvips ["dvips %O -o %D %S"]
2337 The program to used as a filter to convert a .dvi file to a .ps
2338 file. If pdf is going to be generated from pdf, then the value
2339 of the $dvips_pdf_switch variable -- see below -- will be in‐
2340 cluded in the options substituted for "%O".
2341
2342 $dvips_landscape ["dvips -tlandscape %O -o %D %S"]
2343 The program to used as a filter to convert a .dvi file to a .ps
2344 file in landscape mode.
2345
2346 $dvips_pdf_switch ["-P pdf"]
2347 Switch(es) for dvips program when pdf file is to be generated
2348 from .ps file.
2349
2350 $dvips_silent_switch ["-q"]
2351 Switch(es) for dvips program when silent mode is on.
2352
2353 $dvi_update_command [""]
2354 When the dvi previewer is set to be updated by running a com‐
2355 mand, this is the command that is run. See the information for
2356 the variable $dvi_update_method for further information, and see
2357 information on the variable $pdf_update_method for an example
2358 for the analogous case of a pdf previewer.
2359
2360 $dvi_update_method [2 under UNIX, 1 under MS-Windows]
2361 How the dvi viewer updates its display when the dvi file has
2362 changed. The values here apply equally to the $pdf_up‐
2363 date_method and to the $ps_update_method variables.
2364 0 => update is automatic,
2365 1=> manual update by user, which may only mean a mouse click
2366 on the viewer's window or may mean a more serious action.
2367 2 => Send the signal, whose number is in the variable
2368 $dvi_update_signal. The default value under UNIX is suitable
2369 for xdvi.
2370 3 => Viewer cannot do an update, because it locks the file.
2371 (As with acroread under MS-Windows.)
2372 4 => run a command to do the update. The command is speci‐
2373 fied by the variable $dvi_update_command.
2374
2375 See information on the variable $pdf_update_method for an exam‐
2376 ple of updating by command.
2377
2378 $dvi_update_signal [Under UNIX: SIGUSR1, which is a system-dependent
2379 value]
2380 The number of the signal that is sent to the dvi viewer when it
2381 is updated by sending a signal -- see the information on the
2382 variable $dvi_update_method. The default value is the one ap‐
2383 propriate for xdvi on a UNIX system.
2384
2385 $emulate_aux [0]
2386 Whether to emulate the use of aux_dir when $aux_dir and $out_dir
2387 are different, rather than using the -aux-directory option for
2388 the *latex programs. (MiKTeX supports -aux-directory, but
2389 TeXLive doesn't.)
2390
2391 If you use a version of *latex that doesn't support -aux-direc‐
2392 tory, e.g., TeXLive, latexmk will automatically switch aux_dir
2393 emulation on after the first run of *latex, because it will find
2394 the .log file in the wrong place.
2395
2396 Aux_directory emulation means that when *latex is invoked, the
2397 output directory provided to *latex is set to be the aux_dir.
2398 After that, any files that need to be in the output directory
2399 will be moved there. (These are the files with extensions .dvi,
2400 .ps, .pdf, .fls, .synctex, .synctex.gz.)
2401
2402
2403 $failure_cmd [undefined]
2404 See the documentation for $compiling_cmd.
2405
2406 $fdb_ext ["fdb_latexmk"]
2407 The extension of the file which latexmk generates to contain a
2408 database of information on source files. You will not normally
2409 need to change this.
2410
2411 $filetime_causality_threshold [5]; $filetime_offset_report_threshold
2412 [30]. (Units of seconds.)
2413
2414 These variables control how latexmk deals with the following is‐
2415 sue, which can affect the use of files that are on a remote
2416 filesystem (network share) instead of being on a file system lo‐
2417 cal to the computer running latexmk. Almost users will not have
2418 to worry about these settings, and can ignore the following ex‐
2419 planation.
2420
2421 In almost all situations, latexmk does not need to use the time
2422 stamps of the files it works with. However, there are a couple
2423 of situations when it needs to know whether a certain file was
2424 created in the current run of a program (e.g., *latex) or is a
2425 leftover file from a previous run. It does this by comparing the
2426 modification time of the file with the system time just before
2427 the program was started. If the modification time is earlier
2428 than when the program was started, the file is a leftover file,
2429 which latexmk treats as if it were not created. If the filetime
2430 is at least the program start time, then it can be assumed that
2431 the file was created in the current run.
2432
2433 Unfortunately, this test can fail if the file is on a remote
2434 system, since its system time is not necessarily synchronized
2435 with that of the local system; the timestamps on the remote
2436 files are set by the remote system, not the local system. Gen‐
2437 erally, modern operating systems regularly synchronize their
2438 time with a server, so the non-synchronization is mostly small
2439 (a second or so, or a few seconds). But even a small difference
2440 can mess up latexmk's test.
2441
2442 Latexmk measures the time difference between the time on the two
2443 systems and compensates for this. But the measurement (in a
2444 system-independent way) is only accurate to a second or two. So
2445 latexmk allows for a threshold on the difference between file
2446 and system time before it concludes that a file is a leftover
2447 file from a previous run. The configuration variable $file‐
2448 time_causality_theshhold, which in units of seconds, specifies
2449 this threshold. Luckily high precision is not needed. The pre‐
2450 vious run is normally the previous run in a human run-edit-run
2451 cycle, and is at least many seconds back. A few seconds is
2452 therefore appropriate for the threshold, $filetime_causal‐
2453 ity_theshhold; it should be non-negative always, and should be
2454 bigger than 2 if a remote filesystem or network share is used.
2455
2456 If the difference in system times on the two systems is large,
2457 it normally indicates that at least one of the systems is mis‐
2458 configured. The variable $filetime_offset_report_threshold
2459 specifies the smallest size of the difference (or offset) in
2460 seconds between the times of the local and remote system beyond
2461 which the offset is reported. This is reported at the point in
2462 the latexmk's progress that it measures the offset. The report
2463 is made if silent mode is used and diagnostic mode is not on.
2464
2465
2466 $force_mode [0]
2467 If nonzero, continue processing past minor latex errors includ‐
2468 ing unrecognized cross references. Equivalent to specifying the
2469 -f option.
2470
2471 @generated_exts [( aux , bbl , idx , ind , lof , lot , out , toc ,
2472 $fdb_ext )]
2473 This contains a list of extensions for files that are generated
2474 during a LaTeX run and that are read in by LaTeX in later runs,
2475 either directly or indirectly.
2476
2477 This list specifies files known to be generated by *latex. It
2478 is used in two ways: (a) The specified files are deleted in a
2479 cleanup operation (with the -c, -C, -CA, -g and -gg options),
2480 and (b) It affects the determination of whether a rerun of *la‐
2481 tex is needed after a run that gives an error.
2482
2483 (Concerning item (b): Normally, a change of a source file during
2484 a run should provoke a rerun. This includes a file generated by
2485 LaTeX, e.g., an aux file, that is read in on subsequent runs.
2486 But after a run that results in an error, a new run should not
2487 occur until the user has made a change in the files. But the
2488 user may have corrected an error in a source .tex file during
2489 the run. So latexmk needs to distinguish user-generated and au‐
2490 tomatically generated files; it determines the automatically
2491 generated files as those with extensions in the list in @gener‐
2492 ated_exts.)
2493
2494 A convenient way to add an extra extension to the list, without
2495 losing the already defined ones is to use a push command in the
2496 line in an RC file. E.g.,
2497
2498 push @generated_exts, "end";
2499
2500 adds the extension "end" to the list of predefined generated ex‐
2501 tensions. (This extension is used by the RevTeX package, for
2502 example.)
2503
2504 $go_mode [0]
2505 If nonzero, process files regardless of timestamps, and is then
2506 equivalent to the -g option.
2507
2508 %hash_calc_ignore_pattern
2509 !!!This variable is for experts only!!!
2510
2511 The general rule latexmk uses for determining when an extra run
2512 of some program is needed is that one of the source files has
2513 changed. But consider for example a latex package that causes
2514 an encapsulated postscript file (an "eps" file) to be made that
2515 is to be read in on the next run. The file contains a comment
2516 line giving its creation date and time. On the next run the
2517 time changes, latex sees that the eps file has changed, and
2518 therefore reruns latex. This causes an infinite loop, that is
2519 only terminated because latexmk has a limit on the number of
2520 runs to guard against pathological situations.
2521
2522 But the changing line has no real effect, since it is a comment.
2523 You can instruct latex to ignore the offending line as follows:
2524
2525 $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
2526
2527 This creates a rule for files with extension .eps about lines to
2528 ignore. The left-hand side is a Perl idiom for setting an item
2529 in a hash. Note that the file extension is specified without a
2530 period. The value, on the right-hand side, is a string contain‐
2531 ing a regular expression. (See documentation on Perl for how
2532 they are to be specified in general.) This particular regular
2533 expression specifies that lines beginning with "%%CreationDate:
2534 " are to be ignored in deciding whether a file of the given ex‐
2535 tension .eps has changed.
2536
2537 There is only one regular expression available for each exten‐
2538 sion. If you need more one pattern to specify lines to ignore,
2539 then you need to combine the patterns into a single regular ex‐
2540 pression. The simplest method is separate the different simple
2541 patterns by a vertical bar character (indicating "alternation"
2542 in the jargon of regular expressions). For example,
2543
2544 $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Ti‐
2545 tle: ';
2546
2547 causes lines starting with either "^%%CreationDate: " or "^%%Ti‐
2548 tle: " to be ignored.
2549
2550 It may happen that a pattern to be ignored is specified in, for
2551 example, in a system or user initialization file, and you wish
2552 to remove this in a file that is read later. To do this, you
2553 use Perl's delete function, e.g.,
2554
2555 delete $hash_calc_ignore_pattern{'eps'};
2556
2557
2558 $jobname [""]
2559
2560 This specifies the jobname, i.e., the basename that is used for
2561 generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
2562 variable is a null string, then the basename is the basename of
2563 the main tex file. (At present, the string in $jobname should
2564 not contain spaces.)
2565
2566 The placeholder '%A' is permitted. This will be substituted by
2567 the basename of the TeX file. The primary purpose is when a va‐
2568 riety of tex files are to be processed, and you want to use a
2569 different jobname for each but one that is distinct for each.
2570 Thus if you wanted to compare compilations of a set of files on
2571 different operating systems, with distinct filenames for all the
2572 cases, you could set
2573
2574 $jobname = "%A-$^O";
2575
2576 in an initialization file. (Here $^O is a variable provided by
2577 perl that contains perl's name for the operating system.)
2578
2579 Suppose you had .tex files test1.tex and test2.tex. Then when
2580 you run
2581
2582 latexmk -pdf *.tex
2583
2584 both files will be compiled. The .aux, .log, and .pdf files
2585 will have basenames test1-MSWin32 ante test2-MSWin32 on a MS-
2586 Windows system, test1-darwin and test2-darwin on an OS-X system,
2587 and a variety of similar cases on linux systems.
2588
2589
2590 $kpsewhich ["kpsewhich %S"]
2591 The program called to locate a source file when the name alone
2592 is not sufficient. Most filenames used by latexmk have suffi‐
2593 cient path information to be found directly. But sometimes, no‐
2594 tably when a .bib or a .bst file is found from the log file of a
2595 bibtex or biber run, only the base name of the file is known,
2596 but not its path. The program specified by $kpsewhich is used to
2597 find it.
2598
2599 (For advanced users: Because of the different way in which la‐
2600 texmk uses the command specified in $kpsewhich, some of the pos‐
2601 sibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do not
2602 apply. The internal and start keywords are not available. A
2603 simple command specification with possible options and then "%S"
2604 is all that is guaranteed to work. Note that for other com‐
2605 mands, "%S" is substituted by a single source file. In contrast,
2606 for $kpsewhich, "%S" may be substituted by a long list of space-
2607 separated filenames, each of which is quoted. The result on
2608 STDOUT of running the command is then piped to latexmk.)
2609
2610 See also the @BIBINPUTS variable for another way that latexmk
2611 also uses to try to locate files; it applies only in the case of
2612 .bib files.
2613
2614 $kpsewhich_show [0]
2615 Whether to show diagnostics about invocations of kpsewhich: the
2616 command line use to invoke it and the results. These diagnos‐
2617 tics are shown if $kpsewhich_show is non-zero or if diagnostics
2618 mode is on. (But in the second case, lots of other diagnostics
2619 are also shown.) Without these diagnostics there is nothing
2620 visible in latexmk's screen output about invocations of kpse‐
2621 which.
2622
2623 $landscape_mode [0]
2624 If nonzero, run in landscape mode, using the landscape mode pre‐
2625 viewers and dvi to postscript converters. Equivalent to the -l
2626 option. Normally not needed with current previewers.
2627
2628 $latex ["latex %O %S"]
2629 Specifies the command line for the LaTeX processing program.
2630 Note that as with other programs, you can use this variable not
2631 just to change the name of the program used, but also specify
2632 options to the program. E.g.,
2633
2634 $latex = "latex --src-specials %O %S";
2635
2636 To do a coordinated setting of all of $latex, $pdflatex, $luala‐
2637 tex, and $xelatex, see the section "Advanced Configuration".
2638
2639
2640 %latex_input_extensions
2641 This variable specifies the extensions tried by latexmk when it
2642 finds that a LaTeX run resulted in an error that a file has not
2643 been found, and the file is given without an extension. This
2644 typically happens when LaTeX commands of the form \input{file}
2645 or \includegraphics{figure}, when the relevant source file does
2646 not exist.
2647
2648 In this situation, latexmk searches for custom dependencies to
2649 make the missing file(s), but restricts it to the extensions
2650 specified by the variable %latex_input_extensions. The default
2651 extensions are 'tex' and 'eps'.
2652
2653 (For Perl experts: %latex_input_extensions is a hash whose keys
2654 are the extensions. The values are irrelevant.) Two subrou‐
2655 tines are provided for manipulating this and the related vari‐
2656 able %pdflatex_input_extensions, add_input_ext and remove_in‐
2657 put_ext. They are used as in the following examples are possi‐
2658 ble lines in an initialization file:
2659
2660 remove_input_ext( 'latex', 'tex' );
2661
2662 removes the extension 'tex' from latex_input_extensions
2663
2664 add_input_ext( 'latex', 'asdf' );
2665
2666 add the extension 'asdf to latex_input_extensions. (Naturally
2667 with such an extension, you should have made an appropriate cus‐
2668 tom dependency for latexmk, and should also have done the appro‐
2669 priate programming in the LaTeX source file to enable the file
2670 to be read. The standard extensions are handled by LaTeX and
2671 its graphics/graphicx packages.)
2672
2673 $latex_silent_switch ["-interaction=batchmode"]
2674 Switch(es) for the LaTeX processing program when silent mode is
2675 on.
2676
2677 If you use MikTeX, you may prefer the results if you configure
2678 the options to include -c-style-errors, e.g., by the following
2679 line in an initialization file
2680
2681 $latex_silent_switch = "-interaction=batchmode -c-style-er‐
2682 rors";
2683
2684
2685 $lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
2686 The command to print postscript files.
2687
2688 Under MS-Windows (unlike UNIX/Linux), there is no standard pro‐
2689 gram for printing files. But there are ways you can do it. For
2690 example, if you have gsview installed, you could use it with the
2691 option "/p":
2692
2693 $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
2694
2695 If gsview is installed in a different directory, you will need
2696 to make the appropriate change. Note the combination of single
2697 and double quotes around the name. The single quotes specify
2698 that this is a string to be assigned to the configuration vari‐
2699 able $lpr. The double quotes are part of the string passed to
2700 the operating system to get the command obeyed; this is neces‐
2701 sary because one part of the command name ("Program Files") con‐
2702 tains a space which would otherwise be misinterpreted.
2703
2704 $lpr_dvi ["NONE lpr_dvi"]
2705 The printing program to print dvi files.
2706
2707 $lpr_pdf ["NONE lpr_pdf"]
2708 The printing program to print pdf files.
2709
2710 Under MS-Windows you could set this to use gsview, if it is in‐
2711 stalled, e.g.,
2712
2713 $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
2714
2715 If gsview is installed in a different directory, you will need
2716 to make the appropriate change. Note the double quotes around
2717 the name: this is necessary because one part of the command name
2718 ("Program Files") contains a space which would otherwise be mis‐
2719 interpreted.
2720
2721 $lualatex ["lualatex %O %S"]
2722 Specifies the command line for the LaTeX processing program that
2723 is to be used when the lualatex program is called for (e.g., by
2724 the option -lualatex.
2725
2726 To do a coordinated setting of all of $latex, $pdflatex, $luala‐
2727 tex, and $xelatex, see the section "Advanced Configuration".
2728
2729
2730 %lualatex_input_extensions
2731 This variable specifies the extensions tried by latexmk when it
2732 finds that a lualatex run resulted in an error that a file has
2733 not been found, and the file is given without an extension.
2734 This typically happens when LaTeX commands of the form \in‐
2735 put{file} or \includegraphics{figure}, when the relevant source
2736 file does not exist.
2737
2738 In this situation, latexmk searches for custom dependencies to
2739 make the missing file(s), but restricts it to the extensions
2740 specified by the variable %pdflatex_input_extensions. The de‐
2741 fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
2742
2743 See details of the %latex_input_extensions for other information
2744 that equally applies to %lualatex_input_extensions.
2745
2746 $lualatex_silent_switch ["-interaction=batchmode"]
2747 Switch(es) for the lualatex program (specified in the variable
2748 $lualatex) when silent mode is on.
2749
2750 See details of the $latex_silent_switch for other information
2751 that equally applies to $lualatex_silent_switch.
2752
2753 $make ["make"]
2754 The make processing program.
2755
2756 $makeindex ["makeindex %O -o %D %S"]
2757 The index processing program.
2758
2759 $makeindex_fudge [0]
2760 When using makeindex, whether to change directory to $aux_dir
2761 before running makeindex. Set to 1 if $aux_dir is not an ex‐
2762 plicit subdirectory of current directory, otherwise makeindex
2763 will refuse to write its output and log files, for security rea‐
2764 sons.
2765
2766 $makeindex_silent_switch ["-q"]
2767 Switch(es) for the index processing program when silent mode is
2768 on.
2769
2770 $max_repeat [5]
2771 The maximum number of times latexmk will run *latex before de‐
2772 ciding that there may be an infinite loop and that it needs to
2773 bail out, rather than rerunning *latex again to resolve cross-
2774 references, etc. The default value covers all normal cases.
2775
2776 (Note that the "etc" covers a lot of cases where one run of *la‐
2777 tex generates files to be read in on a later run.)
2778
2779 $MSWin_back_slash [1]
2780 This configuration variable only has an effect when latexmk is
2781 running under MS-Windows. With the default value of 1 for this
2782 variable, when a command is executed under MS-Windows, latexmk
2783 substitutes "\" for the separator character between components
2784 of a directory name. Internally, latexmk uses "/" for the di‐
2785 rectory separator character, which is the character used by
2786 Unix-like systems.
2787
2788 For almost all programs and for almost all filenames under MS-
2789 Windows, both "\" and "/" are acceptable as the directory sepa‐
2790 rator character, provided at least that filenames are properly
2791 quoted. But it is possible that programs exist that only accept
2792 "\" on the command line, since that is the standard directory
2793 separator for MS-Windows. So for safety latexmk makes the sub‐
2794 stitution from "/" to "\", by default.
2795
2796 However there are also programs on MS-Windows for which a back
2797 slash "\" is interpreted differently than as a directory separa‐
2798 tor; for these the directory separator should be "/". Programs
2799 with this behavior include all the *latex programs in the
2800 TeXLive implementation (but not the MiKTeX implementation).
2801 Hence if you use TeXLive on MS-Windows, then $MSWin_back_slash
2802 should be set to zero.
2803
2804
2805 $new_viewer_always [0]
2806 This variable applies to latexmk only in continuous-preview
2807 mode. If $new_viewer_always is 0, latexmk will check for a pre‐
2808 viously running previewer on the same file, and if one is run‐
2809 ning will not start a new one. If $new_viewer_always is non-
2810 zero, this check will be skipped, and latexmk will behave as if
2811 no viewer is running.
2812
2813 $out_dir [""]
2814 If non-blank, this variable specifies the directory in which
2815 output files are to be written by a run of *latex. See also the
2816 variable $aux_dir.
2817
2818 The effect of this variable (when non-blank) is achieved by us‐
2819 ing the -output-directory option of *latex. This exists in the
2820 usual current (Dec. 2011 and later) implementations of TeX,
2821 i.e., MiKTeX and TeXLive. But it may not be present in other
2822 versions.
2823
2824 If you also use the -cd option, and $out_dir (or $aux_dir) con‐
2825 tains a relative path, then the path is interpreted relative to
2826 the document directory.
2827
2828 Commonly, the directory specified for output files is a subdi‐
2829 rectory of the current working directory. However, if you spec‐
2830 ify some other directory, e.g., "/tmp/foo" or "../output", be
2831 aware that this could cause problems, e.g., with makeindex or
2832 bibtex. This is because modern versions of these programs, by
2833 default, will refuse to work when they find that they are asked
2834 to write to a file in a directory that appears not to be the
2835 current working directory or one of its subdirectories. This is
2836 part of security measures by the whole TeX system that try to
2837 prevent malicious or errant TeX documents from incorrectly mess‐
2838 ing with a user's files. If for $out_dir or $aux_dir you really
2839 do need to specify an absolute pathname (e.g., "/tmp/foo") or a
2840 path (e.g., "../output") that includes a higher-level directory,
2841 and you need to use makeindex or bibtex, then you need to dis‐
2842 able the security measures (and assume any risks). One way of
2843 doing this is to temporarily set an operating system environment
2844 variable openout_any to "a" (as in "all"), to override the de‐
2845 fault "paranoid" setting.
2846
2847 $pdf_mode [0]
2848 If zero, do NOT generate a pdf version of the document. If
2849 equal to 1, generate a pdf version of the document using pdfla‐
2850 tex, using the command specified by the $pdflatex variable. If
2851 equal to 2, generate a pdf version of the document from the ps
2852 file, by using the command specified by the $ps2pdf variable.
2853 If equal to 3, generate a pdf version of the document from the
2854 dvi file, by using the command specified by the $dvipdf vari‐
2855 able. If equal to 4, generate a pdf version of the document us‐
2856 ing lualatex, using the command specified by the $lualatex vari‐
2857 able. If equal to 5, generate a pdf version (and an xdv ver‐
2858 sion) of the document using xelatex, using the commands speci‐
2859 fied by the $xelatex and xdvipdfmx variables.
2860
2861 In $pdf_mode=2, it is ensured that .dvi and .ps files are also
2862 made. In $pdf_mode=3, it is ensured that a .dvi file is also
2863 made. But this may be overridden by the document.
2864
2865 $pdflatex ["pdflatex %O %S"]
2866 Specifies the command line for the LaTeX processing program in a
2867 version that makes a pdf file instead of a dvi file.
2868
2869 An example use of this variable is to add certain options to the
2870 command line for the program, e.g.,
2871
2872 $pdflatex = "pdflatex --shell-escape %O %S";
2873
2874 (In some earlier versions of latexmk, you needed to use an as‐
2875 signment to $pdflatex to allow the use of lualatex or xelatex
2876 instead of pdflatex. There are now separate configuration vari‐
2877 ables for the use of lualatex or xelatex. See $lualatex and
2878 $xelatex.)
2879
2880 To do a coordinated setting of all of $latex, $pdflatex, $luala‐
2881 tex, and $xelatex, see the section "Advanced Configuration".
2882
2883 %pdflatex_input_extensions
2884 This variable specifies the extensions tried by latexmk when it
2885 finds that a pdflatex run resulted in an error that a file has
2886 not been found, and the file is given without an extension.
2887 This typically happens when LaTeX commands of the form \in‐
2888 put{file} or \includegraphics{figure}, when the relevant source
2889 file does not exist.
2890
2891 In this situation, latexmk searches for custom dependencies to
2892 make the missing file(s), but restricts it to the extensions
2893 specified by the variable %pdflatex_input_extensions. The de‐
2894 fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
2895
2896 See details of the %latex_input_extensions for other information
2897 that equally applies to %pdflatex_input_extensions.
2898
2899 $pdflatex_silent_switch ["-interaction=batchmode"]
2900 Switch(es) for the pdflatex program (specified in the variable
2901 $pdflatex) when silent mode is on.
2902
2903 See details of the $latex_silent_switch for other information
2904 that equally applies to $pdflatex_silent_switch.
2905
2906 $pdf_previewer ["start acroread %O %S"]
2907 The command to invoke a pdf-previewer.
2908
2909 On MS-Windows, the default is changed to "cmd /c start """; un‐
2910 der more recent versions of Windows, this will cause to be run
2911 whatever command the system has associated with .pdf files. But
2912 this may be undesirable if this association is to acroread --
2913 see the notes in the explanation of the -pvc option.]
2914
2915 On OS-X the default is changed to "open %S", which results in
2916 OS-X starting up (and detaching) the viewer associated with the
2917 file. By default, for pdf files this association is to OS-X's
2918 preview, which is quite satisfactory.
2919
2920 WARNING: Problem under MS-Windows: if acroread is used as the
2921 pdf previewer, and it is actually viewing a pdf file, the pdf
2922 file cannot be updated. Thus makes acroread a bad choice of
2923 previewer if you use latexmk's previous-continuous mode (option
2924 -pvc) under MS-windows. This problem does not occur if, for ex‐
2925 ample, SumatraPDF or gsview is used to view pdf files.
2926
2927 Important note: Normally you will want to have a previewer run
2928 detached, so that latexmk doesn't wait for the previewer to ter‐
2929 minate before continuing its work. So normally you should pre‐
2930 fix the command by "start ", which flags to latexmk that it
2931 should do the detaching of the previewer itself (by whatever
2932 method is appropriate to the operating system). But sometimes
2933 letting latexmk do the detaching is not appropriate (for a vari‐
2934 ety of non-trivial reasons), so you should put the "start " bit
2935 in yourself, whenever it is needed.
2936
2937 $pdf_update_command [""]
2938 When the pdf previewer is set to be updated by running a com‐
2939 mand, this is the command that is run. See the information for
2940 the variable $pdf_update_method.
2941
2942 $pdf_update_method [1 under UNIX, 3 under MS-Windows]
2943 How the pdf viewer updates its display when the pdf file has
2944 changed. See the information on the variable $dvi_update_method
2945 for the codes. (Note that information needs be changed slightly
2946 so that for the value 4, to run a command to do the update, the
2947 command is specified by the variable $pdf_update_command, and
2948 for the value 2, to specify update by signal, the signal is
2949 specified by $pdf_update_signal.)
2950
2951 Note that acroread under MS-Windows (but not UNIX) locks the pdf
2952 file, so the default value is then 3.
2953
2954 Arranging to use a command to get a previewer explicitly updated
2955 requires three variables to be set. For example:
2956
2957 $pdf_previewer = "start xpdf -remote %R %O %S";
2958 $pdf_update_method = 4;
2959 $pdf_update_command = "xpdf -remote %R -reload";
2960
2961 The first setting arranges for the xpdf program to be used in
2962 its "remote server mode", with the server name specified as the
2963 rootname of the TeX file. The second setting arranges for up‐
2964 dating to be done in response to a command, and the third set‐
2965 ting sets the update command.
2966
2967 $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent
2968 value]
2969 The number of the signal that is sent to the pdf viewer when it
2970 is updated by sending a signal -- see the information on the
2971 variable $pdf_update_method. The default value is the one ap‐
2972 propriate for gv on a UNIX system.
2973
2974 $pid_position[1 under UNIX, -1 under MS-Windows]
2975 The variable $pid_position is used to specify which word in
2976 lines of the output from $pscmd corresponds to the process ID.
2977 The first word in the line is numbered 0. The default value of
2978 1 (2nd word in line) is correct for Solaris 2.6, Linux, and OS-X
2979 with their default settings of $pscmd.
2980
2981 Setting the variable to -1 is used to indicate that $pscmd is
2982 not to be used.
2983
2984 $postscript_mode [0]
2985 If nonzero, generate a postscript version of the document.
2986 Equivalent to the -ps option.
2987
2988 If some other request is made for which a postscript file is
2989 needed, then $postscript_mode will be set to 1.
2990
2991 $pre_tex_code ['']
2992
2993 Sets TeX code to be executed before inputting the source file.
2994 This works if the relevant one of $latex, etc contains a suit‐
2995 able command line with a %P or %U substitution. For example you
2996 could do
2997
2998 $latex = 'latex %O %P';
2999 $pre_tex_code = '\AtBeginDocument{An initial message\par}';
3000
3001 To set all of $latex, $pdflatex, $lualatex, and $xelatex you
3002 could use the subroutine alt_tex_cmds:
3003
3004 &alt_tex_cmds;
3005 $pre_tex_code = '\AtBeginDocument{An initial message\par}';
3006
3007
3008
3009 $preview_continuous_mode [0]
3010 If nonzero, run a previewer to view the document, and continue
3011 running latexmk to keep .dvi up-to-date. Equivalent to the -pvc
3012 option. Which previewer is run depends on the other settings,
3013 see the command line options -view=, and the variable $view.
3014
3015 $preview_mode [0]
3016 If nonzero, run a previewer to preview the document. Equivalent
3017 to the -pv option. Which previewer is run depends on the other
3018 settings, see the command line options -view=, and the variable
3019 $view.
3020
3021 $printout_mode [0]
3022 If nonzero, print the document using the command specified in
3023 the $lpr variable. Equivalent to the -p option. This is recom‐
3024 mended not to be set from an RC file, otherwise you could waste
3025 lots of paper.
3026
3027 $print_type = ["auto"]
3028 Type of file to printout: possibilities are "auto", "dvi",
3029 "none", "pdf", or "ps". See the option -print= for the meaning
3030 of the "auto" value.
3031
3032 $pscmd Command used to get all the processes currently run by the user.
3033 The -pvc option uses the command specified by the variable
3034 $pscmd to determine if there is an already running previewer,
3035 and to find the process ID (needed if latexmk needs to signal
3036 the previewer about file changes).
3037
3038 Each line of the output of this command is assumed to correspond
3039 to one process. See the $pid_position variable for how the
3040 process number is determined.
3041
3042 The default for pscmd is "NONE" under MS-Windows and cygwin
3043 (i.e., the command is not used), "ps -ww -u $ENV{USER}" under
3044 OS-X, and "ps -f -u $ENV{USER}" under other operating systems
3045 (including Linux). In these specifications "$ENV{USER}" is sub‐
3046 stituted by the username.
3047
3048 $ps2pdf ["ps2pdf -dALLOWPSTRANSPARENCY %O %S %D"]
3049 Command to convert .ps to .pdf file.
3050
3051 $ps_filter [empty]
3052 The postscript file filter to be run on the newly produced post‐
3053 script file before other processing. Equivalent to specifying
3054 the -pF option.
3055
3056 $ps_previewer ["start gv %O %S", but start %O %S under MS-Windows]
3057 The command to invoke a ps-previewer. (The default under MS-
3058 Windows will cause to be run whatever command the system has as‐
3059 sociated with .ps files.)
3060
3061 Note that gv could be used with the -watch option updates its
3062 display whenever the postscript file changes, whereas ghostview
3063 does not. However, different versions of gv have slightly dif‐
3064 ferent ways of writing this option. You can configure this
3065 variable appropriately.
3066
3067 WARNING: Linux systems may have installed one (or more) versions
3068 of gv under different names, e.g., ggv, kghostview, etc, but
3069 perhaps not one actually called gv.
3070
3071 Important note: Normally you will want to have a previewer run
3072 detached, so that latexmk doesn't wait for the previewer to ter‐
3073 minate before continuing its work. So normally you should pre‐
3074 fix the command by "start ", which flags to latexmk that it
3075 should do the detaching of the previewer itself (by whatever
3076 method is appropriate to the operating system). But sometimes
3077 letting latexmk do the detaching is not appropriate (for a vari‐
3078 ety of non-trivial reasons), so you should put the "start " bit
3079 in yourself, whenever it is needed.
3080
3081
3082 $ps_previewer_landscape ["start gv -swap %O %S", but start %O %S under
3083 MS-Windows]
3084 The command to invoke a ps-previewer in landscape mode.
3085
3086 $ps_update_command [""]
3087 When the postscript previewer is set to be updated by running a
3088 command, this is the command that is run. See the information
3089 for the variable $ps_update_method.
3090
3091 $ps_update_method [0 under UNIX, 1 under MS-Windows]
3092 How the postscript viewer updates its display when the .ps file
3093 has changed. See the information on the variable $dvi_up‐
3094 date_method for the codes. (Note that information needs be
3095 changed slightly so that for the value 4, to run a command to do
3096 the update, the command is specified by the variable $ps_up‐
3097 date_command, and for the value 2, to specify update by signal,
3098 the signal is specified by $ps_update_signal.)
3099
3100 $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent
3101 value]
3102 The number of the signal that is sent to the pdf viewer when it
3103 is updated by sending a signal -- see $ps_update_method. The
3104 default value is the one appropriate for gv on a UNIX system.
3105
3106 $pvc_timeout [0]
3107 If this variable is nonzero, there will be a timeout in pvc
3108 mode after a period of inactivity. Inactivity means a period
3109 when latexmk has detected no file changes and hence has not
3110 taken any actions like compiling the document. The period of in‐
3111 activity is in the variable $pvc_timeout_mins.
3112
3113
3114 $pvc_timeout_mins [30]
3115 The period of inactivity, in minutes, after which pvc mode times
3116 out. This is used if $pvc_timeout is nonzero.
3117
3118 $pvc_view_file_via_temporary [1]
3119 The same as $always_view_file_via_temporary, except that it only
3120 applies in preview-continuous mode (-pvc option).
3121
3122 $quote_filenames [1]
3123 This specifies whether substitutions for placeholders in command
3124 specifications (as in $pdflatex) are surrounded by double
3125 quotes. If this variable is 1 (or any other value Perl regards
3126 as true), then quoting is done. Otherwise quoting is omitted.
3127
3128 The quoting method used by latexmk is tested to work correctly
3129 under UNIX systems (including Linux and Mac OS-X) and under MS-
3130 Windows. It allows the use of filenames containing special
3131 characters, notably spaces. (But note that many versions of
3132 *latex cannot correctly deal with TeX files whose names contain
3133 spaces. Latexmk's quoting only ensures that such filenames are
3134 correctly treated by the operating system in passing arguments
3135 to programs.)
3136
3137 $rc_report [1]
3138 After initialization, whether to give a list of the RC files
3139 read.
3140
3141 $recorder [1]
3142 Whether to use the -recorder option to (latex Use of this option
3143 results in a file of extension .fls containing a list of the
3144 files that these programs have read and written. Latexmk will
3145 then use this file to improve its detection of source files and
3146 generated files after a run of *latex.
3147
3148 It is generally recommended to use this option (or to configure
3149 the $recorder variable to be on.) But it only works if *latex
3150 supports the -recorder option, which is true for most current
3151 implementations
3152
3153 Note about the name of the .fls file: Most implementations of
3154 *latex produce an .fls file with the same basename as the main
3155 document's LaTeX, e.g., for Document.tex, the .fls file is Docu‐
3156 ment.fls. However, some implementations instead produce files
3157 named for the program, i.e., latex.fls or pdflatex.fls. In this
3158 second case, latexmk copies the latex.fls or pdflatex.fls to a
3159 file with the basename of the main LaTeX document, e.g., Docu‐
3160 ment.fls.
3161
3162 $search_path_separator [See below for default]
3163 The character separating paths in the environment variables TEX‐
3164 INPUTS, BIBINPUTS, and BSTINPUTS. This variable is mainly used
3165 by latexmk when the -outdir, -output-directory, -auxdir, and/or
3166 -aux-directory options are used. In that case latexmk needs to
3167 communicate appropriately modified search paths to bibtex,
3168 dvipdf, dvips, and *latex.
3169
3170 [Comment to technically savvy readers: *latex doesn't actually
3171 need the modified search path. But, surprisingly, dvipdf and
3172 dvips do, because sometimes graphics files get generated in the
3173 output or aux directories.]
3174
3175 The default under MSWin and Cygwin is ';' and under UNIX-like
3176 operating systems (including Linux and OS-X) is ':'. Normally
3177 the defaults give correct behavior. But there can be difficul‐
3178 ties if your operating system is of one kind, but some of your
3179 software is running under an emulator for the other kind of op‐
3180 erating system; in that case you'll need to find out what is
3181 needed, and set $search_path_separator explicitly. (The same
3182 goes, of course, for unusual operating systems that are not in
3183 the MSWin, Linux, OS-X, Unix collection.)
3184
3185 $show_time [0]
3186 Whether to show CPU time used.
3187
3188 $silence_logfile_warnings [0]
3189 Whether after a run of *latex to summarize warnings in the log
3190 file about undefined citations and references. Setting $si‐
3191 lence_logfile_warnings=0 gives the summary of warnings (provided
3192 silent mode isn't also set), and this is useful to locate unde‐
3193 fined citations and references without searching through the
3194 much more verbose log file or the screen output of *latex. But
3195 the summary can also be excessively annoying. The default is
3196 not to give these warnings. The command line options -si‐
3197 lence_logfile_warning_list and -silence_logfile_warning_list-
3198 also set this variable.
3199
3200 Note that multiple occurrences for the same undefined object on
3201 the same page and same line will be compressed to a single warn‐
3202 ing.
3203
3204 $silent [0]
3205 Whether to run silently. Setting $silent to 1 has the same ef‐
3206 fect as the -quiet of -silent options on the command line.
3207
3208 $sleep_time [2]
3209 The time to sleep (in seconds) between checking for source file
3210 changes when running with the -pvc option. This is subject to a
3211 minimum of one second delay, except that zero delay is also al‐
3212 lowed.
3213
3214 A value of exactly 0 gives no delay, and typically results in
3215 100% CPU usage, which may not be desirable.
3216
3217 $texfile_search [""]
3218 This is an obsolete variable, replaced by the @default_files
3219 variable.
3220
3221 For backward compatibility, if you choose to set $tex‐
3222 file_search, it is a string of space-separated filenames, and
3223 then latexmk replaces @default_files with the filenames in $tex‐
3224 file_search to which is added "*.tex".
3225
3226 $success_cmd [undefined]
3227 See the documentation for $compiling_cmd.
3228
3229 $tmpdir [See below for default]
3230 Directory to store temporary files that latexmk may generate
3231 while running.
3232
3233 The default under MSWindows (including cygwin), is to set $tm‐
3234 pdir to the value of the first of whichever of the system envi‐
3235 ronment variables TMPDIR or TEMP exists, otherwise to the cur‐
3236 rent directory. Under other operating systems (expected to be
3237 UNIX/Linux, including OS-X), the default is the value of the
3238 system environment variable TMPDIR if it exists, otherwise
3239 "/tmp".
3240
3241 $use_make_for_missing_files [0]
3242 Whether to use make to try and make files that are missing after
3243 a run of *latex, and for which a custom dependency has not been
3244 found. This is generally useful only when latexmk is used as
3245 part of a bigger project which is built by using the make pro‐
3246 gram.
3247
3248 Note that once a missing file has been made, no further calls to
3249 make will be made on a subsequent run of latexmk to update the
3250 file. Handling this problem is the job of a suitably defined
3251 Makefile. See the section "USING latexmk WITH make" for how to
3252 do this. The intent of calling make from latexmk is merely to
3253 detect dependencies.
3254
3255 $view ["default"]
3256 Which kind of file is to be previewed if a previewer is used.
3257 The possible values are "default", "dvi", "ps", "pdf". The
3258 value of "default" means that the "highest" of the kinds of file
3259 generated is to be used (among .dvi, .ps and .pdf).
3260
3261
3262 $warnings_as_errors [0]
3263 Normally latexmk copies the behavior of latex in treating unde‐
3264 fined references and citations and multiply defined references
3265 as conditions that give a warning but not an error. The vari‐
3266 able $warnings_as_errors controls whether this behavior is modi‐
3267 fied.
3268
3269 When the variable is non-zero, latexmk at the end of its run
3270 will return a non-zero status code to the operating system if
3271 any of the files processed gives a warning about problems with
3272 citations or references (i.e., undefined citations or references
3273 or multiply defined references). This is after latexmk has com‐
3274 pleted all the runs it needs to try and resolve references and
3275 citations. Thus $warnings_as_errors being nonzero causes la‐
3276 texmk to treat such warnings as errors, but only when they occur
3277 on the last run of *latex and only after processing is complete.
3278 A non-zero value $warnings_as_errors can be set by the command-
3279 line option -Werror.
3280
3281 The default behavior is normally satisfactory in the usual edit-
3282 compile-edit cycle. But, for example, latexmk can also be used
3283 as part of a build process for some bigger project, e.g., for
3284 creating documentation in the build of a software application.
3285 Then it is often sensible to treat citation and reference warn‐
3286 ings as errors that require the overall build process to be
3287 aborted. Of course, since multiple runs of *latex are generally
3288 needed to resolve references and citations, what matters is not
3289 the warnings on the first run, but the warnings on the last run;
3290 latexmk takes this into account appropriately.
3291
3292 In addition, when preview-continuous mode is used, a non-zero
3293 value for $warnings_as_errors changes the use of the commands
3294 $failure_cmd, $warning_cmd, and $success_cmd after a complia‐
3295 tion. If there are citation or reference warnings, but no other
3296 errors, the behavior is as follows. If $warning_cmd is set, it
3297 is used. If it is not set, then then if $warnings_as_errors is
3298 non-zero and $failure_cmd is set, then $failure_cmd. Otherwise
3299 $success_cmd is used, if it is set. (The foregoing explanation
3300 is rather complicated, because latexmk has to deal with the case
3301 that one or more of the commands isn't set.)
3302
3303
3304 $xdvipdfmx ["xdvipdfmx -E -o %D %O %S"]
3305
3306 The program to make a pdf file from an xdv file (used in con‐
3307 junction with xelatex when $pdf_mode=5).
3308
3309 $xdvipdfmx_silent_switch ["-q"]
3310 Switch(es) for the xdvipdfmx program when silent mode is on.
3311
3312 $xelatex ["xelatex %O %S"]
3313 Specifies the command line for the LaTeX processing program of
3314 when the xelatex program is called for. See the documentation
3315 of the -xelatex option for some special properties of latexmk's
3316 use of xelatex.
3317
3318 Note about xelatex: latexmk uses xelatex to make an .xdv rather
3319 than .pdf file, with the .pdf file being created in a separate
3320 step. This is enforced by the use of the -no-pdf option. If %O
3321 is part of the command for invoking xelatex, then latexmk will
3322 insert the -no-pdf option automatically, otherwise you must pro‐
3323 vide the option yourself. See the documentation for the -pdfxe
3324 option for why latexmk makes a .xdv file rather than a .pdf file
3325 when xelatex is used.
3326
3327 To do a coordinated setting of all of $latex, $pdflatex, $luala‐
3328 tex, and $xelatex, see the section "Advanced Configuration".
3329
3330
3331 %xelatex_input_extensions
3332 This variable specifies the extensions tried by latexmk when it
3333 finds that an xelatex run resulted in an error that a file has
3334 not been found, and the file is given without an extension.
3335 This typically happens when LaTeX commands of the form \in‐
3336 put{file} or \includegraphics{figure}, when the relevant source
3337 file does not exist.
3338
3339 In this situation, latexmk searches for custom dependencies to
3340 make the missing file(s), but restricts it to the extensions
3341 specified by the variable %xelatex_input_extensions. The de‐
3342 fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
3343
3344 See details of the %latex_input_extensions for other information
3345 that equally applies to %xelatex_input_extensions.
3346
3347 $xelatex_silent_switch ["-interaction=batchmode"]
3348 Switch(es) for the xelatex program (specified in the variable
3349 $xelatex) when silent mode is on.
3350
3351 See details of the $latex_silent_switch for other information
3352 that equally applies to $xelatex_silent_switch.
3353
3354
3355
3356
3358 In any RC file a set of custom dependencies can be set up to convert a
3359 file with one extension to a file with another. An example use of this
3360 would be to allow latexmk to convert a .fig file to .eps to be included
3361 in the .tex file.
3362
3363
3364 Defining a custom dependency:
3365 The old method of configuring latexmk to use a custom dependency was to
3366 directly manipulate the @cus_dep_list array that contains information
3367 defining the custom dependencies. (See the section "Old Method of
3368 Defining Custom Dependencies" for details.) This method still works,
3369 but is no longer preferred.
3370
3371 A better method is to use the subroutines that allow convenient manipu‐
3372 lations of the custom dependency list. These are
3373
3374 add_cus_dep( fromextension, toextension, must, subroutine )
3375 remove_cus_dep( fromextension, toextension )
3376 show_cus_dep()
3377
3378 The arguments are as follows:
3379
3380 from extension:
3381 The extension of the file we are converting from (e.g. "fig").
3382 It is specified without a period.
3383
3384 to extension:
3385 The extension of the file we are converting to (e.g. "eps"). It
3386 is specified without a period.
3387
3388 must: If non-zero, the file from which we are converting must exist,
3389 if it doesn't exist latexmk will give an error message and exit
3390 unless the -f option is specified. If must is zero and the file
3391 we are converting from doesn't exist, then no action is taken.
3392 Generally, the appropriate value of must is zero.
3393
3394 function:
3395 The name of the subroutine that latexmk should call to perform
3396 the file conversion. The first argument to the subroutine is
3397 the base name of the file to be converted without any extension.
3398 The subroutines are declared in the syntax of Perl. The func‐
3399 tion should return 0 if it was successful and a nonzero number
3400 if it failed.
3401
3402
3403 Naturally add_cus_dep adds a custom dependency with the specified from
3404 and to extensions. If a custom dependency has been previously defined
3405 (e.g., in an rcfile that was read earlier), then it is replaced by the
3406 new one.
3407
3408 The subroutine remove_cus_dep removes the specified custom dependency.
3409 The subroutine show_cus_dep causes a list of the currently defined cus‐
3410 tom dependencies to be sent to the screen output.
3411
3412
3413 How custom dependencies are used:
3414 An instance of a custom dependency rule is created whenever latexmk de‐
3415 tects that a run of *latex needs to read a file, like a graphics file,
3416 whose extension is the to-extension of a custom dependency. Then la‐
3417 texmk examines whether a file exists with the same name, but with the
3418 corresponding from-extension, as specified in the custom-dependency.
3419 If it does, then a corresponding instance of the custom dependency is
3420 created, after which the rule is invoked whenever the destination file
3421 (the one with the to-extension) is out-of-date with respect to the cor‐
3422 responding source file.
3423
3424 To make the new destination file, the Perl subroutine specified in the
3425 rule is invoked, with an argument that is the base name of the files in
3426 question. Simple cases just involve a subroutine invoking an external
3427 program; this can be done by following the templates below, even by
3428 those without knowledge of the Perl programming language. Of course,
3429 experts could do something much more elaborate.
3430
3431 One item in the specification of each custom-dependency rule, labeled
3432 "must" above, specifies how the rule should be applied when the source
3433 file fails to exist.
3434
3435 When latex reports that an input file (e.g., a graphics file) does not
3436 exist, latexmk tries to find a source file and a custom dependency that
3437 can be used to make it. If it succeeds, then it creates an instance of
3438 the custom dependency and invokes it to make the missing file, after
3439 which the next pass of latex etc will be able to read the newly created
3440 file.
3441
3442 Note for advanced usage: The operating system's environment variable
3443 TEXINPUTS can be used to specify a search path for finding files by la‐
3444 tex etc. Correspondingly, when a missing file is reported, latexmk
3445 looks in the directories specified in TEXINPUTS as well as in the cur‐
3446 rent directory, to find a source file from which an instance of a cus‐
3447 tom dependency can be used to make the missing file.
3448
3449
3450 Function to implement custom dependency, traditional method:
3451 The function that implements a custom dependency gets the information
3452 on the files to be processed in two ways. The first is through its one
3453 argument; the argument contains the base name of the source and desti‐
3454 nation files. The second way is described later.
3455
3456 A simple and typical example of code in an initialization rcfile using
3457 the first method is:
3458
3459 add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
3460 sub fig2eps {
3461 system( "fig2dev -Leps \"$_[0].fig\" \"$_[0].eps\"" );
3462 }
3463
3464 The first line adds a custom dependency that converts a file with ex‐
3465 tension "fig", as created by the xfig program, to an encapsulated post‐
3466 script file, with extension "eps". The remaining lines define a sub‐
3467 routine that carries out the conversion. If a rule for converting
3468 "fig" to "eps" files already exists (e.g., from a previously read-in
3469 initialization file), the latexmk will delete this rule before making
3470 the new one.
3471
3472 Suppose latexmk is using this rule to convert a file "figure.fig" to
3473 "figure.eps". Then it will invoke the fig2eps subroutine defined in
3474 the above code with a single argument "figure", which is the basename
3475 of each of the files (possibly with a path component). This argument
3476 is referred to by Perl as $_[0]. In the example above, the subroutine
3477 uses the Perl command system to invoke the program fig2dev. The double
3478 quotes around the string are a Perl idiom that signify that each string
3479 of the form of a variable name, $_[0] in this case, is to be substi‐
3480 tuted by its value.
3481
3482 If the return value of the subroutine is non-zero, then latexmk will
3483 assume an error occurred during the execution of the subroutine. In
3484 the above example, no explicit return value is given, and instead the
3485 return value is the value returned by the last (and only) statement,
3486 i.e., the invocation of system, which returns the value 0 on success.
3487
3488 If you use pdflatex, lualatex or xelatex instead of latex, then you
3489 will probably prefer to convert your graphics files to pdf format, in
3490 which case you would replace the above code in an initialization file
3491 by
3492
3493 add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
3494 sub fig2pdf {
3495 system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
3496 }
3497
3498 Note 1: In the command lines given in the system commands in the above
3499 examples, double quotes have been inserted around the file names (im‐
3500 plemented by '\"' in the Perl language). They immunize the running of
3501 the program against special characters in filenames. Very often these
3502 quotes are not necessary, i.e., they can be omitted. But it is nor‐
3503 mally safer to keep them in. Even though the rules for quoting vary
3504 between operating systems, command shells and individual pieces of
3505 software, the quotes in the above examples do not cause problems in the
3506 cases I have tested.
3507
3508 Note 2: One case in which the quotes are important is when the files
3509 are in a subdirectory and your operating system is Microsoft Windows.
3510 Then the separator character for directory components can be either a
3511 forward slash '/' or Microsoft's more usual backward slash '\'. For‐
3512 ward slashes are generated by latexmk, to maintain its sanity from
3513 software like MiKTeX that mixes both directory separators; but their
3514 correct use normally requires quoted filenames. (See a log file from a
3515 run of MiKTeX (at least in v. 2.9) for an example of the use of both
3516 directory separators.)
3517
3518 Note 3: The subroutines implementing custom dependencies in the exam‐
3519 ples given just have a single line invoking an external program.
3520 That's the usual situation. But since the subroutines are in the Perl
3521 language, you can implement much more complicated processing if you
3522 need it.
3523
3524
3525 Removing custom dependencies, and when you might need to do this:
3526 If you have some general custom dependencies defined in the system or
3527 user initialization file, you may find that for a particular project
3528 they are undesirable. So you might want to delete the unneeded ones.
3529 A situation where this would be desirable is where there are multiple
3530 custom dependencies with the same from-extension or the same to-exten‐
3531 sion. In that case, latexmk might choose a different one from the one
3532 you want for a specific project. As an example, to remove any "fig" to
3533 "eps" rule you would use:
3534
3535 remove_cus_dep( 'fig', 'eps' );
3536
3537 If you have complicated sets of custom dependencies, you may want to
3538 get a listing of the custom dependencies. This is done by using the
3539 line
3540
3541 show_cus_dep();
3542
3543 in an initialization file.
3544
3545
3546 Function implementing custom dependency, alternative methods:
3547 So far the examples for functions to implement custom dependencies have
3548 used the argument of the function to specify the base name of converted
3549 file. This method has been available since very old versions of la‐
3550 texmk, and many examples can be found, e.g., on the web.
3551
3552 However in later versions of latexmk the internal structure of the im‐
3553 plementation of its "rules" for the steps of processing, including cus‐
3554 tom dependencies, became much more powerful. The function implementing
3555 a custom dependency is executed within a special context where a number
3556 of extra variables and subroutines are defined. Publicly documented
3557 ones, intended to be long-term stable, are listed below, under the
3558 heading "Variables and subroutines for processing a rule".
3559
3560 Examples of their use is given in the following examples, concerning
3561 multiple index files and glossaries.
3562
3563 The only index-file conversion built-in to latexmk is from an ".idx"
3564 file written on one run of *latex to an ".ind" file to be read in on a
3565 subsequent run. But with the index.sty package, for example, you can
3566 create extra indexes with extensions that you configure. Latexmk does
3567 not know how to deduce the extensions from the information it has. But
3568 you can easily write a custom dependency. For example if your latex
3569 file uses the command "\newindex{special}{ndx}{nnd}{Special index}" you
3570 will need to get latexmk to convert files with the extension .ndx to
3571 .nnd. The most elementary method is to define a custom dependency as
3572 follows:
3573
3574 add_cus_dep( 'ndx', 'nnd', 0, 'ndx2nnd' );
3575 sub ndx2nnd {
3576 return system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" );
3577 }
3578 push @generated_exts, 'ndx', 'nnd';
3579
3580 Notice the added line compared with earlier examples. The extra line
3581 gets the extensions "ndx" and "nnd" added to the list of extensions for
3582 generated files; then the extra index files will be deleted by clean-up
3583 operations
3584
3585 But if you have yet more indexes with yet different extensions, e.g.,
3586 "adx" and "and", then you will need a separate function for each pair
3587 of extensions. This is quite annoying. You can use the Run_subst
3588 function to simplify the definitions to use a single function:
3589
3590 add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
3591 add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
3592 sub dx2nd {
3593 return Run_subst( "makeindex -o %D %S" );
3594 }
3595 push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
3596
3597 You could also instead use
3598
3599 add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
3600 add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
3601 sub dx2nd {
3602 return Run_subst( $makeindex );
3603 }
3604 push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
3605
3606 This last example uses the command specification in $makeindex, and so
3607 any customization you have made for the standard index also applies to
3608 your extra indexes.
3609
3610 Similar techniques can be applied for glossaries.
3611
3612 Those of you with experience with Makefiles, may get concerned that the
3613 .ndx file is written during a run of *latex and is always later than
3614 the .nnd last read in. Thus the .nnd appears to be perpetually out-of-
3615 date. This situation, of circular dependencies, is endemic to latex,
3616 and is one of the issues that latexmk is programmed to overcome. It
3617 examines the contents of the files (by use of a checksum), and only
3618 does a remake when the file contents have actually changed.
3619
3620 Of course if you choose to write random data to the .nnd (or the .aux
3621 file, etc) that changes on each new run, then you will have a problem.
3622 For real experts: See the %hash_calc_ignore_pattern if you have to deal
3623 with such problems.
3624
3625
3626 Old Method of Defining Custom Dependencies:
3627 In much older versions of latexmk, the only method of defining custom
3628 dependencies was to directly manipulate the table of custom dependen‐
3629 cies. This is contained in the @cus_dep_list array. It is an array of
3630 strings, and each string in the array has four items in it, each sepa‐
3631 rated by a space, the from-extension, the to-extension, the "must"
3632 item, and the name of the subroutine for the custom dependency. These
3633 were all defined above.
3634
3635 An example of the old method of defining custom dependencies is as fol‐
3636 lows. It is the code in an RC file to ensure automatic conversion of
3637 .fig files to .eps files:
3638
3639 push @cus_dep_list, "fig eps 0 fig2eps";
3640 sub fig2eps {
3641 return system( "fig2dev -Lps \"$_[0].fig\" \"$_[0].eps\"" );
3642 }
3643
3644 This method still works, and is almost equivalent to the code given
3645 earlier that used the add_cus_dep subroutine. However, the old method
3646 doesn't delete any previous custom-dependency for the same conversion.
3647 So the new method is preferable.
3648
3649
3650
3652 For most purposes, simple configuration for latexmk along the lines of
3653 the examples given is sufficient. But sometimes you need something
3654 harder. In this section, I indicate some extra possibilities. Gener‐
3655 ally to use these, you need to be fluent in the Perl language, since
3656 this is what is used in the rc files.
3657
3658 See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See also the
3659 examples in the directory example_rcfiles in the latexmk distributions.
3660 Even if none of the examples apply to your case, they may give you use‐
3661 ful ideas
3662
3663
3664 Utility subroutines
3665 ensure_path( var, values ...)
3666
3667 The first parameter is the name of one of the system's environ‐
3668 ment variables for search paths. The remaining parameters are
3669 values that should be in the variable. For each of the value
3670 parameters, if it isn't already in the variable, then it is
3671 prepended to the variable; in that case the environment variable
3672 is created if it doesn't already exist. For separating values,
3673 the character appropriate the the operating system is used --
3674 see the configuration variable $search_path_separator.
3675
3676 Example:
3677
3678 ensure_path( 'TEXINPUTS', './custom_cls_sty_files//' );
3679
3680 (In this example, the trailing '//' is documented by TeX systems
3681 to mean that *latex search for files in the specified directory
3682 and in all subdirectories.)
3683
3684 Technically ensure_path works by setting Perl's variable
3685 $ENV{var}, where var is the name of the target variable. The
3686 changed value is then passed as an environment variable to any
3687 invoked programs.
3688
3689
3690 Variables and subroutines for processing a rule
3691 A step in the processing is called a rule. One possibility to implement
3692 the processing of a rule is by a Perl subroutine. This is always the
3693 case for custom dependencies. Also, for any other rule, you can use a
3694 subroutine by prefixing the command specification by the word "inter‐
3695 nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
3696
3697 When you use a subroutine for processing a rule, all the possibilities
3698 of Perl programming are available, of course. In addition, some of la‐
3699 texmk's internal variables and subroutines are available. The ones
3700 listed below are intended to be available to (advanced) users, and
3701 their specifications will generally have stability under upgrades. Gen‐
3702 erally, the variables should be treated as read-only: Changing their
3703 values can have bad consequences, since it is liable to mess up the
3704 consistency of what latexmk is doing.
3705
3706 $rule This variable has the name of the rule, as known to latexmk.
3707 Note that the exact contents of this variable for a given rule
3708 may be dependent on the version of latexmk
3709
3710 $$Psource
3711 This gives the name of the primary source file. Note the double
3712 dollar signs.
3713
3714 $$Pdest
3715 This gives the name of the main output file if any. Note the
3716 double dollar signs.
3717
3718 rdb_ensure_file( $rule, file )
3719 This a subroutine that ensures that the given file is among the
3720 source files for the specified rule. It is typically used when,
3721 during the processing of a rule, it is known that a particular
3722 extra file is among the dependencies that latexmk should know,
3723 but its default methods don't find the dependency. Almost always
3724 the first argument is the name of the rule currently being pro‐
3725 cessed, so it is then appropriate to specify it by $rule.
3726
3727 For examples of its use, see some of the files in the directory
3728 example_rcfiles of latexmk's distribution. Currently the cases
3729 that use this subroutine are bib2gls-latexmkrc, exceltex_la‐
3730 texmkrc and texinfo-latexmkrc. These illustrate typical cases
3731 where latexmk's normal processing fails to detect certain extra
3732 source files.
3733
3734 rdb_remove_files( $rule, file, ... )
3735 This subroutine removes one or more files from the dependency
3736 list for the given rule.
3737
3738 rdb_list_source( $rule )
3739 This subroutine returns the list of source files (i.e., the de‐
3740 pendency list) for the given rule.
3741
3742 rdb_set_source( $rule, file, ... )
3743
3744 rdb_set_source( $rule, @files )
3745 This subroutine sets the dependency list for the given rule to
3746 be the specified files. Files that are already in the list have
3747 unchanged information. Files that were not in the list are
3748 added to it. Files in the previous dependency list that are not
3749 in the newly specified list of files are removed from the depen‐
3750 dency list.
3751
3752 Run_subst( command_spec )
3753 This subroutine runs the command specified by command_spec. The
3754 specification is a string in the format listed in the section
3755 "Format of Command Specifications". An important action of the
3756 Run_subst is to make substitutions of placeholders, e.g., %S and
3757 %D for source and destination files; these get substituted be‐
3758 fore the command is run. In addition, the command after substi‐
3759 tution is printed to the screen unless latexmk is running in
3760 silent mode.
3761
3762
3763 Coordinated Setting of Commands for *latex
3764 To set all of $latex, $pdflatex, $lualatex, and $xelatex to a common
3765 pattern, you can use one of the following subroutines, std_tex_cmds,
3766 alt_tex_cmds, and set_tex_cmds.
3767
3768 They work as follows
3769
3770 &std_tex_cmds;
3771
3772 This results in $latex = 'latex %O %S', and similarly for $pdflatex,
3773 $lualatex, and $xelatex. Note the ampersand in the invocation; this
3774 indicates to Perl that a subroutine is being called.
3775
3776 &alt_tex_cmds;
3777
3778 This results in $latex = 'latex %O %P', and similarly for $pdflatex,
3779 $lualatex, and $xelatex. Note the ampersand in the invocation; this
3780 indicates to Perl that a subroutine is being called.
3781
3782 set_tex_cmds( CMD_SPEC );
3783
3784 Here CMD_SPEC is the command line without the program name. This re‐
3785 sults in $latex = 'CMD_SPEC', and similarly for $pdflatex, $lualatex,
3786 and $xelatex. An example would be
3787
3788 set_tex_cmds( '--interaction=batchmode %O %S' );
3789
3790
3791 Advanced configuration: Using latexmk with make
3792 This section is targeted only at advanced users who use the make pro‐
3793 gram for complex projects, as for software development, with the depen‐
3794 dencies specified by a Makefile.
3795
3796 Now the basic task of latexmk is to run the appropriate programs to
3797 make a viewable version of a LaTeX document. However, the usual make
3798 program is not suited to this purpose for at least two reasons. First
3799 is that the use of LaTeX involves circular dependencies (e.g., via .aux
3800 files), and these cannot be handled by the standard make program. Sec‐
3801 ond is that in a large document the set of source files can change
3802 quite frequently, particularly with included graphics files; in this
3803 situation keeping a Makefile manually updated is inappropriate and er‐
3804 ror-prone, especially when the dependencies can be determined automati‐
3805 cally. Latexmk solves both of these problems robustly.
3806
3807 Thus for many standard LaTeX documents latexmk can be used by itself
3808 without the make program. In a complex project it simply needs to be
3809 suitably configured. A standard configuration would be to define cus‐
3810 tom dependencies to make graphics files from their source files (e.g.,
3811 as created by the xfig program). Custom dependencies are latexmk's
3812 equivalent of pattern rules in Makefiles.
3813
3814 Nevertheless there are projects for which a Makefile is appropriate,
3815 and it is useful to know how to use latexmk from a Makefile. A typical
3816 example would be to generate documentation for a software project. Po‐
3817 tentially the interaction with the rest of the rules in the Makefile
3818 could be quite complicated, for example if some of the source files for
3819 a LaTeX document are generated by the project's software.
3820
3821 In this section, I give a couple of examples of how latexmk can be use‐
3822 fully invoked from a Makefile. The examples use specific features of
3823 current versions of GNU make, which is the default on both linux and
3824 OS-X systems. They may need modifications for other versions of make.
3825
3826 The simplest method is simply to delegate all the relevant tasks to la‐
3827 texmk, as is suitable for a straightforward LaTeX document. For this a
3828 suitable Makefile is like
3829
3830 .PHONY : FORCE_MAKE
3831 all : try.pdf
3832 %.pdf : %.tex FORCE_MAKE
3833 latexmk -pdf -dvi- -ps- $<
3834
3835 (Note: the last line must be introduced by a tab for the Makefile to
3836 function correctly!) Naturally, if making try.pdf from its associated
3837 LaTeX file try.tex were the only task to be performed, a direct use of
3838 latexmk without a Makefile would normally be better. The benefit of
3839 using a Makefile for a LaTeX document would be in a larger project,
3840 where lines such as the above would be only be a small part of a larger
3841 Makefile.
3842
3843 The above example has a pattern rule for making a .pdf file from a .tex
3844 file, and it is defined to use latexmk in the obvious way. There is a
3845 conventional default target named "all", with a prerequisite of
3846 try.pdf. So when make is invoked, by default it makes try.pdf. The
3847 only complication is that there may be many source files beyond
3848 try.tex, but these aren't specified in the Makefile, so changes in them
3849 will not by themselves cause latexmk to be invoked. Instead, the pat‐
3850 tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
3851 the effect of causing the rule to be always out-of-date, so that la‐
3852 texmk is always run. It is latexmk that decides whether any action is
3853 needed, e.g., a rerun of pdflatex. Effectively the Makefile delegates
3854 all decisions to latexmk, while make has no knowledge of the list of
3855 source files except for primary LaTeX file for the document. If there
3856 are, for example, graphics files to be made, these must be made by cus‐
3857 tom dependencies configured in latexmk.
3858
3859 But something better is needed in more complicated situations, for ex‐
3860 ample, when the making of graphics files needs to be specified by rules
3861 in the Makefile. To do this, one can use a Makefile like the follow‐
3862 ing:
3863
3864 TARGETS = document1.pdf document2.pdf
3865 DEPS_DIR = .deps
3866 LATEXMK = latexmk -recorder -use-make -deps \
3867 -e 'warn qq(In Makefile, turn off custom dependencies\n);' \
3868 -e '@cus_dep_list = ();' \
3869 -e 'show_cus_dep();'
3870 all : $(TARGETS)
3871 $(foreach file,$(TARGETS),$(eval -include $(DEPS_DIR)/$(file)P))
3872 $(DEPS_DIR) :
3873 mkdir $@
3874 %.pdf : %.tex
3875 if [ ! -e $(DEPS_DIR) ]; then mkdir $(DEPS_DIR); fi
3876 $(LATEXMK) -pdf -dvi- -ps- -deps-out=$(DEPS_DIR)/$@P $<
3877 %.pdf : %.fig
3878 fig2dev -Lpdf $< $@
3879
3880 (Again, the lines containing the commands for the rules should be
3881 started with tabs.) This example was inspired by how GNU automake han‐
3882 dles automatic dependency tracking of C source files.
3883
3884 After each run of latexmk, dependency information is put in a file in
3885 the .deps subdirectory. The Makefile causes these dependency files to
3886 be read by make, which now has the full dependency information for each
3887 target .pdf file. To make things less trivial it is specificed that
3888 two files document1.pdf and document2.pdf are the targets. The depen‐
3889 dency files are .deps/document1.pdfP and .deps/document2.pdfP.
3890
3891 There is now no need for the phony prerequisite for the rule to make
3892 .pdf files from .tex files. But I have added a rule to make .pdf files
3893 from .fig files produced by the xfig program; these are commonly used
3894 for graphics insertions in LaTeX documents. Latexmk is arranged to
3895 output a dependency file after each run. It is given the -recorder op‐
3896 tion, which improves its detection of files generated during a run of
3897 pdflatex; such files should not be in the dependency list. The -e op‐
3898 tions are used to turn off all custom dependencies, and to document
3899 this. Instead the -use-make is used to delegate the making of missing
3900 files to make itself.
3901
3902 Suppose in the LaTeX file there is a command \includegraphics{graph},
3903 and an xfig file "graph.fig" exists. On a first run, pdflatex reports
3904 a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
3905 by calling "make graph.pdf", and after completion of its work, it lists
3906 "fig.pdf" among the dependents of the file latexmk is making. Then let
3907 "fig.fig" be updated, and then let make be run. Make first remakes
3908 "fig.pdf", and only then reruns latexmk.
3909
3910 Thus we now have a method by which all the subsidiary processing is
3911 delegated to make.
3912
3913
3915 latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
3916
3918 Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
3919 its creation is started but before the file is complete. Work around:
3920 manually refresh (or reopen) display. Or use one of the other preview‐
3921 ers and update methods.
3922
3923 (The following isn't really a bug, but concerns features of preview‐
3924 ers.) Preview continuous mode only works perfectly with certain pre‐
3925 viewers: Xdvi on UNIX/Linux works for dvi files. Gv on UNIX/Linux
3926 works for both postscript and pdf. Ghostview on UNIX/Linux needs a
3927 manual update (reopen); it views postscript and pdf. Gsview under MS-
3928 Windows works for both postscript and pdf, but only reads the updated
3929 file when its screen is refreshed. Acroread under UNIX/Linux views
3930 pdf, but the file needs to be closed and reopened to view an updated
3931 version. Under MS-Windows, acroread locks its input file and so the
3932 pdf file cannot be updated. (Remedy: configure latexmk to use suma‐
3933 trapdf instead.)
3934
3936 Authors of previous versions. Many users with their feedback, and es‐
3937 pecially David Coppit (username david at node coppit.org) who made many
3938 useful suggestions that contributed to version 3, and Herbert Schulz.
3939 (Please note that the e-mail addresses are not written in their stan‐
3940 dard form to avoid being harvested too easily.)
3941
3943 Current version, by John Collins (Version 4.76). Report bugs etc to
3944 his e-mail (jcc8 at psu.edu).
3945
3946 Released version can be obtained from CTAN:
3947 <http://www.ctan.org/pkg/latexmk/>, and from the author's website
3948 <http://www.personal.psu.edu/jcc8/latexmk/>.
3949 Modifications and enhancements by Evan McLean (Version 2.0)
3950 Original script called "go" by David J. Musliner (RCS Version 3.2)
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963 20 November 2021 LATEXMK(1)