LATEXMK(1) General Commands Manual LATEXMK(1) NAME latexmk - generate LaTeX document SYNOPSIS latexmk [options] [file ...] DESCRIPTION Latexmk completely automates the process of compiling a LaTeX document. Essentially, it is like a specialized relative of the general make utility, but one which determines dependencies automatically and has some other very useful features. In its basic mode of operation la- texmk is given the name of the primary source file for a document, and it issues the appropriate sequence of commands to generate a .dvi, .ps, .pdf and/or hardcopy version of the document. By default latexmk will run the commands necessary to generate a .dvi file, which copies the behavior of earlier versions when only latex was available. Latexmk can also be set to run continuously with a suitable previewer. In that case the latex program (or one of its relatives), etc, are re- run whenever one of the source files is modified, and the previewer au- tomatically updates the on-screen view of the compiled document. Latexmk determines which are the source files by examining the log file. (Optionally, it also examines the list of input and output files generated by the -recorder option of modern versions of latex (and pdflatex, xelatex, lualatex). See the documentation for the -recorder option of latexmk below.) When latexmk is run, it examines properties of the source files, and if any have been changed since the last docu- ment generation, latexmk will run the various LaTeX processing programs as necessary. In particular, it will repeat the run of latex (or a re- lated program)) often enough to resolve all cross references; depending on the macro packages used. With some macro packages and document classes, four, or even more, runs may be needed. If necessary, latexmk will also run bibtex, biber, and/or makeindex. In addition, latexmk can be configured to generate other necessary files. For example, from an updated figure file it can automatically generate a file in encapsu- lated postscript or another suitable format for reading by LaTeX. Latexmk has two different previewing options. With the simple -pv op- tion, a dvi, postscript or pdf previewer is automatically run after generating the dvi, postscript or pdf version of the document. The type of file to view is selected according to configuration settings and command line options. The second previewing option is the powerful -pvc option (mnemonic: "preview continuously"). In this case, latexmk runs continuously, reg- ularly monitoring all the source files to see if any have changed. Ev- ery time a change is detected, latexmk runs all the programs necessary to generate a new version of the document. A good previewer will then automatically update its display. Thus the user can simply edit a file and, when the changes are written to disk, latexmk completely automates the cycle of updating the .dvi (and/or the .ps and .pdf) file, and 4 April 2023 1 LATEXMK(1) General Commands Manual LATEXMK(1) refreshing the previewer's display. It's not quite WYSIWYG, but use- fully close. For other previewers, the user may have to manually make the previewer update its display, which can be (e.g., with some versions of xdvi and gsview) as simple as forcing a redraw of its display. Latexmk has the ability to print a banner in gray diagonally across each page when making the postscript file. It can also, if needed, call an external program to do other postprocessing on generated dvi and postscript files. (See the options -dF and -pF, and the documenta- tion for the $dvi_filter and $ps_filter configuration variables.) These capabilities are leftover from older versions of latexmk, but are currently non-functional. More flexibility can be obtained in current versions, since the command strings for running *latex can now be con- figured to run multiple commands. This also extends the possibility of postprocessing generated files. Latexmk is highly configurable, both from the command line and in con- figuration files, so that it can accommodate a wide variety of user needs and system configurations. Default values are set according to the operating system, so latexmk often works without special configura- tion on MS-Windows, cygwin, Linux, OS-X, and other UNIX systems. See the section "Configuration/Initialization (rc) Files", and then the later sections "How to Set Variables in Initialization Files", "Format of Command Specifications", "List of Configuration Variables Usable in Initialization Files", "Custom Dependencies", and "Advanced Configura- tion" A very annoying complication handled very reliably by latexmk, is that LaTeX is a multiple pass system. On each run, LaTeX reads in informa- tion generated on a previous run, for things like cross referencing and indexing. In the simplest cases, a second run of LaTeX suffices, and often the log file contains a message about the need for another pass. However, there is a wide variety of add-on macro packages to LaTeX, with a variety of behaviors. The result is to break simple-minded de- terminations of how many runs are needed and of which programs. La- texmk has a highly general and efficient solution to these issues. The solution involves retaining between runs information on the source files, and a symptom is that latexmk generates an extra file (with ex- tension .fdb_latexmk, by default) that contains the source file infor- mation. LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE In general the command line to invoke latexmk has the form latexmk [options] [file] All options can be introduced by single or double "-" characters, e.g., "latexmk -help" or "latexmk --help". Note 1: In the documentation, '*latex' means any of the supported en- gines, i.e., currently latex, lualatex, pdflatex, xelatex. Mention of 4 April 2023 2 LATEXMK(1) General Commands Manual LATEXMK(1) a specific one of these normally refers that specific engines. Earlier versions of this documentation weren't so consistent. Which of these is used to compile a document, depends on the configuration and the command line arguments. Note 2: In addition to the options in the list below, latexmk recog- nizes almost all the options recognized by the *latex programs in their current TeXLive and MiKTeX implementations. Some of the options for these programs trigger special action or behavior by latexmk, in which case they have specific explanations in this document; in this case they may or may not be passed to *latex as well. Run latexmk with the -showextraoptions to get a list of the options that latexmk accepts and that are simply passed through to *latex. See also the explanation of the -showextraoptions option for more informa- tion. Definitions of options and arguments file One or more files can be specified. If no files are specified, latexmk will, by default, run on all files in the current work- ing directory with a ".tex" extension. This behavior can be changed: see the description concerning the @default_files vari- able in the section "List of configuration variables usable in initialization files". If a file is specified without an extension, then the ".tex" ex- tension is automatically added, just as LaTeX does. Thus, if you specify: latexmk foo then latexmk will operate on the file "foo.tex". There are certain restrictions on what characters can be in a filename; certain characters are either prohibited or problem- atic for the latex etc programs. These characters are: "$", "%", "\", "~", the double quote character, and the control char- acters null, tab, form feed, carriage return, line feed, and delete. In addition "&" is prohibited when it is the first character of a filename. Latexmk gives a fatal error when it detects any of the above characters in the TeX filename(s) specified on the command line. However before testing for illegal characters, latexmk removes matching pairs of double quotes from a filename. This matches the behavior of latex etc, and deals with problems that occa- sionally result from filenames that have been incorrectly quoted on the command line. In addition, under Microsoft Windows, the forward slash character "\" is a directory separator, so latexmk replaces it by a backward slash "/", which is also a legal di- rectory separator in Windows, and is accepted by latex etc. 4 April 2023 3 LATEXMK(1) General Commands Manual LATEXMK(1) -auxdir=FOO or -aux-directory=FOO Sets the directory for auxiliary output files of *latex (.aux, .log etc). These are all the generated files, with the excep- tion of final output files (.dvi, .ps, .pdf, .synctex.gz, .sync- tex). See the -outdir/-output-directory option for directories for the final output files. If the directory specified for the -aux/-aux-directory option is blank, then the default is used, which is to be the same as the output directory. If you also use the -cd option, and the specified auxiliary out- put directory is a relative path, then the path is interpreted relative to the document directory. See the section AUXILIARY AND OUTPUT DIRECTORIES for more de- tails. -bibtex When the source file uses bbl files for bibliography, run bibtex or biber as needed to regenerate the bbl files. This property can also be configured by setting the $bibtex_use variable to 2 in a configuration file. -bibtex- Never run bibtex or biber. Also, always treat .bbl files as precious, i.e., do not delete them in a cleanup operation. A common use for this option is when a document comes from an external source, complete with its bbl file(s), and the user does not have the corresponding bib files available. In this situation use of the -bibtex- option will prevent latexmk from trying to run bibtex or biber, which would result in overwriting of the bbl files. This property can also be configured by setting the $bibtex_use variable to 0 in a configuration file. -bibtex-cond When the source file uses a bbl file for the bibliography and bibtex is used to generate the bibliography, run bibtex as needed to regenerate the bbl files only if the relevant bib file(s) exist. Thus when the bib file(s) are not available, bibtex is not run, thereby avoiding overwriting of the bbl file. Also, always treat .bbl files as precious, i.e., do not delete them in a cleanup operation. This is the default setting. It can also be configured by set- ting the $bibtex_use variable to 1 in a configuration file. 4 April 2023 4 LATEXMK(1) General Commands Manual LATEXMK(1) The reason for using this setting is first to allow automatic switching between the use and non-use of bibtex depending on the existence or not of a bib file. In addition, when submitting articles to a scientific journal, it is common to submit only .tex and .bbl files (plus graphics files), but not a .bib file. Hence it is often useful to treat .bbl files as true source files, that should be preserved under a clean up operation. This property can also be configured by setting the $bibtex_use variable to 1 in a configuration file. Note that when biber is used, and a bib file doesn't exist, this option does not currently prevent biber from being run. See the documentation on $bibtex_use for more details. However, a bbl file is treated as precious. -bibtex-cond1 The same as -bibtex-cond except that .bbl files are only treated as precious if one or more bibfiles fails to exist. Thus if all the bib files exist, bibtex is run to generate .bbl files as needed, and then it is appropriate to delete the bbl files in a cleanup operation since they can be re-generated. This property can also be configured by setting the $bibtex_use variable to 1.5 in a configuration file. Note that when biber is used, and a bib file doesn't exist, this option does not currently prevent biber from being run. See the documentation on $bibtex_use for more details. -bibtexfudge or -bibfudge Turn on the change-directory fudge for bibtex. See documenta- tion of $bibtex_fudge for details. -bibtexfudge- or -bibfudge- Turn off the change-directory fudge for bibtex. See documenta- tion of $bibtex_fudge for details. -bm A banner message to print diagonally across each page when con- verting the dvi file to postscript. The message must be a sin- gle argument on the command line so be careful with quoting spa- ces and such. Note that if the -bm option is specified, the -ps option is as- sumed. 4 April 2023 5 LATEXMK(1) General Commands Manual LATEXMK(1) -bi How dark to print the banner message. A decimal number between 0 and 1. 0 is black and 1 is white. The default is 0.95, which is OK unless your toner cartridge is getting low. -bs A decimal number that specifies how large the banner message will be printed. Experimentation is necessary to get the right scale for your message, as a rule of thumb the scale should be about equal to 1100 divided by the number of characters in the message. The default is 220.0 which is just right for 5 charac- ter messages. -commands List the commands used by latexmk for processing files, and then exit. -c Clean up (remove) all regeneratable files generated by latex and bibtex or biber except dvi, postscript and pdf. These files are a combination of log files, aux files, latexmk's database file of source file information, and those with extensions specified in the @generated_exts configuration variable. In addition, files specified by the $clean_ext and @generated_exts configura- tion variables are removed. This cleanup is instead of a regular make. See the -gg option if you want to do a cleanup followed by a make. Treatment of .bbl files: If $bibtex_use is set to 0 or 1, bbl files are always treated as non-regeneratable. If $bibtex_use is set to 1.5, bbl files are counted as non-regeneratable condi- tionally: If the bib file exists, then bbl files are regenerat- able, and are deleted in a clean up. But if $bibtex_use is 1.5 and a bib file doesn't exist, then the bbl files are treated as non-regeneratable and hence are not deleted. In contrast, if $bibtex_use is set to 2, bbl files are always treated as regeneratable, and are deleted in a cleanup. Treatment of files generated by custom dependencies: If $cleanup_includes_cusdep_generated is nonzero, regeneratable files are considered as including those generated by custom de- pendencies and are also deleted. Otherwise these files are not deleted. -C Clean up (remove) all regeneratable files generated by latex and bibtex or biber. This is the same as the -c option with the ad- dition of dvi, postscript and pdf files, and those specified in the $clean_full_ext configuration variable. 4 April 2023 6 LATEXMK(1) General Commands Manual LATEXMK(1) This cleanup is instead of a regular make. See the -gg option if you want to do a cleanup followed by a make. See the -c option for the specification of whether or not .bbl files are treated as non-regeneratable or regeneratable. If $cleanup_includes_cusdep_generated is nonzero, regeneratable files are considered as including those generated by custom de- pendencies and are also deleted. Otherwise these files are not deleted. -CA (Obsolete). Now equivalent to the -C option. See that option for details. -cd Change to the directory containing the main source file before processing it. Then all the generated files (.aux, .log, .dvi, .pdf, etc) will be relative to the source file. This option is particularly useful when latexmk is invoked from a GUI configured to invoke latexmk with a full pathname for the source file. This option works by setting the $do_cd configuration variable to one; you can set that variable if you want to configure la- texmk to have the effect of the -cd option without specifying it on the command line. See the documentation for that variable. -cd- Do NOT change to the directory containing the main source file before processing it. Then all the generated files (.aux, .log, .dvi, .pdf, etc) will be relative to the current directory rather than the source file. This is the default behavior and corresponds to the behavior of the *latex programs. However, it is not desirable behavior when latexmk is invoked by a GUI configured to invoke latexmk with a full pathname for the source file. See the -cd option. This option works by setting the $do_cd configuration variable to zero. See the documentation for that variable for more in- formation. -CF Remove the file containing the database of source file informa- tion, before doing the other actions requested. -d Set draft mode. This prints the banner message "DRAFT" across your page when converting the dvi file to postscript. Size and intensity can be modified with the -bs and -bi options. The -bm option will override this option as this is really just a short way of specifying: 4 April 2023 7 LATEXMK(1) General Commands Manual LATEXMK(1) latexmk -bm DRAFT Note that if the -d option is specified, the -ps option is as- sumed. -deps Show a list of dependent files after processing. This is in the form of a dependency list of the form used by the make program, and it is therefore suitable for use in a Makefile. It gives an overall view of the files without listing intermediate files, as well as latexmk can determine them. By default the list of dependent files is sent to stdout (i.e., normally to the screen unless you've redirected latexmk's out- put). But you can set the filename where the list is sent by the -deps-out= option. See the section "USING latexmk WITH make" for an example of how to use a dependency list with make. Users familiar with GNU automake and gcc will find that the -deps option is very similar in its purpose and results to the -M option to gcc. (In fact, latexmk also has options -M, -MF, and -MP options that behave like those of gcc.) -dependents Equivalent to -deps. -deps- Do not show a list of dependent files after processing. (This is the default.) -dependents- Equivalent to -deps-. -deps-escape= Set the kind of escaping used for spaces in the dependency list. The possible values are "none", "unix", "nmake", corresponding respectively to no escaping, escaping with a "\" suitable for standard Unix make, and escaping with "^", suitable for Micro- soft's nmake. -deps-out=FILENAME Set the filename to which the list of dependent files is writ- ten. If the FILENAME argument is omitted or set to "-", then the output is sent to stdout. Use of this option also turns on the output of the list of de- pendent files after processing. 4 April 2023 8 LATEXMK(1) General Commands Manual LATEXMK(1) -dF Dvi file filtering. The argument to this option is a filter which will generate a filtered dvi file with the extension ".dviF". All extra processing (e.g. conversion to postscript, preview, printing) will then be performed on this filtered dvi file. Example usage: To use dviselect to select only the even pages of the dvi file: latexmk -dF "dviselect even" foo.tex -diagnostics Print detailed diagnostics during a run. This may help for de- bugging problems or to understand latexmk's behavior in diffi- cult situations. -dir-report For each .tex file processed, list the settings for aux and out directories, after they have been normalized from the settings specified during initialization. See the description of the variable $aux_out_dir_report for more details. -dir-report- Do not report the settings for aux and out directories. (De- fault) -dvi Generate dvi version of document using latex. -dvilua Generate dvi version of document using lualatex instead of la- tex. -dvi- Turn off generation of dvi version of document. (This may get overridden, if some other file is made (e.g., a .ps file) that is generated from the dvi file, or if no generated file at all is requested.) -dvilualatex="COMMAND" This sets the string specifying the command to run dvi lualatex. It behaves like the -pdflatex option, but sets the variable $dvilualatex. Note: This option when provided with the COMMAND argument only sets the command for invoking dvilualatex; it does not turn on the use of dvilualatex. That is done by other options or in an initialization file. 4 April 2023 9 LATEXMK(1) General Commands Manual LATEXMK(1) -e Execute the specified initialization code before processing. The code is Perl code of the same form as is used in latexmk's initialization files. For more details, see the information on the -r option, and the section about "Configuration/initializa- tion (RC) files". The code is typically a sequence of assign- ment statements separated by semicolons. The code is executed when the -e option is encountered during latexmk's parsing of its command line. See the -r option for a way of executing initialization code from a file. An error re- sults in latexmk stopping. Multiple instances of the -r and -e options can be used, and they are executed in the order they ap- pear on the command line. Some care is needed to deal with proper quoting of special char- acters in the code on the command line. For example, suppose you want to set the latex command to use its -shell-escape op- tion, then under UNIX/Linux you could use the line latexmk -e '$latex=q/latex %O -shell-escape %S/' file.tex Note that the single quotes block normal UNIX/Linux command shells from treating the characters inside the quotes as spe- cial. (In this example, the q/.../ construct is a Perl idiom equivalent to using single quotes. This avoids the complica- tions of getting a quote character inside an already quoted string in a way that is independent of both the shell and the operating-system.) The above command line will NOT work under MS-Windows with cmd.exe or command.com or 4nt.exe. For MS-Windows with these command shells you could use latexmk -e "$latex=q/latex %O -shell-escape %S/" file.tex or latexmk -e "$latex='latex %O -shell-escape %S'" file.tex The last two examples will NOT work with UNIX/Linux command shells. (Note: the above examples show are to show how to use the -e to specify initialization code to be executed. But the particular effect can be achieved also by the use of the -latex option with less problems in dealing with quoting.) -emulate-aux-dir Emulate the use of an aux directory instead of leaving it to the *latex programs to do it. (MiKTeX supports -aux-directory, but TeXLive doesn't.) 4 April 2023 10 LATEXMK(1) General Commands Manual LATEXMK(1) See the section AUXILIARY AND OUTPUT DIRECTORIES for more de- tails. -emulate-aux-dir- Turn off emulation to implement an aux directory and leave it to the *latex program to handle the case that the aux directory is different from the output directory. Note that if you use TeXLive, which doesn't support -aux-directory, latexmk will au- tomatically switch aux_dir emulation on after the first run of *latex, because it will find the .log file in the wrong place. -f Force latexmk to continue document processing despite errors. Normally, when latexmk detects that LaTeX or another program has found an error which will not be resolved by further processing, no further processing is carried out. Note: "Further processing" means the running of other programs or the rerunning of latex (etc) that would be done if no errors had occurred. If instead, or additionally, you want the latex (etc) program not to pause for user input after an error, you should arrange this by an option that is passed to the program, e.g., by latexmk's option -interaction=nonstopmode (which la- texmk passes to *latex). -f- Turn off the forced processing-past-errors such as is set by the -f option. This could be used to override a setting in a con- figuration file. -g Force latexmk to process document fully, even under situations where latexmk would normally decide that no changes in the source files have occurred since the previous run. This option is useful, for example, if you change some options and wish to reprocess the files. -g- Turn off -g. -gg "Super go mode" or "clean make": clean out generated files as if -C had been given, and then do a regular make. -h or-non-help Print help information. -jobname=STRING Set the basename of output files(s) to STRING, instead of the default, which is the basename of the specified TeX file. (At present, STRING should not contain spaces.) 4 April 2023 11 LATEXMK(1) General Commands Manual LATEXMK(1) This is like the same option for current implementations of the *latex, and the passing of this option to these programs is part of latexmk's implementation of -jobname. There is one enhancement, that the STRING may contain the place- holder '%A'. This will be substituted by the basename of the TeX file. The primary purpose is when multiple files are specified on the command line to latexmk, and you wish to use a jobname with a different file-dependent value for each file. For exam- ple, suppose you had .tex files test1.tex and test2.tex, and you wished to compare the results of compilation by *latex and those with xelatex. Then under a unix-type operating system you could use the command line latexmk -pdf -jobname=%A-pdflatex *.tex latexmk -pdfxe -jobname=%A-xelatex *.tex Then the .aux, .log, and .pdf files from the use of pdflatex would have basenames test1-pdflatex and test2-pdflatex, while from xelatex, the basenames would be test1-xelatex and test2-xe- latex. Under MS-Windows with cmd.exe, you would need to double the per- cent sign, so that the percent character is passed to latexmk rather than being used to substitute an environment variable: latexmk -pdf -jobname=%%A-pdflatex *.tex latexmk -pdfxe -jobname=%%A-xelatex *.tex -l Run in landscape mode, using the landscape mode for the preview- ers and the dvi to postscript converters. This option is not normally needed nowadays, since current previewers normally de- termine this information automatically. -l- Turn off -l. -latex This sets the generation of dvi files by latex, and turns off the generation of pdf and ps files. Note: to set the command used when latex is specified, see the -latex="COMMAND" option. -latex="COMMAND" This sets the string specifying the command to run latex, and is typically used to add desired options. Since the string nor- mally contains spaces, it should be quoted, e.g., latexmk -latex="latex --shell-escape %O %S" foo.tex The specification of the contents of the string are the same as 4 April 2023 12 LATEXMK(1) General Commands Manual LATEXMK(1) for the $latex configuration variable. Depending on your oper- ating system and the command-line shell you are using, you may need to change the single quotes to double quotes (or something else). Note: This option when provided with the COMMAND argument only sets the command for invoking latex; it does not turn on the use of latex. That is done by other options or in an initialization file. To set the command for running pdflatex (rather than the command for latex) see the -pdflatex option. -logfilewarninglist -logfilewarnings After a run of *latex, give a list of warnings about undefined citations and references (unless silent mode is on). See also the $silence_logfile_warnings configuration variable. -logfilewarninglist- -logfilewarnings- After a run of *latex, do not give a list of warnings about undefined citations and references. (Default) See also the $silence_logfile_warnings configuration variable. -lualatex Use lualatex. That is, use lualatex to process the source file(s) to pdf. The generation of dvi and postscript files is turned off. This option is equivalent to using the following set of options -pdflua -dvi- -ps- (Note: Note that the method of implementation of this option, but not its intended effect, differ from some earlier versions of latexmk.) -lualatex="COMMAND" This sets the string specifying the command to run lualatex. It behaves like the -pdflatex option, but sets the variable $luala- tex. Note: This option when provided with the COMMAND argument only sets the command for invoking lualatex; it does not turn on the use of lualatex. That is done by other options or in an initial- ization file. 4 April 2023 13 LATEXMK(1) General Commands Manual LATEXMK(1) -M Show list of dependent files after processing. This is equiva- lent to the -deps option. -MF file If a list of dependents is made, the -MF specifies the file to write it to. -MP If a list of dependents is made, include a phony target for each source file. If you use the dependents list in a Makefile, the dummy rules work around errors the program make gives if you re- move header files without updating the Makefile to match. -makeindexfudge Turn on the change-directory fudge for makeindex. See documen- tation of $makeindex_fudge for details. -makeindexfudge- Turn off the change-directory fudge for makeindex. See documen- tation of $makeindex_fudge for details. -MSWinBackSlash This option only has an effect when latexmk is running under MS- Windows. This is that when latexmk runs a command under MS-Win- dows, the Windows standard directory separator "\" is used to separate directory components in a file name. Internally, la- texmk uses "/" for the directory separator character, which is the character used by Unix-like systems. This is the default behavior. However the default may have been overridden by a configuration file (latexmkrc file) which sets $MSWin_back_slash=0. -MSWinBackSlash- This option only has an effect when latexmk is running under MS- Windows. This is that when latexmk runs a command under MS-Win- dows, the substitution of "\" for the separator character be- tween directory components of a file name is not done. Instead the forward slash "/" is used, the same as on Unix-like systems. This is acceptable in most situations under MS-Windows, provided that filenames are properly quoted, as latexmk does by default. See the documentation for the configuration variable $MSWin_back_slash for more details. -new-viewer When in continuous-preview mode, always start a new viewer to view the generated file. By default, latexmk will, in 4 April 2023 14 LATEXMK(1) General Commands Manual LATEXMK(1) continuous-preview mode, test for a previously running previewer for the same file and not start a new one if a previous pre- viewer is running. However, its test sometimes fails (notably if there is an already-running previewer that is viewing a file of the same name as the current file, but in a different direc- tory). This option turns off the default behavior. -new-viewer- The inverse of the -new-viewer option. It puts latexmk in its normal behavior that in preview-continuous mode it checks for an already-running previewer. -nobibtex Never run bibtex or biber. Equivalent to the -bibtex- option. -nobibtexfudge or -nobibfudge Turn off the change-directory fudge for bibtex. See documenta- tion of $bibtex_fudge for details. -noemulate-aux-dir Turn aux_dir emulation off. Same as -emulate-aux-dir-. -nomakeindexfudge Turn off the change-directory fudge for makeindex. See documen- tation of $makeindex_fudge for details. -norc Turn off the automatic reading of initialization (rc) files. N.B. Normally the initialization files are read and obeyed, and then command line options are obeyed in the order they are en- countered. But -norc is an exception to this rule: it is acted on first, no matter where it occurs on the command line. -outdir=FOO or -output-directory=FOO Sets the directory for the output files of *latex. If the aux directory is not set or is the same as the output di- rectory, then all output files of *latex are sent to the output directory. If the aux directory is set, e.g., by the option -auxdir, and is not equal to the output directory, then only final output files (.dvi, .ps, .pdf, .synctex, .synctex.gz) are sent to the output directory. Other generated files are sent to the aux directory. See the section AUXILIARY AND OUTPUT DIRECTORIES for more 4 April 2023 15 LATEXMK(1) General Commands Manual LATEXMK(1) details. -output-format=FORMAT This option is one that is allowed for latex, lualatex, and pdflatex. But it is not passed to these programs. Instead la- texmk emulates it in a way suitable for the context of latexmk and its workflows. If FORMAT is dvi, then dvi output is turned on, and postscript and pdf output are turned off. This is equivalent to using the options -dvi -ps- -pdf-. If FORMAT is pdf, then pdf output is turned on, and dvi and postscript output are turned off. This is equivalent to using the options -pdf -ps- -dvi-. If FORMAT is anything else, latexmk gives an error. -p Print out the document. By default the file to be printed is the first in the list postscript, pdf, dvi that is being made. But you can use the -print=... option to change the type of file to be printed, and you can configure this in a start up file (by setting the $print_type variable). However, printing is enabled by default only under UNIX/Linux systems, where the default is to use the lpr command and only on postscript files. In general, the correct behavior for printing very much depends on your system's software. In particular, un- der MS-Windows you must have suitable program(s) available, and you must have configured the print commands used by latexmk. This can be non-trivial. See the documentation on the $lpr, $lpr_dvi, and $lpr_pdf configuration variables to see how to set the commands for printing. This option is incompatible with the -pv and -pvc options, so it turns them off. -pdf Generate pdf version of document using pdflatex. (If you wish to use lualatex or xelatex, you can use whichever of the options -pdflua, -pdfxe, -lualatex or -xelatex applies.) To configure latexmk to have such behavior by default, see the section on "Configuration/initialization (rc) files". -pdfdvi Generate dvi file and then pdf version of document from the dvi file, by default using dvipdf. The program used to compile the document to dvi is latex by de- fault, but this can be changed to dvilulatex by the use of the -dvilua option or by setting $dvi_mode to 2. 4 April 2023 16 LATEXMK(1) General Commands Manual LATEXMK(1) -pdflua Generate pdf version of document using lualatex. -pdfps Generate dvi file, ps file from the dvi file, and then pdf file from the ps file. The program used to compile the document to dvi is latex by de- fault, but this can be changed to dvilulatex by the use of the -dvilua option or by setting $dvi_mode to 2. -pdfxe Generate pdf version of document using xelatex. Note that to optimize processing time, latexmk uses xelatex to generate an .xdv file rather than a pdf file directly. Only after possibly multiple runs to generate a fully up-to-date .xdv file does la- texmk then call xdvipdfmx to generate the final .pdf file. (Note: The reason why latexmk arranges for xelatex to make an .xdv file instead of the xelatex's default of a .pdf file is as follows: When the document includes large graphics files, espe- cially .png files, the production of a .pdf file can be quite time consuming, even when the creation of the .xdv file by xela- tex is fast. So the use of the intermediate .xdv file can re- sult in substantial gains in procesing time, since the .pdf file is produced once rather than on every run of xelatex.) -pdf- Turn off generation of pdf version of document. (This can be used to override a setting in a configuration file. It may get overridden if some other option requires the generation of a pdf file.) If after all options have been processed, pdf generation is still turned off, then generation of a dvi file will be turned on, and then the program used to compiled a document will be la- tex (or, more precisely, whatever program is configured to be used in the $latex configuration variable). -pdflatex This sets the generation of pdf files by pdflatex, and turns off the generation of dvi and ps files. Note: to set the command used when pdflatex is specified, see the -pdflatex="COMMAND" option. -pdflatex="COMMAND" This sets the string specifying the command to run pdflatex, and is typically used to add desired options. Since the string nor- mally contains spaces, it should be quoted, e.g., latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S" 4 April 2023 17 LATEXMK(1) General Commands Manual LATEXMK(1) foo.tex The specification of the contents of the string are the same as for the $pdflatex configuration variable. (The option -pdflatex in fact sets the variable $pdflatex.) Depending on your operat- ing system and the command-line shell you are using, you may need to change the single quotes to double quotes (or something else). Note: This option when provided with the COMMAND argument only sets the command for invoking pdflatex; it does not turn on the use of pdflatex. That is done by other options or in an initial- ization file. To set the command for running latex (rather than the command for pdflatex) see the -latex option. -pdflualatex="COMMAND" Equivalent to -lualatex="COMMAND". -pdfxelatex="COMMAND" Equivalent to -xelatex="COMMAND". -pretex=CODE Given that CODE is some TeX code, this options sets that code to be executed before inputting source file. This only works if the command for invoking the relevant *latex is suitably config- ured. See the documentation of the variable $pre_tex_code, and the substitution strings %P and %U for more details. This op- tion works by setting the variable $pre_tex_code. See also the -usepretex option. An example: latexmk -pretex='\AtBeginDocument{Message\par}' -usepretex foo.tex But this is better written latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex If you already have a suitable command configured, you only need latexmk -pretex='\AtBeginDocument{Message\par}' foo.tex -print=dvi, -print=ps, -print=pdf, -print=auto, Define which kind of file is printed. This option also ensures that the requisite file is made, and turns on printing. 4 April 2023 18 LATEXMK(1) General Commands Manual LATEXMK(1) The (default) case -print=auto determines the kind of print file automatically from the set of files that is being made. The first in the list postscript, pdf, dvi that is among the files to be made is the one used for print out. -ps Generate postscript version of document. -ps- Turn off generation of postscript version of document. This can be used to override a setting in a configuration file. (It may get overridden by some other option that requires a postscript file, for example a request for printing.) -pF Postscript file filtering. The argument to this option is a filter which will generate a filtered postscript file with the extension ".psF". All extra processing (e.g. preview, printing) will then be performed on this filtered postscript file. Example of usage: Use psnup to print two pages on the one page: latexmk -ps -pF 'psnup -2' foo.tex or latexmk -ps -pF "psnup -2" foo.tex Whether to use single or double quotes round the "psnup -2" will depend on your command interpreter, as used by the particular version of perl and the operating system on your computer. -pv Run file previewer. If the -view option is used, that will se- lect the kind of file to be previewed (.pdf, .ps or .dvi). Oth- erwise the viewer views the "highest" kind of output file that is made, with the ordering being .pdf, .ps, .dvi (high to low). This option is incompatible with the -p and -pvc options, so it turns them off. -pv- Turn off -pv. -pvc Run a file previewer and continually update the .dvi, .ps, and/or .pdf files whenever changes are made to source files (see the Description above). Which of these files is generated and which is viewed is governed by the other options, and is the same as for the -pv option. The preview-continuous option -pvc can only work with one file. So in this case you will normally only specify one filename on the command line. It is also in- compatible with the -p and -pv options, so it turns these op- tions off. 4 April 2023 19 LATEXMK(1) General Commands Manual LATEXMK(1) The -pvc option also turns off force mode (-f), as is normally best for continuous preview mode. If you really want force mode, use the options in the order -pvc -f. With a good previewer the display will be automatically updated. (Under some but not all versions of UNIX/Linux "gv -watch" does this for postscript files; this can be set by a configuration variable. This would also work for pdf files except for an ap- parent bug in gv that causes an error when the newly updated pdf file is read.) Many other previewers will need a manual update. Important note: the acroread program on MS-Windows locks the pdf file, and prevents new versions being written, so it is a bad idea to use acroread to view pdf files in preview-continuous mode. It is better to use a different viewer: SumatraPDF and gsview are good possibilities. There are some other methods for arranging an update, notably useful for many versions of xdvi and xpdf. These are best set in latexmk's configuration; see below. Note that if latexmk dies or is stopped by the user, the "forked" previewer will continue to run. Successive invocations with the -pvc option will not fork new previewers, but latexmk will normally use the existing previewer. (At least this will happen when latexmk is running under an operating system where it knows how to determine whether an existing previewer is run- ning.) -pvc- Turn off -pvc. -pvctimeout Do timeout in pvc mode after period of inactivity, which is 30 min. by default. Inactivity means a period when latexmk has de- tected no file changes and hence has not taken any actions like compiling the document. -pvctimeout- Don't do timeout in pvc mode after inactivity. -pvctimeoutmins=