.TH LATEXMK 1L "24 November 2001" "" .SH NAME latexmk \- generate LaTeX document .SH SYNOPSIS .B latexmk [options] [file ...] .SH DESCRIPTION .I LatexMk completely automates the process of generating a LaTeX document. Essentially, it is a highly specialized relative of the general \fImake\fR utility. Given the source files for a document, \fIlatexmk\fR issues the appropriate sequence of commands to generate a .dvi, .ps, .pdf or hardcopy version of the document. It can also be set to run continuously with a previewer; the latex program, etc, are rerun whenever one of the source files is modified. .PP \fILatexmk\fR will normally determine which are the source files by examining the log file. It has an option to parse the TeX file instead --- see later. When \fIlatexmk\fR is run, it will examine the timestamps on the source files. If any of the source files have been changed since the last document generation, \fIlatexmk\fR will run the various LaTeX processing programs as necessary. In particular, it will repeat the run of LaTeX often enough to resolve all cross references; depending on the macro packages used. With some macro packages and document styles four, or even more, runs may be needed. .PP If the option \fB-lt\fR to scan the LaTeX file is used, the main LaTeX file and all included files (recursively) are scanned for LaTeX commands for including other TeX files and figure files. Then on subsequent runs, \fIlatexmk\fR with the \fB-lt\fR switch reads the dependency information from this file. If the dependencies of the document are changed (e.g., by adding or removing an \\input command), an additional pass of \fIlatexmk -i\fR or \fIlatexmk -I\fR will update the dependency file. .PP \fILatexmk\fR has two different previewing options. In the simple \fB-pv\fR option, a dvi, postscript or pdf previewer is automatically run after generating the dvi, postscript or pdf version of the document. The type of viewer is selected automatically depending on the \fB-ps\fR or \fB-pdf\fR option. .PP Particularly when a document is reaching the final stages of editing, it is often useful to have a previewer open continuously and have it update its display whenever changes are made to the source file(s). For this, \fIlatexmk\fR provides the powerful \fB-pvc\fR option (mnemonic: "preview continuously"). With this option, \fIlatexmk\fR runs a previewer for the document, and then \fIlatexmk\fR repeatedly monitors the source files of the document to see if any changes have been made since the last dependent file was produced. When changes are detected, \fIlatexmk\fR runs the appropriate LaTeX commands to regenerate the .dvi, .ps and/or .pdf files (depending on the which of the \fB-ps\fR and \fB-pdf\fR options was specified, the .ps file. A good previewer (like \fIgv\fR) will then automatically update its display. Thus the user can simply edit a file and, when the changes are written to disk, \fIlatexmk\fR completely automates the cycle of updating the .dvi (and possibly the .ps and .pdf) file, and refreshing the previewer's display. It's not quite WYSIWYG, but usefully close. .PP For other previewers, the user will have to manually make the previewer update its display, which can be (xdvi and gsview) as forcing a redraw of its display. .PP \fILatexmk\fR has the ability to print a banner in gray diagonally across each page when making the postscript file. .SH LATEXMK OPTIONS AND ARGUMENTS .TP .B file One or more files can be specified. If no files are specified, \fIlatexmk\fR will run on all files in the current working directory with a ".tex" extension and any files that match any file masks specified in the \fI$texfile_search\fR variable. If a file is specified without an extension, then the ".tex" extension is automatically added, just as LaTeX does. (e.g. If you specify: latexmk foo then \fIlatexmk\fR will operate on the file "foo.tex". .TP .B -bm A banner message to print diagonally across each page when converting the dvi file to postscript. The message must be a single argument on the command line so be careful with quoting spaces and such. Note that if the \fB-bm\fR option is specified, the \fB-ps\fR option is assumed and the postscript file is always generated, even if it is newer than the dvi file. .TP .B -bi How dark to print the banner message. A decimal number between 0 and 1. 0 is black and 1 is white, default is 0.95 which is OK unless your toner cartridge is getting low. .TP .B -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. Default is 220.0 which is just right for 5 character messages. .TP .B --commands List the commands used by \fIlatexmk\fR for processing files, and then exit. .TP .B -c Clean up (remove) all unnecessary files generated by \fIlatex\fR and \fIbibtex\fR except dvi, postscript and pdf. .TP .B -C Clean up (remove) all unnecessary files generated by \fIlatex\fR and \fIbibtex\fR including aux, dep, dvi, postscript and pdf. .TP .B -c1 Clean up (remove) all unnecessary files generated by \fIlatex\fR and \fIbibtex\fR except aux and dep. .TP .B -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 \fB-bs\fR and \fB-bi\fR options. The \fB-bm\fR option will override this option as this is really just a short way of specifying: latexmk -bm DRAFT Note that if the \fB-d\fR option is specified, the \fB-ps\fR option is assumed and the postscript file is always generated, even if it is newer than the dvi file. .TP .B -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 .TP .B -dvi Generate dvi version of document. .TP .B -dvi- Turn off generation of dvi version of document. (This may get overridden, if some other file is made (a .ps file) that is generated from the dvi file, or if no generated file at all is requested.) .TP .B --diagnostics Whenever a log file is parsed to determine the included files, print a list of included files. .TP .B -f Force \fIlatexmk\fR to continue document processing despite errors. Normally, when \fIlatexmk\fR detects that \fIlatex\fR has found an error which will not be resolved by further processing, the program terminates. .TP .B -F Force \fIlatexmk\fR to include files that don't exist when generating dependency files. A warning is produced instead of an error message and the program terminating. If the file name is not an absolute path, it is assumed to be relative to the current working directory. .TP .B -g Force \fIlatexmk\fR to process document, disregarding the timestamps of the source files. This option is particularly useful when updating style files, which are not included in the file dependency information. .TP .B -h, --help Print help information. .TP .B -i Generate new dependency file if root file is newer than dependency file or dependency file does not exist. The dependency information is taken from the log file or the source file, depending on the setting made by the \fB-il\fR and \fB-it\fR switches. .TP .B -il Extract dependency information from log file. This is normally the best method, so it is the default. However, some packages do not put information on files read in the log file, and then it may be better to tell \fIlatexmk\fR to get the information from the TeX file(s) --- see the switch \fB-it\fR. (Default) .TP .B -it Extract dependency information by scanning the source TeX file(s), rather than the log file. This is the method used by earlier versions of \fIlatexmk\fR. It relies on parsing TeX files, which can be confused by definitions of new commands, etc. Normally it is better to tell \fIlatexmk\fR to scan the log file --- see the switch \fB-il\fR. .TP .B -I Always generate new dependency file, even if newer dependency file exists. The dependency information is taken from the log file or the source file, depending on the setting made by the \fB-il\fR and \fB-it\fR switches. .TP .B -l Run in landscape mode, using the landscape mode previewers and dvi to postscript converters. .TP .B -p Print out the file using lpr after generating the postscript version. .TP .B -pdf Generate pdf version of document using pdflatex. .TP .B -pdf- Turn off generation of pdf version of document using pdflatex. This can be used to override a setting in a configuration file. It may get overridden if some other option uses the pdf file. .TP .B -ps Generate postscript version of document. .TP .B -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. .TP .B -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 usage: Use psnup to print two pages on the one page: latexmk -ps -pF 'psnup -2' foo.tex .TP .B -pv Run file previewer. If \fB-pdf\fR is specified, then \fIlatexmk\fR will run the pdf previewer. If \fB-ps\fR is specified, then \fIlatexmk\fR will run the postscript previewer. Otherwise it will run the dvi previewer. .TP .B -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). If \fB-pdf\fR is specified, the .pdf file will be updated and a pdf previewer will be used. If \fB-ps\fR is specified, the .dvi and .ps files will be updated and a postscript previewer will be used. Otherwise the .dvi file will be updated and a dvi previewer will be used. With a good previewer the display will be automatically updated. (Under UNIX "gv -watch" does this for postscript files; it would also do it for pdf files except for an apparent bug in gv that causes an error when the newly updated pdf file is read.) Note that if \fIlatexmk\fR dies because it encounters an error, the forked previewer will continue to run. Successive invocations with the \fB-pvc\fR option will not fork new previewers, but will use the existing previewer. (At least this will happen when \fIlatexmk\fR is running under an operating system where it knows how to determine whether an existing previewer is running.) .TP .B -r Read specified initialization file ("RC file") before processing. Since it may be used override options specified before the \fB-r\fR option, therefore it is a good idea have the habit of specifying the -r option first. See below for more details about RC files. .TP .B --silent Run commands silently, i.e., with options that reduce the amount of diagnostics generated. For example, with the default settings for commands under UNIX, the command "latex -interaction=batchmode" is used for latex. .TP .B -v, --version Print version number of \fILatexmk\fR. .TP .B --verbose Opposite of \fB--silent\fR. This is the default setting. .TP .B --view=default, --view=dvi, --view=ps, --view=pdf Set the kind of file used when previewing is requested (e.g., by the \fB-pv\fR or \fB-pvc\fR switches). The default is to view the "highest" kind of requested file (in the order dvi, ps, pdf). .PP If \fB-ps\fR are specified when the dependency file is created or updated, then these options are stored in the dependency file. This means that these options will automatically be activated without having to be explicitly specified on the command line in future runs. Of coarse, if the dependency file is updated or deleted, these automatic settings will be lost. .PP Options \fB-pv\fR and \fB-pvc\fR require one and only one filename specified on the command line. .PP Options \fB-p\fR, \fB-pv\fR and \fB-pvc\fR are mutually exclusive. .SH EXAMPLES .nf .ta 2i % \fBlatexmk thesis\fR \fI# run latex enough times to resolve cross-references\fR % \fBlatexmk -pvc -ps -f thesis\fR \fI# run latex enough times to resolve cross-references, make a postscript file, start a previewer. Then watch for changes in of the source file thesis.tex and any files it uses. After any changes rerun latex the appropriate number of times and remake the postscript file. If latex encounters an error, latexmk will keep running (as indicated by the \fB-f\fR switch). \fR % \fBlatexmk -c\fR \fI# remove .aux, .log, .bbl, .blg, .dep, .dvi, .pdf, .ps & .bbe files\fR .SH INITIALIZATION (RC) FILES .PP There are four initialization files ("RC files") that \fIlatexmk\fR can read at startup: .PP 1) The system RC file. On a UNIX system, it may be any one of the following "/opt/local/share/latexmk/LatexMk", "/usr/local/share/latexmk/LatexMk", "/usr/local/lib/latexmk/LatexMk". On a MS-WINDOWS system it is "C:\\latex\\LatexMk". .PP 2) The user's RC file in "$HOME/.latexmkrc". .PP 3) The RC file in the current working directory called "latexmkrc". .PP 4) The RC file specified on the command line with the \fB-r\fR option. .PP Each RC file is a sequence of Perl commands. Usually it will be just a sequence of assignment statements that override the built-in settings of \fILatexmk\fR. Comment lines are introduced by the "#" character. .SH RC VARIABLES .PP Many of the available variables that can be set are shown below. Syntax for the statements in an initialization file is of the form: .PP $bibtex = 'bibtex'; .PP If a command is to be run detached this is indicated by preceding it with "start", as in .PP $dvi_previewer = 'start xdvi'; .PP If a command is not to be run, the command name NONE is used, as in .PP $lpr = 'NONE lpr'; .PP Default values are indicated in brackets. .TP .B $banner [0] If nonzero, the banner message is printed across each page when converting the dvi file to postscript. Without modifying $banner_message, this is equivalent to specifying the \fB-d\fR option. Note that if \fB$banner\fR is nonzero, the \fB$postscript_mode\fR is assumed and the postscript file is always generated, even if it is newer than the dvi file. .TP .B $banner_intensity [0.95] Equivalent to the \fB-bi\fR option, this is a decimal number between 0 and 1 that specifies how dark to print the banner message. 0 is black, 1 is white. The default is just right if your toner cartridge isn't running too low. .TP .B $banner_message ["DRAFT"] The banner message to print across each page when converting the dvi file to postscript. This is equivalent to the \fB-bm\fR option. .TP .B $banner_scale [220.0] 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 just right for 5 character messages. This is equivalent to the \fB-bs\fR option. .TP .B $bibtex ["bibtex"] The BibTeX processing program. .TP .B $bibtex_silent ["-terse"] \fBSwitches\fR for the BibTeX processing program when silent mode is on. .TP .B $bibtex_mode [0] If nonzero, the document has a bibtex bibliography. Set by the \fB-i\fR and \fB-I\fR options and saved in the dependency file. Should not need to set this in an RC file. .TP .B $cleanup_mode [0] If nonzero, specifies cleanup mode. All other options ignored. Equivalent to specifying the \fB-c\fR option. Recommend that this is not set from an RC file. .TP .B $clean_ext [""] Extra extensions of files for \fIlatexmk\fR to remove when the \fB-c\fR option is selected. .TP .B $clean_full_ext [""] Extra extensions of files for \fIlatexmk\fR to remove when the \fB-C\fR option is selected. .TP .B $cus_dep_list [empty] Custom dependency list (see below). .TP .B $dvi_filter [empty] The dvi file filter to be run on the newly produced dvi file before other processing. Equivalent to specifying the \fB-dF\fR option. .TP .B $dvi_previewer ["start xdvi"] [Default is "start yap" under MS-WINDOWS.] The dvi-previewer to run with the \fB-pv\fR option. .TP .B $dvi_previewer_landscape ["start xdvi"] [Default is "start yap" under MS-WINDOWS.] The dvi-previewer to run with the \fB-pv\fR option in landscape mode. .TP .B $dvips ["dvips"] The program to used as a filter to convert a .dvi file to a .ps file. .TP .B $dvips_landscape ["dvips -tlandscape"] The program to used as a filter to convert a .dvi file to a .ps file in landscape mode. .TP .B $dvips_silent ["-q"] \fBSwitches\fR for dvips program when silent mode is on. .TP .B $dvi_update_method [2 under UNIX, 1 under MSWindows] How the dvi viewer updates its display when the dvi file has changed. 0 => update is automatic, 1=> manual update, by user, which may only mean a mouse click on the viewer's window or may mean serious action. 2 => Send the signal SIGUSR1 (as for xdvi under UNIX), 3 => Viewer cannot do an update, because it locks the file. .TP .B $force_generate_and_save_includes [0] If nonzero, specifies that the dependency file should always be generated. Equivalent to specifying the \fB-I\fR option. .TP .B $force_mode [0] If nonzero, continue processing past minor \fIlatex\fR errors including unrecognized cross references. Equivalent to specifying the \fB-f\fR option. .TP .B $force_include_mode [0] If nonzero, force \fIlatexmk\fR to include files that don't exist when generating dependency files. A warning is produced instead of an error message and the program terminating. If the file name is not an absolute path, it is assumed to be relative to the current working directory. Equivalent to specifying the \fB-F\fR option. .TP .B $generate_and_save_includes [0] If nonzero, generates dependency file if it does not exist or is older than the root file (the base .tex file). Equivalent to specifying the \fB-i\fR option. .TP .B $go_mode [0] If nonzero, process files regardless of timestamps. Equivalent to the \fB-g\fR option. .TP .B $includes_from_log [1] If nonzero, extract dependency information from the log file, rather than the source TeX file(s); this is equivalent to the \fB-il\fR option. If zero, extract dependency information by scanning the source TeX file(s); this is equivalent to the \fB-it\fR option. .TP .B $index_mode [0] If nonzero, run \fImakeindex\fR to produce index of document. Set by the \fB-i\fR and \fB-I\fR options and saved in the dependency file. Should not need to set this in an RC file. .TP .B $landscape_mode [0] If nonzero, run in landscape mode, using the landscape mode previewers and dvi to postscript converters. Equivalent to the \fB-l\fR option. .TP .B $latex ["latex"] The LaTeX processing program. .TP .B $latex_silent ["latex -interaction=batchmode"] Command to invoke the LaTeX processing program when silent mode is on. Under MSWindows, the default command is changed to "latex -interaction=batchmode -c-style-errors", as used by MikTeX. .TP .B $lpr ["lpr"] [Default is "NONE lpr" under MS-WINDOWS.] The printing program. .TP .B $makeindex ["makeindex"] The index processing program. .TP .B $pdf_mode [0] If nonzero, generate a postscript version of the document. Set by the \fB-i\fR and \fB-I\fR options if $slide_mode is set. Equivalent to the \fB-pdf\fR option and is stored in the dependency file if generated. .TP .B $pdflatex ["pdflatex"] The LaTeX processing program in the version that makes a pdf file instead of a dvi file. .TP .B $pdflatex_silent ["pdflatex -interaction=batchmode"] Command to invoke the pdflatex program (for directly generating a pdf file) when silent mode is on. Under MSWindows, the default command is changed to "pdflatex -interaction=batchmode -c-style-errors", as used by MikTeX. .TP .B $pdf_previewer ["start acroread"] [Default is changed to "start" on MS-WINDOWS, which launches the program associated with the .pdf file extension, which is commonly acroread.] The pdf previewer to run with the \fB-pv\fR option. Potential problem: if acroread is used as the pdf previewer, and it is actually viewing a pdf file that pdflatex wants to write, pdflatex will fail. This problem does not occur if ghostview, gv or psview is used to view pdf files. .TP .B $pdf_update_method [1 under UNIX, 3 under MSWindow] How the pdf viewer updates its display when the pdf file has changed. See $dvi_update_method for the codes. Note that acroread under MSWindows (but not UNIX) locks the pdf file, so the default value is then 3. .TP .B $pid_position = [1 under UNIX, -1 under MSWindows] Command used to get all the processes currently run by the user. The -pvc option uses the command specified by the variable $pscmd to determine if there is an already running previewer, and to find the process ID (needed if \fIlatexmk\fR needs to signal the previewer about file changes). The variable $pid_position is used to specify which word in lines of the output from $pscmd corresponds to the process ID. The first word in the line is numbered 0. The default value of 1 (2nd word in line) is correct for Solaris 2.6 and Linux. Setting the variable to -1 is used to indicate that $pscmd is not to be used. .TP .B $postscript_mode [0] If nonzero, generate a postscript version of the document. Set by the \fB-i\fR and \fB-I\fR options if $slide_mode is set. Equivalent to the \fB-ps\fR option and is stored in the dependency file if generated. .TP .B $preview_continuous_mode [0] If nonzero, run the \fB$dvi_previewer\fR to preview the document, and continue running \fIlatexmk\fR to keep .dvi up-to-date. Equivalent to the \fB-pvc\fR option. .TP .B $preview_mode [0] If nonzero, run the \fB$ps_previewer\fR to preview the document. Equivalent to the \fB-pv\fR option. .TP .B $printout_mode [0] If nonzero, print the document using \fIlpr\fR. Equivalent to the \fB-p\fR option. Recommend that this is not set from an RC file or you could waste lots of paper. .TP .B $pscmd [On UNIX, the default is "ps -f -u $ENV{USER}". On MS-WINDOWS the default in "NONE pscmd".] Command used to get all the processes currently run by the user. This is used by the -pvc option to determine if there is an already running previewer. The command line options for this command under the different flavors of UNIX are quite variable. The command given is suitable for Solaris 2.6 and for Linux. The variable $pid_position must also be set: see its description. .TP .B $ps_filter [empty] The postscript file filter to be run on the newly produced postscript file before other processing. Equivalent to specifying the \fB-pF\fR option. .TP .B $ps_previewer ["start gv -watch"] [Default is "start c:/gstools/gsview/gsview32" on MS-WINDOWS.] The postscript previewer to run with the \fB-pv\fR option. Note that gv with the -watch option updates its display whenever the postscript file changes, whereas ghostview does not. .TP .B $ps_previewer_landscape ["start gv -swap -watch"] [Default is "start c:/gstools/gsview/gsview32" on MS-WINDOWS.] The postscript previewer to run with the \fB-pv\fR option in landscape mode. .TP .B $ps_update_method [0 under UNIX, 1 under MSWindows] How the postscript viewer updates its display when the ps file has changed. See $dvi_update_method for the codes. .TP .B $sleep_time [2] The time to sleep (in seconds) between checking for source file changes when running the \fB-pvc\fR option. .TP .B $slide_mode [0] If nonzero, document is a Slitex document. Set by the \fB-i\fR and \fB-I\fR options or the \fB-s\fR option. Saved in the dependency file if generated. .TP .B $texfile_search [""] If no files were specified on the command line, then \fIlatexmk\fR will search for and files in the current working directory that end with a ".tex" extension or match the file mask specified in this variable. An example is: .PP $texfile_search = "$texfile_search *.ftex *.c.tex"; .TP .B $tmpdir ["/tmp"] [Default is the value of the environment variable TEMP under MS-WINDOWS.] Directory to store very small temporary files that \fIlatexmk\fR generates while running. .SH CUSTOM DEPENDENCIES .PP In any RC file a set of custom dependencies can be set up to convert a file with one extension to a file with another. An example use of this would be to allow \fIlatexmk\fR to convert a \fI.fig\fR file to \fI.eps\fR to be included in the \fI.tex\fR file. A table of custom dependencies are set up by using the \fB@cus_dep_list\fR array. Each string in the array has four arguments, separated by a space: .TP .B from extension: The extension of the file we are converting from (e.g. "fig"). .TP .B to extension: The extension of the file we are converting to (e.g. "eps"). .TP .B must: If non-zero, the file we are converting from \fBmust\fR exist, if it doesn't exist \fIlatexmk\fR will give an error message and exit unless the \fB-f\fR option is specified. If \fImust\fR is zero and the file we are converting from doesn't exist, then no action is taken. .TP .B function: The name of the subroutine that \fIlatexmk\fR should call to perform the file conversion. The first argument to the subroutine is the base name of the file to be converted without any extension. The subroutines are declared in the syntax of \fIperl\fR. .PP Example in an RC file to convert a \fI.fig\fR file to a \fI.eps\fR file: @cus_dep_list = (@cus_dep_list, "fig eps 0 fig2eps"); sub fig2eps { system("fig2dev -Lps $_[0].fig $_[0].eps"); } The subroutine \fIfig2eps\fR will only be called if the \fI.fig\fR file was modified more recently then the \fI.eps\fR file, or the \fI.eps\fR file does not exist. If the return value of the subroutine is non-zero, then \fIlatexmk\fR will assume an error occurred during the execution of the subroutine. .SH SEE ALSO latex(1), bibtex(1). .SH BUGS Search for .bib files is not correct if they are not in the current directory; the problem is that the log file generated by bibtex does not give the full path to the .bib files. The easiest fix at the moment is to set the BIBINPUTS environment variable to include explicitly the path containing your .bib files. Or you can set the $BIBINPUTS variable explicitly in one of latexmk's startup files. Preview continuous mode only works perfectly with certain previewers: Xdvi on UNIX/LINUX works for dvi files. Gv on UNIX/LINUX works for both postscript and pdf. Ghostview on UNIX/LINUX needs a manual update (reopen); it views postscript and pdf. Gsview under MS-Windows works for both postscript and pdf, but only reads the updated file when its screen is refreshed. Acroread under UNIX/LINUX views pdf, but the file needs to be closed and reopened to view an updated version. Under MS-Windows, acroread locks its input file and so the pdf file cannot be update. (Remedy: configure \fIlatexmk\fR use gsview instead.) .SH THANKS TO David Coppit (david@coppit.org) made many useful suggestions that contributed to version 3. .SH IDENTIFICATION Current version, with substantial modifications, enhancements and bug fixes by John Collins (collins@phys.psu.edu). (Version 3.04). .br Modifications and enhancements by Evan McLean (Version 2.0) .br Original script called "go" by David J. Musliner (RCS Version 3.2)