summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
Diffstat (limited to 'Master')
-rw-r--r--Master/texmf-dist/doc/man/man1/latexmk.1263
-rw-r--r--Master/texmf-dist/doc/man/man1/latexmk.man1.pdfbin221794 -> 215450 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexmk/CHANGES11
-rw-r--r--Master/texmf-dist/doc/support/latexmk/INSTALL2
-rw-r--r--Master/texmf-dist/doc/support/latexmk/README6
-rw-r--r--Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc64
-rw-r--r--Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc83
-rw-r--r--Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc80
-rw-r--r--Master/texmf-dist/doc/support/latexmk/latexmk.pdfbin204721 -> 188230 bytes
-rw-r--r--Master/texmf-dist/doc/support/latexmk/latexmk.txt3420
-rwxr-xr-xMaster/texmf-dist/scripts/latexmk/latexmk.pl2336
11 files changed, 3583 insertions, 2682 deletions
diff --git a/Master/texmf-dist/doc/man/man1/latexmk.1 b/Master/texmf-dist/doc/man/man1/latexmk.1
index 151970fed87..82cd96f1867 100644
--- a/Master/texmf-dist/doc/man/man1/latexmk.1
+++ b/Master/texmf-dist/doc/man/man1/latexmk.1
@@ -1,4 +1,4 @@
-.TH LATEXMK 1 "25 October 2018" ""
+.TH LATEXMK 1 "17 March 2019" ""
.SH NAME
latexmk \- generate LaTeX document
.SH SYNOPSIS
@@ -69,7 +69,9 @@ needed, call an external program to do other postprocessing on
generated dvi and postscript files. (See the options \fB-dF\fR and
\fB-pF\fR, and the documentation for the \fI$dvi_filter\fR and
\fI$ps_filter\fR configuration variables.) These capabilities are
-leftover from older versions of \fIlatexmk\fR. More flexibility can
+leftover from older versions of \fIlatexmk\fR, but \fBare currently
+non-functional\fR.
+More flexibility can
be obtained in current versions, since the command strings for running
\fIlatex\fR, \fIpdflatex\fR, etc can now be configured to run multiple
commands.
@@ -299,8 +301,8 @@ combination of log files, aux files, \fIlatexmk\fR's database file of
source file information,
and those with extensions
specified in the \fI@generated_exts\fR configuration variable. In addition,
-files specified by the \fI$clean_ext\fR configuration variable are
-removed.
+files specified by the \fI$clean_ext\fR and \fI@generated_exts\fR
+configuration variables are removed.
This cleanup is instead of a regular make. See the \fB-gg\fR option
if you want to do a cleanup then a make.
@@ -316,7 +318,7 @@ files are treated as non-regeneratable and hence are not deleted.
In contrast, if \fI$bibtex_use\fR is set to 2, bbl files are always
treated as regeneratable, and are deleted in a cleanup.
-\fITreatment of files generated by custom dependencies:\fRIf
+\fITreatment of files generated by custom dependencies:\fR If
\fI$cleanup_includes_cusdep_generated\fR is nonzero, regeneratable
files are considered as including those generated by custom
dependencies and are also deleted. Otherwise these files are not
@@ -559,13 +561,38 @@ Print help information.
.TP
.B -jobname=STRING
Set the basename of output files(s) to STRING, instead of the default,
-which is the basename of the specified TeX file.
+which is the basename of the specified TeX file. (At present, STRING
+should not contain spaces.)
This is like the same option for current implementations of the
\fIlatex\fR, \fIpdflatex\fR, etc, and the passing of this option to
these programs is part of \fIlatexmk\fR's implementation of
\fB-jobname\fR.
+There is one enhancement, that the STRING may contain the
+placeholder '%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 \fIlatexmk\fR, and you wish to use a jobname with a
+different file-dependent value for each file. For example, suppose
+you had .tex files test1.tex and test2.tex, and you wished to compare
+the results of compilation by \fIpdflatex\fR and those with
+\fIxelatex\fR. 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 \fIpdflatex\fR
+would have basenames test1-pdflatex and test2-pdflatex, while from
+\fIxelatex\fR, the basenames would be test1-xelatex and test2-xelatex.
+
+Under MS-Windows with cmd.exe, you would need to double the percent
+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
+
.TP
.B -l
Run in landscape mode, using the landscape mode for the previewers and
@@ -788,7 +815,7 @@ behaves like the \fB-pdflatex\fR option, but sets the variable
.TP
.B -pdfxelatex="COMMAND"
-This sets the string specifying the command to run \fIlualatex\fR. It
+This sets the string specifying the command to run \fIxelatex\fR. It
behaves like the \fB-pdflatex\fR option, but sets the variable
\fI$xelatex\fR.
@@ -1263,6 +1290,82 @@ j. Or ask me (the author of \fIlatexmk\fR). My e-mail is at the end
of this documentation.
+.SH ALLOWING FOR CHANGE OF OUTPUT FILE TYPE
+
+When one of the latex engines is run, the usual situation is that
+\fIlatex\fR produces a .dvi file, while \fIpdflatex\fR and
+\fIlualatex\fR produce a .pdf file. For \fIxelatex\fR the default is
+to produce a .pdf file, but to optimize processing time \fIlatexmk\fR
+runs \fIxelatex\fR its \fB-no-pdf\fR option so that it produces
+an .xdv file. Further processing by \fIlatexmk\fR takes this as a
+starting point.
+
+However, the actual output file may differ from the normal
+expectation; and then \fIlatexmk\fR can adjust its processing to
+accommodate this situation. The difference in output file type can
+happen for two reasons: One is that for \fIlatex\fR, \fIpdflatex\fR
+and \fIlualatex\fR the document itself can override the defaults. The
+other is that there may be a configuration, or misconfiguration, such
+that the program that \fIlatexmk\fR invokes to compile the document is
+not the expected one, or is given options incompatible with what
+\fIlatexmk\fR initially expects. (E.g., the \fB-output-format=...\fR
+option could be used with \fIlualatex\fR, or \fIxelatex\fR gets
+invoked without the \fB-no-pdf\fR option.)
+
+Under \fIlatex\fR and \fIpdflatex\fR, control of the output format by
+the document is done by setting the \\pdfoutput macro. Under
+\fIlualatex\fR, the \\outputmode macro is used instead.
+
+One example of an important use-case for document control of the
+output format is a document that uses the psfrag package to insert
+graphical elements in the output file. The psfrag package achieves its
+effects by inserting postscript code in the output of the compilation
+of the document. This entails the use of compilation to a .dvi file,
+followed by the use of conversion to a postscript file (either
+directly, as by \fIdvips\fR or implicitly, as an intermediate step by
+\fIdvipdf\fR). Then it is useful to force output to be of the .dvi
+format by inserting \\pdfoutput=0 in the preamble of the document.
+
+Another example is where the document uses graphics file of
+the .pdf, .jpg, and png types. With the default setting for the
+graphicx package, these can be processed in compilation to .pdf but
+not with compilation to .dvi. In this case, it is useful to insert
+\\pdfoutput=1 in the preamble of the document to force compilation
+to .pdf output format.
+
+In all of these cases, it is needed that \fIlatexmk\fR has to adjust
+its processing to deal with a mismatch between the actual output
+format (out of .pdf, .dvi, .xdv) and the initially expected output, if
+possible. \fILatexmk\fR does this provided the following conditions
+are met.
+
+The first is that \fIlatexmk\fR's \fI$allow_switch\fR configuration
+variable is set to a non-zero value as it is by default. If this
+variable is zero, a mismatch of filetypes in the compilation results
+in an erro.
+
+The second condition for \fIlatexmk\fR to be able to handle a change
+of output type is that no explicit requests for .dvi or .ps output
+files are made. Explicit requests are by the \fB-dvi\fR and
+\fB-ps\fR, \fB-print=dvi\fR, \fB-print=ps\fR, \fB-view=dvi\fR, and
+\fB-view=ps\fR options, and by corresponding settings of the
+\fI$dvi_mode\fR, \fI$postscript_mode\fR, \fI$print_type\fR, and
+\fI$view\fR configuration variables. The print-type and view-type
+restrictions only apply when printing and viewing are explicitly
+requested, respectively. For this purpose, the use of the
+\fB-pdfdvi\fR and \fB-pdfps\fR options (and the corresponding setting
+of the \fI$pdf_mode\fR variable) does not count as an explicit request
+for the .dvi and .ps files; they are merely regarded as a request for
+making a .pdf file together with an initial proposal for the
+processing route to make it.
+
+Note that when accommodating a change in output file type, there is
+involved a substantial change in the network of rules that
+\fIlatexmk\fR uses in its actions. The second condition applied to
+accommodate a change is to avoid situations where the change in the
+rule network is too radical to be readily handled automatically.
+
+
.SH CONFIGURATION/INITIALIZATION (RC) FILES
.PP
\fILatexmk\fR can be customized using initialization files, which are
@@ -1405,6 +1508,11 @@ invocation of \fIlatexmk\fR, it results in the replacement of %O by
The available placeholders are:
.TP
+.B %A
+basename of the main tex file. Unlike %R, this is unaffected by the
+setting of a jobname by the \fI-jobname\fR option or the
+\fI$jobname\fR configuration value.
+.TP
.B %B
base of filename for current command. E.g., if a postscript file
document.ps is being made from the dvi file document.dvi, then the
@@ -1416,6 +1524,7 @@ converting a dvi file to postscript).
.TP
.B %O
options
+.TP
.B %P
If the variable \fI$pre_tex_code\fR is non-empty, then %P is
substituted by the contents of \fI$pre_tex_code\fR followed by
@@ -1428,7 +1537,11 @@ If the variable \fI$pre_tex_code\fR is the empty string, then %P is
equivalent to %S.
.TP
.B %R
-root filename. This is the base name for the main tex file.
+root filename. This is the base name for the main tex file.
+
+By default this is the basename of the main tex file. However the
+value can be changed by the use of the \fI-jobname\fR option or the
+\fI$jobname\fR configuration variable.
.TP
.B %S
source file (e.g., the name of the dvi file when converting a .dvi file
@@ -1436,6 +1549,7 @@ to ps).
.TP
.B %T
The name of the primary tex file.
+.TP
.B %U
If the variable \fI$pre_tex_code\fR is non-empty, then its value is
substituted for %U (appropriately quoted). Otherwise it is replaced
@@ -1630,6 +1744,23 @@ indicates true, i.e., the behavior occurs, while a zero value
indicates a false value, i.e., the behavior does not occur.
.TP
+.B $allow_switch [1]
+
+This controls what happens when the output extension of latex,
+pdflatex, lualatex or xelatex differs from what is expected. (The
+possible extensions are .dvi, .pdf, .xdv.) This can happen with the
+use of the \\pdfoutput macro in a document compiled under \fIlatex\fR
+or \fIpdflatex\fR, or with the use of the \\outputmode macro under
+\fIlualatex\fR. It can also happen with certain kinds of incorrect
+configuration.
+
+In such a case, \fIlatexmk\fR can appropriately adjust its network of
+rules. The adjustment is made if \fI$allow_switch\fR is on, and if no
+request for a dvi or ps file has been made.
+
+See the section ALLOWING FOR CHANGE OF OUTPUT EXTENSION.
+
+.TP
.B $always_view_file_via_temporary [0]
Whether .ps and .pdf files are initially to be made in a temporary
directory and then moved to the final location. (This applies to
@@ -1809,7 +1940,6 @@ Note that the value 1.5 does \fInot\fR work properly if the document
uses \fIbiber\fR instead of \fIbibtex\fR. (There's a long story why
not.)
-
.TP
.B $cleanup_includes_cusdep_generated [0]
If nonzero, specifies that cleanup also deletes files that are
@@ -1820,9 +1950,19 @@ previous run.)
.TP
.B $cleanup_includes_generated [0]
If nonzero, specifies that cleanup also deletes files that are
-detected in log file as being generated (see the \\openout lines in
-the log file). It will also include files made from these first
+detected in the fls file (or failing that, in log file) as being
+generated. It will also include files made from these first
generation generated files.
+
+This operation is somewhat dangerous, and can have unintended
+consequences, since the files to be deleted are determined from a file
+created by (pdf)latex, which can contain erroneous
+information. Therefore this variable is turned off by default, and
+then files to be deleted are restricted to those explictly specified
+by patterns configured in the variables \fIclean_ext\fR,
+\fIclean_full_ext\fR, and \fI@generated_exts\fR, together with those
+very standard cases that are hardwired into \fIlatexmk\fR (e.g., .log
+files).
.TP
.B $cleanup_mode [0]
If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for cleanup
@@ -1845,7 +1985,7 @@ It is also possible to specify a more general pattern of file to be
deleted, by using the place holder %R, as in commands, and it is also
possible to use wildcards. Thus setting
- $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-files-%R/*";
+ $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-files-%R/*";
in an initialization file will imply that when a clean-up operation is
specified, not only is the standard set of files deleted, but also
@@ -1860,6 +2000,15 @@ equal to \fI$out_dir\fR. A normal situation is therefore that \fI$aux_dir\fR
equals \fI$out_dir\fR, which is the only case supported by
TeXLive, unlike MiKTeX.)
+The filenames specfied for a clean-up operation can refer not only to
+regular files but also to directories. Directories are only deleted
+if they are empty. An example of an application is to pythontex, which
+creates files in a particular directory. You can arrange to remove
+both the files and the directory by setting
+
+ $clean_ext = "pythontex-files-%R pythontex-files-%R";
+
+See also the variable \fI@generated_exts\fR.
.TP
.B $clean_full_ext [""]
Extra extensions of files for \fIlatexmk\fR to remove when the \fB-C\fR
@@ -2185,20 +2334,22 @@ This contains a list of extensions for files that are generated during
a LaTeX run and that are read in by LaTeX in later runs, either
directly or indirectly.
-This list has two uses: (a) to set the kinds of file to be deleted in
-a cleanup operation (with the \fB-c\fR, \fB-C\fR, \fB-CA\fR, \fB-g\fR
-and \fB-gg\fR options), and (b) in the determination of whether a
-rerun of (pdf)LaTeX is needed after a run that gives an error.
-
-(Normally, a change of a source file during a run should provoke a
-rerun. This includes a file generated by LaTeX, e.g., an aux file,
-that is read in on subsequent runs. But after a run that results in
-an error, a new run should occur until the user has made a change in
-the files. But the user may have corrected an error in a source .tex
-file during the run. So \fIlatexmk\fR needs to distinguish
-user-generated and automatically generated files; it determines the
-automatically generated files as those with extensions in the list in
-@generated_exts.)
+This list specifies files known to be generated by latex (and
+pdflatex, etc). It is used in two ways:
+(a) The specified files are deleted in a cleanup operation (with the
+\fB-c\fR, \fB-C\fR, \fB-CA\fR, \fB-g\fR and \fB-gg\fR options), and
+(b) It affects the determination of whether a rerun of (pdf)LaTeX is
+needed after a run that gives an error.
+
+(Concerning item (b): Normally, a change of a source file during a run
+should provoke a rerun. This includes a file generated by LaTeX,
+e.g., an aux file, that is read in on subsequent runs. But after a
+run that results in an error, a new run should not occur until the
+user has made a change in the files. But the user may have corrected
+an error in a source .tex file during the run. So \fIlatexmk\fR needs
+to distinguish user-generated and automatically generated files; it
+determines the automatically generated files as those with extensions
+in the list in @generated_exts.)
A convenient way to add an extra extension to the list, without losing
the already defined ones is to use a push command in the line in an
@@ -2263,6 +2414,36 @@ delete function, e.g.,
delete $hash_calc_ignore_pattern{'eps'};
.TP
+.B $jobname [""]
+
+This specifies the jobname, i.e., the basename that is used for
+generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this variable
+is a null string, then the basename is the basename of the main tex
+file.
+(At present, the string in \fI$jobname\fR should not contain spaces.)
+
+The placeholder '%A' is permitted. This will be substituted by the
+basename of the TeX file. The primary purpose is when a variety of
+tex files are to be processed, and you want to use a different jobname
+for each but one that is distinct for each. Thus if you wanted to
+compare compilations of a set of files on different operating systems,
+with distinct filenames for all the cases, you could set
+
+ $jobname = "%A-$^O";
+
+in an initialization file. (Here \fI$^O\fR is a variable provided by
+perl that contains perl's name for the operating system.)
+
+Suppose you had .tex files test1.tex and test2.tex. Then when you run
+
+ latexmk -pdf *.tex
+
+both files will be compiled. The .aux, .log, and .pdf files will have
+basenames test1-MSWin32 ante test2-MSWin32 on a MS-Windows system,
+test1-darwin and test2-darwin on an OS-X system, and a variety of
+similar cases on linux systems.
+
+.TP
.B $kpsewhich ["kpsewhich %S"]
The program called to locate a source file when the name alone is not
sufficient. Most filenames used by \fIlatexmk\fR have sufficient path
@@ -2511,6 +2692,7 @@ document using \fIxelatex\fR, using the commands specified by the
In \fI$pdf_mode\fR=2, it is ensured that .dvi and .ps files are also made.
In \fI$pdf_mode\fR=3, it is ensured that a .dvi file is also made.
+But this may be overridden by the document.
.TP
.B $pdflatex ["pdflatex %O %S"]
Specifies the command line for
@@ -3304,6 +3486,33 @@ also the examples in the directory \fIexample_rcfiles\fR in the
\fIlatexmk\fR distributions. Even if none of the examples apply to
your case, they may give you useful ideas
+.SS Utility subroutines
+
+.TP
+.B ensure_path( var, values ...)
+
+The first parameter is the name of one of the system's environment
+variables for search paths. The remaining parameters are values that
+should be in the variable. For each of the value parameters, if it
+isn't already in the variable, then it is prepended to the variable;
+in that case the environment variable is created if it doesn't already
+exist. For separating values, the character appropriate the the
+operating system is used -- see the configuration variable
+\fI$search_path_separator\fR.
+
+Example:
+
+ ensure_path( 'TEXINPUTS', './custom_cls_sty_files//' );
+
+(In this example, the trailing '//' is documented by TeX systems to
+mean that latex, pdflatex, etc search for files in the specified
+directory and in all subdirectories.)
+
+Technically \fIensure_path\fR works by setting Perl's variable
+\fI$ENV{var}\fR, where \fIvar\fR is the name of the target variable.
+The changed value is then passed as an environment variable to any
+invoked programs.
+
.SS Variables and subroutines for processing a rule
A step in the processing is called a rule. One possibility to
@@ -3575,7 +3784,7 @@ e-mail addresses are not written in their standard form to avoid being
harvested too easily.)
.SH AUTHOR
Current version, by John Collins (username jcc8 at node psu.edu).
-(Version 4.61).
+(Version 4.63b).
Released version can be obtained from CTAN:
<http://www.ctan.org/pkg/latexmk/>, and from the
diff --git a/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf b/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
index 2e7c93a21cc..566081325bd 100644
--- a/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
+++ b/Master/texmf-dist/doc/man/man1/latexmk.man1.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexmk/CHANGES b/Master/texmf-dist/doc/support/latexmk/CHANGES
index ec17299401c..b3d9f8c1cde 100644
--- a/Master/texmf-dist/doc/support/latexmk/CHANGES
+++ b/Master/texmf-dist/doc/support/latexmk/CHANGES
@@ -639,7 +639,7 @@ From v. 4.57 to 4.59
'"' character is not allowed in a filename read by tex and
friends.
Give fatal error when name of tex file on command line is either not
- allowed by tex and friends are gives problematic behavior.
+ allowed by tex and friends , or gives problematic behavior.
Use TEXINPUTS as search path for source files for custom
dependency.
Only give warning about differing expected and output filenames when
@@ -670,3 +670,12 @@ From v. 4.59 to 4.61
as in 'pythontex-files-%R/*'.
Updates of documentation.
+From v. 4.61 to 4.63b
+ Update example_rcfiles/glossary_latexmkrc
+ Fix problem that in -cd mode, an error is raised when the path
+ part of the tex filename contains a character prohibited by *tex.
+ Implement changing of rule network when output of *latex is not what
+ is expected, e.g., because \pdfoutput is used in document.
+ Implement placeholder for true basename of main tex file, and use it
+ in jobname.
+ Various bug fixes.
diff --git a/Master/texmf-dist/doc/support/latexmk/INSTALL b/Master/texmf-dist/doc/support/latexmk/INSTALL
index 6d876e70c01..c586319d324 100644
--- a/Master/texmf-dist/doc/support/latexmk/INSTALL
+++ b/Master/texmf-dist/doc/support/latexmk/INSTALL
@@ -1,6 +1,6 @@
INSTALLING latexmk
==================
- (Version 4.61, 25 October 2018)
+ (Version 4.63b, 17 March 2019)
John Collins
Physics Department
diff --git a/Master/texmf-dist/doc/support/latexmk/README b/Master/texmf-dist/doc/support/latexmk/README
index 4ed7873b465..0f3d5993194 100644
--- a/Master/texmf-dist/doc/support/latexmk/README
+++ b/Master/texmf-dist/doc/support/latexmk/README
@@ -1,5 +1,5 @@
-Latexmk, version 4.61, 25 Oct 2018
-----------------------------------
+Latexmk, version 4.63b, 17 Mar 2019
+-----------------------------------
Latexmk completely automates the process of generating a LaTeX
document. Essentially, it is a highly specialized cousin of the
@@ -87,7 +87,7 @@ NOTES:-
John Collins
---------------------------- "latexmk -h" ----------------------------
-Latexmk 4.61: Automatic LaTeX document generation routine
+Latexmk 4.63b: Automatic LaTeX document generation routine
Usage: latexmk [latexmk_options] [filename ...]
diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc
new file mode 100644
index 00000000000..a8cf90ae47b
--- /dev/null
+++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/fix-aux.latexmkrc
@@ -0,0 +1,64 @@
+# This shows how to implement the use different values for $aux_dir and
+# $out_dir when the latex (etc) engines don't support the -aux-directory
+# option. (Of the standard distributions, MiKTeX supports -aux-directory,
+# but TeXLive does not.)
+
+
+foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
+ ${$cmd} = "internal latex_fix_aux $cmd %O %S";
+}
+$xelatex =~ s/%O/-no-pdf %O/;
+
+
+#---------------------------
+
+sub latex_fix_aux {
+ # Fudge to allow use of -aux_directory option with non-MiKTeX system.
+ # Just communicate by arguments, and don't use latexmk's variables
+ # $aux_dir, etc.
+ my $auxD = '';
+ my $outD = '';
+ foreach (@_) {
+ if ( /^-aux-directory=(.*)$/ ) {
+ $auxD = $1;
+ }
+ elsif ( /^-output-directory=(.*)$/ ) {
+ $outD = $1;
+ }
+ }
+ if ( $outD eq '' ) { $outD = '.'; }
+ if ( $auxD eq '' ) { $auxD = $outD; }
+ my @args_act = ();
+ my $set_outD = 0;
+ foreach (@_) {
+ if ( /^-(aux|output)-directory=.*$/ ) {
+ if ( ! $set_outD ) {
+ push @args_act, "-output-directory=$auxD";
+ $set_outD = 1;
+ }
+ }
+ else {
+ push @args_act, $_;
+ }
+ }
+ my $outD1 = $outD;
+ my $auxD1 = $auxD;
+ foreach ( $auxD1, $outD1 ) {
+ if ( ($_ ne '') && ! m([\\/\:]$) ) {
+ $_ .= '/';
+ }
+ while ( s[^\.\/][] ) {}
+ }
+
+ print "Running: '@args_act'\n";
+ my $ret = system @args_act;
+ if ($auxD ne $outD) {
+ print "Moving dvi, fls, ps, pdf files from '$auxD' to '$outD'\n";
+ foreach my $ext ('dvi', 'fls', 'ps', 'pdf' ) {
+ rename "$auxD1$root_filename.$ext", "$outD1$root_filename.$ext",;
+ }
+ }
+ return $ret;
+}
+
+#---------------------------
diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc
index 203a0a3fe72..2c15e9aac67 100644
--- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc
+++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc
@@ -1,62 +1,39 @@
-# This shows how to use the glossary package
-# (http://www.ctan.org/pkg/glossary) and the glossaries package
-# (http://www.ctan.org/pkg/glossaries) with latexmk. Note that there
-# are important differences between these two packages, so you should
-# take careful note of the comments below.
+# This shows how to use
+# the glossaries package (http://www.ctan.org/pkg/glossaries)
+# the glossaries-extra package (http://www.ctan.org/pkg/glossaries-extra)
+# with latexmk.
+# N.B. There is also the OBSOLETE glossary package
+# (http://www.ctan.org/pkg/glossary), which has some differences. See items
+# 2 and 3
+# 1. If you use the glossaries or the glossaries-extra package, then you use:
-# 1. For glossaries using glossary package
-
-add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
-sub makeglo2gls {
- system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
-}
-
-
-
-# 2. For acronyms using glossary package:
+ add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
+ add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
+ $clean_ext .= " acr acn alg glo gls glg";
+ sub makeglossaries {
+ my ($name, $path) = fileparse( $$Psource );
+ return system "makeglossaries -d '$path' '$name'";
+ }
-add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
-sub makeacr2acn {
- system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
-}
+# 2. If you use the OBSOLETE glossary package, then you can do
-# ===> 3. If you use the package glossaries rather than the package
-# glossary, you need to EXCHANGE acn and acr in the above.
+ add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
+ sub makeglo2gls {
+ system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
+ }
-# 4. If you use the glossaries package and have the makeglossaries
-# script installed, then you can do something simpler:
+# 2. If you use the OBSOLETE glossary package, then you can do
+# the following for acronyms:
- add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
- sub makeglossaries {
- my ($base_name, $path) = fileparse( $_[0] );
- pushd $path;
- my $return = system "makeglossaries $base_name";
- popd;
- return $return;
- }
+ # ONLY FOR PACKAGE glossary, NOT FOR glossaries and glossaries-extra
+ add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
+ sub makeacr2acn {
+ system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
+ }
-# This code works around a problem with makeglossaries when the
-# -output-directory option of latexmk is used. When makeglossaries is
-# called with a filename that has a directory in it, e.g.,
-#
-# makeglossaries output/document
-#
-# the makeindex or xindy commmands look for a document.ist or
-# document.xdy file that is created by the glossaries package. The
-# file is correctly created in the output/ directory, but the
-# makeindex or xindy commands are called in way that they look for
-# that file in the document directory, not in the output directory.
-# So the above definition of a subroutine makeglossaries works around
-# that.
-#
-# Note that the 3rd definition of a custom dependency, the one that
-# invokes the makeglossaries script, has the advantage that it can
-# change automatically to use the xindy program instead of makeindex,
-# according to the setting by which the glossaries package is invoked
-# in the document. The first two solutions I gave for the custom
-# dependency have the choice of makeindex hard-coded (which can be
-# changed, of course). Automatic switching would need a more
-# complicated solution.
+# ===> WARNING: In the current glossaries and glossaries-extra packages
+# the roles of the .acr and .acn files are exchanged, so the above
+# code will fail with the more modern packages.
diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc
index 26d2a19a7aa..ba02de3ee78 100644
--- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc
+++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc
@@ -1,67 +1,39 @@
-# Support for pythontex in v. 0.16 or higher.
+# Support for pythontex in v. 0.16 or higher, with latexmk 4.62 or higher
#
# What these definitions provide/do:
# 1. Variable specifying command string for invoking pythontex
-# 2. Definition of commands for latex, pdflatex, etc to call a
-# subroutine latex_python that implements the necessary
-# functionality, as follows:
-# a. The latex, pdflatex program, etc is run.
-# b. It is determined whether a file $root.pytxcode was generated
-# during the run. Here $root is the root name of the primary
-# document file. The $root.pytxcode, if present, is created in
-# the output directory (or more exactly, the aux directory, if
-# different from the output directory. It is a symptom of the
-# use of pythontex.
-# c. If the file is present, a rule for running pythontex is set
-# up, if it has not already been created.
-# d. The source file for the rule is $root.pytxcode and the
-# destination file is named $root.pytxmcr, which is always
-# created in a subdirectory named pythontex-files-$root of the
-# aux or output directory. The file $root.pytxmcr is always
-# created when pythontex is run, and is read when a document
-# using pythontex is compiled (by latex, or pdflatex, etc)
-# e. If that rule is being created for the first time, a message is
-# appended to the .log file of the latex run about the
-# $root.pytxmcr filename (with the appropriate prefix
-# directory). This ensures that at the next stage of the
-# processing, when latexmk examines the run's .log file, it
-# creates appropriate dependency information and links the
-# pythontex rule into the network of dependencies.
-# 3. Settings for the files generated by the pythontex package and the
+# 2. Addition to %extra_rule_spec of template for pythontex rule. This
+# tells latexmkrc to create the rule when it is initializing for
+# processing a TeX file.
+# 3. A subroutine mypythontex that the pythontex rule is defined to
+# call. This runs pythontex and then sets dependency information.
+# 4. Settings for the files generated by the pythontex package and the
# pythontex program so that the files are deleted in a clean-up
# operation.
-$clean_ext .= " pythontex-files-%R/*";
+$clean_ext .= " pythontex-files-%R/* pythontex-files-%R";
push @generated_exts, 'pytxcode';
$pythontex = 'pythontex %O %S';
+$extra_rule_spec{'pythontex'} = [ 'internal', '', 'mypythontex', "%Y%R.pytxcode", "%Ypythontex-files-%R/%R.pytxmcr", "%R", 1 ];
-foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
- ${$cmd} = "internal latex_python %R %Y $cmd %O %S";
-}
-
-sub latex_python {
- # Run *latex, then set pythontex rule if needed.
- # Arguments: Root name, directory for aux files (with terminator),
- # latex program to run, arguments for latex.
-
- my $root = shift;
- my $dir_string = shift;
- my $pytx_code = "$dir_string$root.pytxcode";
- my $result_dir = $dir_string."pythontex-files-$root";
- my $pytx_out_file = "$result_dir/$root.pytxmcr";
- my $pytx_rule_name = "pythontex $root";
- my $ret = system @_;
- if ( test_gen_file( $pytx_code ) ) {
- print "=== Pythontex being used\n";
- if (! rdb_rule_exists( $pytx_rule_name ) ) {
- print "=== Creating rule '$pytx_rule_name'\n";
- rdb_create_rule( $pytx_rule_name, 'external', $pythontex, '', 1,
- $pytx_code, $pytx_out_file, $root, 1 );
- system "echo No file \"$pytx_out_file\". >> \"$dir_string$root.log\"";
- }
+sub mypythontex {
+ my $result_dir = $aux_dir1."pythontex-files-$$Pbase";
+ my $ret = Run_subst( $pythontex, 2 );
+ rdb_add_generated( glob "$result_dir/*" );
+ my $fh = new FileHandle $$Pdest, "r";
+ if ($fh) {
+ while (<$fh>) {
+ if ( /^%PythonTeX dependency:\s+'([^']+)';/ ) {
+ print "Found pythontex dependency '$1'\n";
+ rdb_ensure_file( $rule, $aux_dir1.$1 );
+ }
+ }
+ undef $fh;
+ }
+ else {
+ warn "mypythontex: I could not read '$$Pdest'\n",
+ " to check dependencies\n";
}
return $ret;
}
-
-
diff --git a/Master/texmf-dist/doc/support/latexmk/latexmk.pdf b/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
index 6c875256167..b2bee5a0725 100644
--- a/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
+++ b/Master/texmf-dist/doc/support/latexmk/latexmk.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/support/latexmk/latexmk.txt b/Master/texmf-dist/doc/support/latexmk/latexmk.txt
index b9e44777c8b..aabdeb362e5 100644
--- a/Master/texmf-dist/doc/support/latexmk/latexmk.txt
+++ b/Master/texmf-dist/doc/support/latexmk/latexmk.txt
@@ -14,18 +14,18 @@ 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
- latexmk 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.
+ 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.
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
- rerun whenever one of the source files is modified, and the previewer
- automatically updates the on-screen view of the compiled document.
+ 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
@@ -44,24 +44,24 @@ DESCRIPTION
in encapsulated postscript or another suitable format for reading by
LaTeX.
- Latexmk has two different previewing options. With the simple -pv
- option, a dvi, postscript or pdf previewer is automatically run after
+ 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.
- Every time a change is detected, latexmk runs all the programs neces-
- sary 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)
+ 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
- 25 October 2018 1
+ 17 March 2019 1
@@ -70,8 +70,8 @@ DESCRIPTION
LATEXMK(1) General Commands Manual LATEXMK(1)
- file, and refreshing the previewer's display. It's not quite WYSIWYG,
- but usefully close.
+ 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
@@ -82,11 +82,11 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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. More
- flexibility can be obtained in current versions, since the command
- strings for running latex, pdflatex, etc can now be configured to run
- multiple commands. This also extends the possibility of postprocessing
- generated files.
+ 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, pdflatex, etc
+ can now be configured 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
@@ -100,13 +100,13 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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
- determinations of how many runs are needed and of which programs.
- Latexmk 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
- extension .fdb_latexmk, by default) that contains the source file
- information.
+ 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
@@ -120,14 +120,14 @@ LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE
Note 1: In addition to the options in the list below, latexmk recog-
nizes almost all the options recognized by the latex, pdflatex programs
(and their relatives) in their current TeXLive and MiKTeX implementa-
- tions. Some of the options for these programs also trigger special
- action or behavior by latexmk, in which case they have specific expla-
- nations in this document. Otherwise, they are just passed through to a
+ tions. Some of the options for these programs also trigger special ac-
+ tion or behavior by latexmk, in which case they have specific explana-
+ tions in this document. Otherwise, they are just passed through to a
called latex or pdflatex program. Run latexmk with the
- 25 October 2018 2
+ 17 March 2019 2
@@ -164,8 +164,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
able in the section "List of configuration variables usable in
initialization files".
- If a file is specified without an extension, then the ".tex"
- extension is automatically added, just as LaTeX does. Thus, if
+ 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
@@ -188,12 +188,12 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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
- directory separator in Windows, and is accepted by latex etc.
+ replaces it by a backward slash "/", which is also a legal di-
+ rectory separator in Windows, and is accepted by latex etc.
- 25 October 2018 3
+ 17 March 2019 3
@@ -259,7 +259,7 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
- 25 October 2018 4
+ 17 March 2019 4
@@ -308,8 +308,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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
- assumed.
+ Note that if the -bm option is specified, the -ps option is as-
+ sumed.
-bi <intensity>
@@ -325,7 +325,7 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
- 25 October 2018 5
+ 17 March 2019 5
@@ -349,8 +349,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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 configuration variable are
- removed.
+ 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 then a make.
@@ -366,17 +366,17 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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
+ Treatment of files generated by custom dependencies: If
$cleanup_includes_cusdep_generated is nonzero, regeneratable
- files are considered as including those generated by custom
- dependencies and are also deleted. Otherwise these files are
- not deleted.
+ 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
- addition of dvi, postscript and pdf files, and those specified
- in the $clean_full_ext configuration variable.
+ 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.
This cleanup is instead of a regular make. See the -gg option
if you want to do a cleanup than a make.
@@ -385,13 +385,13 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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
- dependencies and are also deleted. Otherwise these files are
- not deleted.
+ files are considered as including those generated by custom de-
+ pendencies and are also deleted. Otherwise these files are not
+ deleted.
- 25 October 2018 6
+ 17 March 2019 6
@@ -413,51 +413,51 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
source file.
This option works by setting the $do_cd configuration variable
- to one; you can set that variable if you want to configure
- latexmk to have the effect of the -cd option without specifying
- it on the command line. See the documentation for that vari-
- able.
+ 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
+ -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
+ .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 and pdflatex 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
+ This is the default behavior and corresponds to the behavior of
+ the latex and pdflatex 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
- information.
+ 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-
+ -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
+ -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
+ option will override this option as this is really just a short
way of specifying:
latexmk -bm DRAFT
- Note that if the -d option is specified, the -ps option is
- assumed.
+ 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,
+ 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
- 25 October 2018 7
+ 17 March 2019 7
@@ -466,20 +466,19 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
- 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-
+ 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
+ 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,
+ 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.)
@@ -487,7 +486,7 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Equivalent to -deps.
- -deps- Do not show a list of dependent files after processing. (This
+ -deps- Do not show a list of dependent files after processing. (This
is the default.)
@@ -496,18 +495,18 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-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
+ 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
- dependent files after processing.
+ Use of this option also turns on the output of the list of de-
+ pendent files after processing.
- -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
+ -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
@@ -517,13 +516,14 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-diagnostics
- Print detailed diagnostics during a run. This may help for
- debugging problems or to understand latexmk's behavior in diffi-
+ Print detailed diagnostics during a run. This may help for de-
+ bugging problems or to understand latexmk's behavior in diffi-
cult situations.
- 25 October 2018 8
+
+ 17 March 2019 8
@@ -535,44 +535,44 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-dvi Generate dvi version of document.
- -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
+ -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.)
-e <code>
- 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-
+ 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
- results in latexmk stopping. Multiple instances of the -r and
- -e options can be used, and they are executed in the order they
- appear on the command line.
+ 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
- option, then under UNIX/Linux you could use the line
+ 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
+ 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
+ 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
@@ -581,15 +581,15 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
latexmk -e "$latex='latex %O -shell-escape %S'" file.tex
- The last two examples will NOT work with UNIX/Linux command
+ 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
+ (Note: the above examples show are to show how to use the -e to
+ specify initialization code to be executed. But the particular
- 25 October 2018 9
+ 17 March 2019 9
@@ -602,28 +602,28 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
less problems in dealing with quoting.)
- -f Force latexmk to continue document processing despite errors.
+ -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,
+ 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.
-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-
+ -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
+ -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.
@@ -639,29 +639,56 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-jobname=STRING
- Set the basename of output files(s) to STRING, instead of the
- default, which is the basename of the specified TeX file.
+ 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.)
This is like the same option for current implementations of the
latex, pdflatex, etc, 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
+
- -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
- determine this information automatically.
+ 17 March 2019 10
- 25 October 2018 10
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ example, suppose you had .tex files test1.tex and test2.tex, and
+ you wished to compare the results of compilation by pdflatex and
+ those with xelatex. Then under a unix-type operating system you
+ could use the command line
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ 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.
@@ -669,15 +696,15 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-latex="COMMAND"
This sets the string specifying the command to run latex, and is
- typically used to add desired options. Since the string nor-
+ 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
- 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
+ The specification of the contents of the string are the same as
+ 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).
To set the command for running pdflatex (rather than the command
@@ -686,133 +713,132 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-logfilewarninglist
-logfilewarnings After a run of (pdf)latex, give a list of warn-
- ings about undefined citations and references (unless silent
+ ings about undefined citations and references (unless silent
mode is on).
See also the $silence_logfile_warnings configuration variable.
- -logfilewarninglist-
- -logfilewarnings- After a run of (pdf)latex, do not give a list
- of warnings about undefined citations and references. (Default)
- See also the $silence_logfile_warnings configuration variable.
+ 17 March 2019 11
- -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.)
-
-
- -M Show list of dependent files after processing. This is equiva-
- lent to the -deps option.
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ -logfilewarninglist-
+ -logfilewarnings- After a run of (pdf)latex, do not give a list
+ of warnings about undefined citations and references. (Default)
+ See also the $silence_logfile_warnings configuration variable.
- 25 October 2018 11
+ -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.)
-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
+ 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
- remove header files without updating the Makefile to match.
+ 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.
-new-viewer
- When in continuous-preview mode, always start a new viewer to
- view the generated file. By default, latexmk will, in continu-
- ous-preview mode, test for a previously running previewer for
+ When in continuous-preview mode, always start a new viewer to
+ view the generated file. By default, latexmk will, in continu-
+ ous-preview mode, test for a previously running previewer for
the same file and not start a new one if a previous previewer 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 directory). This
+ an already-running previewer that is viewing a file of the same
+ name as the current file, but in a different directory). This
option turns off the default behavior.
-new-viewer-
- The inverse of the -new-viewer option. It puts latexmk in its
+ 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.
- -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
- encountered. But -norc is an exception to this rule: it is
- acted on first, no matter where it occurs on the command line.
+ 17 March 2019 12
- -outdir=FOO or -output-directory=FOO
- Sets the directory for the output files of (pdf)latex. This
- achieves its effect by the -output-directory option of
- (pdf)latex, which currently (Dec. 2011 and later) is implemented
- on the common versions of (pdf)latex, i.e., MiKTeX and TeXLive.
- It may not be present in other versions.
- See also the -auxdir/-aux-directory options, and the $aux_dir,
- $out_dir, and $search_path_separator configuration variables of
- latexmk. In particular, see the documentation of $out_dir for
- some complications on what directory names are suitable.
- If you also use the -cd option, and the specified output
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ -nobibtex
+ Never run bibtex or biber. Equivalent to the -bibtex- option.
- 25 October 2018 12
+ -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
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ Sets the directory for the output files of (pdf)latex. This
+ achieves its effect by the -output-directory option of (pdf)la-
+ tex, which currently (Dec. 2011 and later) is implemented on the
+ common versions of (pdf)latex, i.e., MiKTeX and TeXLive. It may
+ not be present in other versions.
+ See also the -auxdir/-aux-directory options, and the $aux_dir,
+ $out_dir, and $search_path_separator configuration variables of
+ latexmk. In particular, see the documentation of $out_dir for
+ some complications on what directory names are suitable.
- directory is a relative path, then the path is interpreted rela-
- tive to the document directory.
+ If you also use the -cd option, and the specified output direc-
+ tory is a relative path, then the path is interpreted relative
+ to the document directory.
- -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.
+ -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
+ 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,
- under 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,
+ 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.
@@ -820,62 +846,62 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
turns them off.
- -pdf Generate pdf version of document using pdflatex. (If you wish
+ -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".
+ -pdflua, -pdfxe, -lualatex or -xelatex applies.) To configure
+ latexmk to have such behavior by default, see the section on
- -pdfdvi
- Generate pdf version of document from the dvi file, by default
- using dvipdf.
+ 17 March 2019 13
- -pdflua
- Generate pdf version of document using lualatex.
- -pdfps Generate pdf version of document from the .ps file, by default
- using ps2pdf.
- -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
- latexmk then call xdvipdfmx to generate the final .pdf file.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- (Note: When the document includes large graphics files, espe-
- cially .png files, the last step can be quite time consuming,
- even when the creation of the .xdv file by xelatex is fast. So
- the use of the intermediate .xdv file can result in substantial
+ "Configuration/initialization (rc) files".
- 25 October 2018 13
+ -pdfdvi
+ Generate pdf version of document from the dvi file, by default
+ using dvipdf.
+ -pdflua
+ Generate pdf version of document using lualatex.
+ -pdfps Generate pdf version of document from the .ps file, by default
+ using ps2pdf.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ -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.
- gains in procesing time, since the .pdf file is produced once
- rather than on every run of xelatex. See the documentation on
+ (Note: When the document includes large graphics files, espe-
+ cially .png files, the last step can be quite time consuming,
+ even when the creation of the .xdv file by xelatex is fast. So
+ the use of the intermediate .xdv file can result in substantial
+ gains in procesing time, since the .pdf file is produced once
+ rather than on every run of xelatex. See the documentation on
the -pdfxe option for why an .xdv file is used.
- -pdf- Turn off generation of pdf version of document. (This can be
- used to override a setting in a configuration file. It may get
+ -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
- latex (or, more precisely, whatever program is configured to be
+ 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).
@@ -887,14 +913,26 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
latexmk -pdf -pdflatex="pdflatex --shell-escape %O %S"
foo.tex
- The specification of the contents of the string are the same as
+ 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).
+ in fact sets the variable $pdflatex.) Depending on your
+
+
+
+ 17 March 2019 14
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
- To set the command for running latex (rather than the command
+
+ operating system and the command-line shell you are using, you
+ may need to change the single quotes to double quotes (or some-
+ thing else).
+
+ To set the command for running latex (rather than the command
for pdflatex) see the -latex option.
@@ -905,30 +943,18 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-pdfxelatex="COMMAND"
- This sets the string specifying the command to run lualatex. It
- behaves like the -pdflatex option, but sets the variable $xela-
+ This sets the string specifying the command to run xelatex. It
+ behaves like the -pdflatex option, but sets the variable $xela-
tex.
Warning: It is important to ensure that the -no-pdf is used when
- xelatex is invoked; see the explanation for the variable $xela-
+ xelatex is invoked; see the explanation for the variable $xela-
tex for why this is necessary. If you provide %O in the command
specification, this will be done automatically.
An example of the use of the -pdfxelatex option:
-
-
-
- 25 October 2018 14
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- latexmk -pdfxe -pdfxelatex="xelatex --shell-escape %O %S"
+ latexmk -pdfxe -pdfxelatex="xelatex --shell-escape %O %S"
foo.tex
@@ -936,11 +962,11 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-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
+ 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_cmd, and
- the substitution strings %P and %U for more details. This
- option works by setting the variable $pre_tex_cmd.
+ ured. See the documentation of the variable $pre_tex_cmd, and
+ the substitution strings %P and %U for more details. This op-
+ tion works by setting the variable $pre_tex_cmd.
See also the -usepretex option.
@@ -958,13 +984,23 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
latexmk -pretex='\AtBeginDocument{Message\par}' foo.tex
+
+ 17 March 2019 15
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
-print=dvi, -print=ps, -print=pdf, -print=auto,
- Define which kind of file is printed. This option also ensures
+ Define which kind of file is printed. This option also ensures
that the requisite file is made, and turns on printing.
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
+ 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.
@@ -972,28 +1008,16 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-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
+ 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
+ -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.
-
-
-
- 25 October 2018 15
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
Example of usage: Use psnup to print two pages on the one page:
latexmk -ps -pF 'psnup -2' foo.tex
@@ -1003,15 +1027,15 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
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
+ 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, this will
- select the kind of file to be previewed (.dvi, .ps or .pdf).
- Otherwise the viewer views the "highest" kind of file selected,
- by the -dvi, -ps, -pdf, -pdfps options, in the order .dvi, .ps,
- .pdf (low to high). If no file type has been selected, the dvi
+ -pv Run file previewer. If the -view option is used, this will se-
+ lect the kind of file to be previewed (.dvi, .ps or .pdf). Oth-
+ erwise the viewer views the "highest" kind of file selected, by
+ the -dvi, -ps, -pdf, -pdfps options, in the order .dvi, .ps,
+ .pdf (low to high). If no file type has been selected, the dvi
previewer will be used. This option is incompatible with the -p
and -pvc options, so it turns them off.
@@ -1019,47 +1043,46 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-pv- Turn off -pv.
- -pvc Run a file previewer and continually update the .dvi, .ps,
+ -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
- incompatible with the -p and -pv options, so it turns these
- options off.
-
- 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.
+ 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
- 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
- apparent 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
+ 17 March 2019 16
- 25 October 2018 16
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ 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.
-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.
@@ -1077,9 +1100,9 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-pvctimeout
Do timeout in pvc mode after period of inactivity, which is 30
- min. by default. Inactivity means a period when latexmk has
- detected no file changes and hence has not taken any actions
- like compiling the document.
+ 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-
@@ -1090,7 +1113,20 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Set period of inactivity in minutes for pvc timeout.
- -quiet Same as -silent
+ -quiet
+
+
+
+ 17 March 2019 17
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ Same as -silent
-r <rcfile>
@@ -1113,30 +1149,18 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
during latexmk's parsing of its command line. See the -e option
for a way of giving initialization code directly on latexmk's
command line. An error results in latexmk stopping. Multiple
- instances of the -r and -e options can be used, and they are
-
-
-
- 25 October 2018 17
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- executed in the order they appear on the command line.
+ instances of the -r and -e options can be used, and they are ex-
+ ecuted in the order they appear on the command line.
-recorder
Give the -recorder option with latex and pdflatex. In (most)
- modern versions of these programs, this results in a file of
- extension .fls containing a list of the files that these pro-
- grams have read and written. Latexmk will then use this file to
- improve its detection of source files and generated files after
- a run of latex or pdflatex. This is the default setting of
- latexmk, unless overridden in an initialization file.
+ modern versions of these programs, this results in a file of ex-
+ tension .fls containing a list of the files that these programs
+ have read and written. Latexmk will then use this file to im-
+ prove its detection of source files and generated files after a
+ run of latex or pdflatex. This is the default setting of la-
+ texmk, unless overridden in an initialization file.
For further information, see the documentation for the $recorder
configuration variable.
@@ -1156,12 +1180,24 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-showextraoptions
Show the list of extra latex and pdflatex options that latexmk
+
+
+
+ 17 March 2019 18
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
recognizes, but that it simply passes through to the programs
latex, pdflatex, etc when they are run. These options are
(currently) a combination of those allowed by the TeXLive and
- MiKTeX implementations. (If a particular option is given to
- latexmk but is not handled by the particular implementation of
- latex or pdflatex that is being used, that program will probably
+ MiKTeX implementations. (If a particular option is given to la-
+ texmk but is not handled by the particular implementation of la-
+ tex or pdflatex that is being used, that program will probably
give an error message.) These options are very numerous, but
are not listed in this documentation because they have no effect
on latexmk's actions.
@@ -1172,27 +1208,15 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
processing by latexmk that isn't implemented (at least, not
yet).
- There are also options that are accepted by latex etc, but
- instead trigger actions by latexmk: -help, -version.
+ There are also options that are accepted by latex etc, but in-
+ stead trigger actions by latexmk: -help, -version.
Finally, there are certain options for latex and pdflatex (e.g.,
-recorder) that trigger special actions or behavior by latexmk
itself as well as being passed in some form to the called latex
and pdflatex program, or that affect other programs as well.
- These options do have entries in this documentation. These
-
-
-
- 25 October 2018 18
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- options are: -jobname=STRING, -aux-directory=dir, -output-direc-
+ These options do have entries in this documentation. These op-
+ tions are: -jobname=STRING, -aux-directory=dir, -output-direc-
tory=DIR, -quiet, and -recorder.
@@ -1202,8 +1226,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
tings, the command "latex -interaction=batchmode" is used for
latex, and similarly for its friends.
- See also the -logfilewarninglist and -logfilewarninglist-
- options.
+ See also the -logfilewarninglist and -logfilewarninglist- op-
+ tions.
Also reduce the number of informational messages that latexmk
itself generates.
@@ -1222,6 +1246,18 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
ones. This is useful to override special configurations.
The result is that $latex = 'latex %O %S', and similarly for
+
+
+
+ 17 March 2019 19
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$pdflatex, $lualatex, and $xelatex. (The option -no-pdf needed
for $xelatex is provided automatically, given that %O appears in
the definition.)
@@ -1239,25 +1275,13 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
When after a run of latex or pdflatex, there are warnings about
missing files (e.g., as requested by the LaTeX \input, \include,
and \includgraphics commands), latexmk tries to make them by a
- custom dependency. If no relevant custom dependency with an
- appropriate source file is found, and if the -use-make option is
+ custom dependency. If no relevant custom dependency with an ap-
+ propriate source file is found, and if the -use-make option is
set, then as a last resort latexmk will try to use the make pro-
gram to try to make the missing files.
Note that the filename may be specified without an extension,
e.g., by \includegraphics{drawing} in a LaTeX file. In that
-
-
-
- 25 October 2018 19
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
case, latexmk will try making drawing.ext with ext set in turn
to the possible extensions that are relevant for latex (or as
appropriate pdflatex).
@@ -1267,8 +1291,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
-use-make-
- Do not use the make program to try to make missing files.
- (Default.)
+ Do not use the make program to try to make missing files. (De-
+ fault.)
-usepretex
@@ -1290,6 +1314,16 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
latexmk -usepretex='\AtBeginDocument{Message\par}' foo.tex
+
+ 17 March 2019 20
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
-v, -version
Print version number of latexmk.
@@ -1305,25 +1339,12 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
.pdf).
Note the possibility -view=none where no viewer is opened at
- all. One example of is use is in conjunction with the -pvc
- option, when you want latexmk to do a compilation automatically
+ all. One example of is use is in conjunction with the -pvc op-
+ tion, when you want latexmk to do a compilation automatically
whenever source file(s) change, but do not want a previewer to
be opened.
-
-
-
-
- 25 October 2018 20
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
-Werror
This causes latexmk to return a non-zero status code if any of
the files processed gives a warning about problems with cita-
@@ -1357,14 +1378,26 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+
+ 17 March 2019 21
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
Compatibility between options
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.
- Options -p, -pv and -pvc are mutually exclusive. So each of these
- options turns the others off.
+ Options -p, -pv and -pvc are mutually exclusive. So each of these op-
+ tions turns the others off.
EXAMPLES
@@ -1378,18 +1411,6 @@ EXAMPLES
file thesis.tex and any files it
uses. After any changes rerun latex
the appropriate number of times and
-
-
-
- 25 October 2018 21
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
remake the postscript file. If latex
encounters an error, latexmk will
keep running, watching for
@@ -1424,30 +1445,75 @@ DEALING WITH ERRORS, PROBLEMS, ETC
of latexmk's behavior is configurable to deal with particular situa-
tions. (But there is a lot of reading!)
+
+
+ 17 March 2019 22
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
The remainder of these notes consists of ideas for dealing with more
difficult situations.
- d. Further tricks can involve replacing the standard commands that
- latexmk runs by other commands or scripts.
+ d. Further tricks can involve replacing the standard commands that la-
+ texmk runs by other commands or scripts.
e. For possible examples of code for use in an RC file, see the direc-
tory example_rcfiles in the distribution of latexmk (e.g., at
http://mirror.ctan.org/support/latexmk/example_rcfiles). Even if these
examples don't do what you want, they may provide suitable inspiration.
- f. There's a useful trick that can be used when you use lualatex
- instead of pdflatex (and in some related situations). The problem is
+ f. There's a useful trick that can be used when you use lualatex in-
+ stead of pdflatex (and in some related situations). The problem is
that latexmk won't notice a dependency on a file, bar.baz say, that is
input by the lua code in your document instead of by the LaTeX part.
(Thus if you change bar.baz and rerun latexmk, then latexmk will think
- no files have changed and not rerun lualatex, whereas if you had
- '\input{bar.baz}' in the LaTeX part of the document, latexmk would
- notice the change.) One solution is just to put the following some-
- where in the LaTeX part of the document:
+ no files have changed and not rerun lualatex, whereas if you had '\in-
+ put{bar.baz}' in the LaTeX part of the document, latexmk would notice
+ the change.) One solution is just to put the following somewhere in
+ the LaTeX part of the document:
+
+ \typeout{(bar.baz)}
+ This puts a line in the log file that latexmk will treat as implying
+ that the file bar.baz was read. (At present I don't know a way of do-
+ ing this automatically.) Of course, if the file has a different name,
+ change bar.baz to the name of your file.
+ g. See also the section "Advanced Configuration: Some extra resources".
- 25 October 2018 22
+ h. Look on tex.stackexchange, i.e., at http://tex.stackex-
+ change.com/questions/tagged/latexmk Someone may have already solved
+ your problem.
+
+ i. Ask a question at tex.stackexchange.com.
+
+ j. Or ask me (the author of latexmk). My e-mail is at the end of this
+ documentation.
+
+
+
+ALLOWING FOR CHANGE OF OUTPUT FILE TYPE
+ When one of the latex engines is run, the usual situation is that latex
+ produces a .dvi file, while pdflatex and lualatex produce a .pdf file.
+ For xelatex the default is to produce a .pdf file, but to optimize pro-
+ cessing time latexmk runs xelatex its -no-pdf option so that it pro-
+ duces an .xdv file. Further processing by latexmk takes this as a
+ starting point.
+
+ However, the actual output file may differ from the normal expectation;
+ and then latexmk can adjust its processing to accommodate this situa-
+ tion. The difference in output file type can happen for two reasons:
+ One is that for latex, pdflatex and lualatex the document itself can
+ override the defaults. The other is that there may be a configuration,
+
+
+
+ 17 March 2019 23
@@ -1456,26 +1522,72 @@ DEALING WITH ERRORS, PROBLEMS, ETC
LATEXMK(1) General Commands Manual LATEXMK(1)
- \typeout{(bar.baz)}
+ or misconfiguration, such that the program that latexmk invokes to com-
+ pile the document is not the expected one, or is given options incom-
+ patible with what latexmk initially expects. (E.g., the -output-for-
+ mat=... option could be used with lualatex, or xelatex gets invoked
+ without the -no-pdf option.)
- This puts a line in the log file that latexmk will treat as implying
- that the file bar.baz was read. (At present I don't know a way of
- doing this automatically.) Of course, if the file has a different
- name, change bar.baz to the name of your file.
+ Under latex and pdflatex, control of the output format by the document
+ is done by setting the \pdfoutput macro. Under lualatex, the \output-
+ mode macro is used instead.
- g. See also the section "Advanced Configuration: Some extra resources".
+ One example of an important use-case for document control of the output
+ format is a document that uses the psfrag package to insert graphical
+ elements in the output file. The psfrag package achieves its effects by
+ inserting postscript code in the output of the compilation of the docu-
+ ment. This entails the use of compilation to a .dvi file, followed by
+ the use of conversion to a postscript file (either directly, as by
+ dvips or implicitly, as an intermediate step by dvipdf). Then it is
+ useful to force output to be of the .dvi format by inserting \pdfout-
+ put=0 in the preamble of the document.
- h. Look on tex.stackexchange, i.e., at http://tex.stackex-
- change.com/questions/tagged/latexmk Someone may have already solved
- your problem.
+ Another example is where the document uses graphics file of the .pdf,
+ .jpg, and png types. With the default setting for the graphicx pack-
+ age, these can be processed in compilation to .pdf but not with compi-
+ lation to .dvi. In this case, it is useful to insert \pdfoutput=1 in
+ the preamble of the document to force compilation to .pdf output for-
+ mat.
- i. Ask a question at tex.stackexchange.com.
+ In all of these cases, it is needed that latexmk has to adjust its pro-
+ cessing to deal with a mismatch between the actual output format (out
+ of .pdf, .dvi, .xdv) and the initially expected output, if possible.
+ Latexmk does this provided the following conditions are met.
- j. Or ask me (the author of latexmk). My e-mail is at the end of this
- documentation.
+ The first is that latexmk's $allow_switch configuration variable is set
+ to a non-zero value as it is by default. If this variable is zero, a
+ mismatch of filetypes in the compilation results in an erro.
+
+ The second condition for latexmk to be able to handle a change of out-
+ put type is that no explicit requests for .dvi or .ps output files are
+ made. Explicit requests are by the -dvi and -ps, -print=dvi,
+ -print=ps, -view=dvi, and -view=ps options, and by corresponding set-
+ tings of the $dvi_mode, $postscript_mode, $print_type, and $view con-
+ figuration variables. The print-type and view-type restrictions only
+ apply when printing and viewing are explicitly requested, respectively.
+ For this purpose, the use of the -pdfdvi and -pdfps options (and the
+ corresponding setting of the $pdf_mode variable) does not count as an
+ explicit request for the .dvi and .ps files; they are merely regarded
+ as a request for making a .pdf file together with an initial proposal
+ for the processing route to make it.
+
+ Note that when accommodating a change in output file type, there is in-
+ volved a substantial change in the network of rules that latexmk uses
+ in its actions. The second condition applied to accommodate a change
+ is to avoid situations where the change in the rule network is too rad-
+ ical to be readily handled automatically.
+
+
+
+ 17 March 2019 24
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
CONFIGURATION/INITIALIZATION (RC) FILES
Latexmk can be customized using initialization files, which are read at
startup in the following order:
@@ -1487,7 +1599,7 @@ CONFIGURATION/INITIALIZATION (RC) FILES
"/usr/local/share/latexmk/LatexMk",
"/usr/local/lib/latexmk/LatexMk".
On a MS-Windows system it looks for "C:\latexmk\LatexMk".
- On a cygwin system (i.e., a MS-Windows system in which Perl is that
+ On a cygwin system (i.e., a MS-Windows system in which Perl is that
of cygwin), latexmk reads the first it finds of
"/cygdrive/c/latexmk/LatexMk",
"/opt/local/share/latexmk/LatexMk",
@@ -1497,71 +1609,71 @@ CONFIGURATION/INITIALIZATION (RC) FILES
In addition, it then tries the same set of locations, but with the file
name replaced "LatexMk" replaced by "latexmkrc".
- If the environment variable LATEXMKRCSYS is set, its value is used as
+ If the environment variable LATEXMKRCSYS is set, its value is used as
the name of the system RC file, instead of any of the above.
2) The user's RC file, if it exists. This can be in one of two places.
- The traditional one is ".latexmkrc" in the user's home directory. The
- other possibility is "latexmk/latexmkrc" in the user's XDG configura-
- tion home directory. The actual file read is the first of "$XDG_CON-
- FIG_HOME/latexmk/latexmkrc" or "$HOME/.latexmkrc" which exists. (See
+ The traditional one is ".latexmkrc" in the user's home directory. The
+ other possibility is "latexmk/latexmkrc" in the user's XDG configura-
+ tion home directory. The actual file read is the first of "$XDG_CON-
+ FIG_HOME/latexmk/latexmkrc" or "$HOME/.latexmkrc" which exists. (See
https://specifications.freedesktop.org/basedir-spec/basedir-spec-lat-
est.html for details on the XDG Base Directory Specification.)
- Here $HOME is the user's home directory. [Latexmk determines the
- user's home directory as follows: It is the value of the environment
+ Here $HOME is the user's home directory. [Latexmk determines the
+ user's home directory as follows: It is the value of the environment
+ variable HOME, if this variable exists, which normally is the case on
+ UNIX-like systems (including Linux and OS-X). Otherwise the environ-
+ ment variable USERPROFILE is used, if it exists, which normally is the
+ case on MS-Windows systems. Otherwise a blank string is used instead of
+ $HOME, in which case latexmk does not look for an RC file in it.]
+ $XDG_CONFIG_HOME is the value of the environment variable XDG_CON-
+ FIG_HOME if it exists. If this environment variable does not exist,
+ but $HOME is non-blank, then $XDG_CONFIG_HOME is set to the default
+ value of $HOME/.config. Otherwise $XDG_CONFIG_HOME is blank, and la-
+ texmk does not look for an RC file under it.
- 25 October 2018 23
+ 3) The RC file in the current working directory. This file can be
+ named either "latexmkrc" or ".latexmkrc", and the first of these to be
+ found is used, if any.
+ 4) Any RC file(s) specified on the command line with the -r option.
+ Each RC file is a sequence of Perl commands. Naturally, a user can use
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ 17 March 2019 25
- variable HOME, if this variable exists, which normally is the case on
- UNIX-like systems (including Linux and OS-X). Otherwise the environ-
- ment variable USERPROFILE is used, if it exists, which normally is the
- case on MS-Windows systems. Otherwise a blank string is used instead of
- $HOME, in which case latexmk does not look for an RC file in it.]
- $XDG_CONFIG_HOME is the value of the environment variable XDG_CON-
- FIG_HOME if it exists. If this environment variable does not exist,
- but $HOME is non-blank, then $XDG_CONFIG_HOME is set to the default
- value of $HOME/.config. Otherwise $XDG_CONFIG_HOME is blank, and
- latexmk does not look for an RC file under it.
- 3) The RC file in the current working directory. This file can be
- named either "latexmkrc" or ".latexmkrc", and the first of these to be
- found is used, if any.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- 4) Any RC file(s) specified on the command line with the -r option.
- Each RC file is a sequence of Perl commands. Naturally, a user can use
- this in creative ways. But for most purposes, one simply uses a
- sequence of assignment statements that override some of the built-in
- settings of Latexmk. Straightforward cases can be handled without
- knowledge of the Perl language by using the examples in this document
- as templates. Comment lines are introduced by the "#" character.
+ this in creative ways. But for most purposes, one simply uses a se-
+ quence of assignment statements that override some of the built-in set-
+ tings of Latexmk. Straightforward cases can be handled without knowl-
+ edge of the Perl language by using the examples in this document as
+ templates. Comment lines are introduced by the "#" character.
- Note that command line options are obeyed in the order in which they
+ Note that command line options are obeyed in the order in which they
are written; thus any RC file specified on the command line with the -r
- option can override previous options but can be itself overridden by
- later options on the command line. There is also the -e option, which
+ option can override previous options but can be itself overridden by
+ later options on the command line. There is also the -e option, which
allows initialization code to be specified in latexmk's command line.
- For possible examples of code for in an RC file, see the directory
- example_rcfiles in the distribution of latexmk (e.g., at http://mir-
+ For possible examples of code for in an RC file, see the directory ex-
+ ample_rcfiles in the distribution of latexmk (e.g., at http://mir-
ror.ctan.org/support/latexmk/example_rcfiles).
HOW TO SET VARIABLES IN INITIALIZATION FILES
- The important variables that can be configured are described in the
- section "List of configuration variables usable in initialization
+ The important variables that can be configured are described in the
+ section "List of configuration variables usable in initialization
files". Syntax for setting these variables is of the following forms:
$bibtex = 'bibtex %O %B';
@@ -1574,101 +1686,114 @@ HOW TO SET VARIABLES IN INITIALIZATION FILES
@default_files = ('paper', 'paper1');
- for the setting of an array of strings. It is possible to append an
+ for the setting of an array of strings. It is possible to append an
item to an array variable as follows:
+ push @default_files, 'paper2';
+
+ Note that simple "scalar" variables have names that begin with a $
+ character and array variables have names that begin with a @ character.
+ Each statement ends with a semicolon.
+
+ Strings should be enclosed in single quotes. (You could use double
+ quotes, as in many programming languages. But then the Perl program-
+ ming language brings into play some special rules for interpolating
+ variables into strings. People not fluent in Perl will want to avoid
+ these complications.)
+ You can do much more complicated things, but for this you will need to
+ consult a manual for the Perl programming language.
- 25 October 2018 24
-LATEXMK(1) General Commands Manual LATEXMK(1)
- push @default_files, 'paper2';
+ 17 March 2019 26
- Note that simple "scalar" variables have names that begin with a $
- character and array variables have names that begin with a @ character.
- Each statement ends with a semicolon.
- Strings should be enclosed in single quotes. (You could use double
- quotes, as in many programming languages. But then the Perl program-
- ming language brings into play some special rules for interpolating
- variables into strings. People not fluent in Perl will want to avoid
- these complications.)
- You can do much more complicated things, but for this you will need to
- consult a manual for the Perl programming language.
+LATEXMK(1) General Commands Manual LATEXMK(1)
FORMAT OF COMMAND SPECIFICATIONS
- Some of the variables set the commands that latexmk uses for carrying
- out its work, for example to generate a .dvi file from a .tex file or
- to view a postscript file. This section describes some important fea-
+ Some of the variables set the commands that latexmk uses for carrying
+ out its work, for example to generate a .dvi file from a .tex file or
+ to view a postscript file. This section describes some important fea-
tures of how the commands are specified. (Note that some of the possi-
- bilities listed here do not apply to the $kpsewhich variable; see its
+ bilities listed here do not apply to the $kpsewhich variable; see its
documentation.)
Placeholders: Supposed you wanted latexmk to use the command elatex in
- place of the regular latex command, and suppose moreover that you
- wanted to give it the option "--shell-escape". You could do this by
+ place of the regular latex command, and suppose moreover that you
+ wanted to give it the option "--shell-escape". You could do this by
the following setting:
$latex = 'elatex --shell-escape %O %S';
- The two items starting with the % character are placeholders. These
- are substituted by appropriate values before the command is run. Thus
- %S will be replaced by the source file that elatex will be applied to,
- and %O will be replaced by any options that latexmk has decided to use
+ The two items starting with the % character are placeholders. These
+ are substituted by appropriate values before the command is run. Thus
+ %S will be replaced by the source file that elatex will be applied to,
+ and %O will be replaced by any options that latexmk has decided to use
for this command. (E.g., if you used the -silent option in the invoca-
- tion of latexmk, it results in the replacement of %O by "-interac-
+ tion of latexmk, it results in the replacement of %O by "-interac-
tion=batchmode".)
The available placeholders are:
- %B base of filename for current command. E.g., if a postscript
- file document.ps is being made from the dvi file document.dvi,
+ %A basename of the main tex file. Unlike %R, this is unaffected by
+ the setting of a jobname by the -jobname option or the $jobname
+ configuration value.
+
+ %B base of filename for current command. E.g., if a postscript
+ file document.ps is being made from the dvi file document.dvi,
then the basename is document.
- %D destination file (e.g., the name of the postscript file when
+ %D destination file (e.g., the name of the postscript file when
converting a dvi file to postscript).
- %O options %P If the variable $pre_tex_code is non-empty, then %P
- is substituted by the contents of $pre_tex_code followed by
- \input{SOURCE}, where SOURCE stands for the name of the source
+ %O options
+
+ %P If the variable $pre_tex_code is non-empty, then %P is substi-
+ tuted by the contents of $pre_tex_code followed by \in-
+ put{SOURCE}, where SOURCE stands for the name of the source
file. Appropriate quoting is done. This enables TeX code to be
+ passed to one of the *latex engines to be executed before the
+ source file is read.
+ If the variable $pre_tex_code is the empty string, then %P is
+ equivalent to %S.
+ %R root filename. This is the base name for the main tex file.
- 25 October 2018 25
+ By default this is the basename of the main tex file. However
+ the value can be changed by the use of the -jobname option or
+ the $jobname configuration variable.
+ 17 March 2019 27
-LATEXMK(1) General Commands Manual LATEXMK(1)
- passed to one of the *latex engines to be executed before the
- source file is read.
- If the variable $pre_tex_code is the empty string, then %P is
- equivalent to %S.
- %R root filename. This is the base name for the main tex file.
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
- %S source file (e.g., the name of the dvi file when converting a
+ %S source file (e.g., the name of the dvi file when converting a
.dvi file to ps).
- %T The name of the primary tex file. %U If the variable
- $pre_tex_code is non-empty, then its value is substituted for %U
- (appropriately quoted). Otherwise it is replaced by a null
- string.
+ %T The name of the primary tex file.
+
+ %U If the variable $pre_tex_code is non-empty, then its value is
+ substituted for %U (appropriately quoted). Otherwise it is re-
+ placed by a null string.
%Y Name of directory for auxiliary output files (see the configura-
tion variable $aux_dir). A directory separation character ('/')
@@ -1680,8 +1805,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
value $out_dir.
%Z Name of directory for output files (see the configuration vari-
- able $out_dir). A directory separation character ('/') is
- appended if $out_dir is non-empty and does not end in a suitable
+ able $out_dir). A directory separation character ('/') is ap-
+ pended if $out_dir is non-empty and does not end in a suitable
character, with suitable characters being those appropriate to
UNIX and MS-Windows, i.e., ':', '/' and '\'.
@@ -1709,31 +1834,32 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Generally, you should use %B rather than %R. Similarly for most pur-
poses, the name %T of the primary texfile is not a useful placeholder.
+ See the default values in the section "List of configuration variables
+ usable in initialization files" for what is normally the most appropri-
+ ate usage.
+ If you omit to supply any placeholders whatever in the specification of
+ a command, latexmk will supply what its author thinks are appropriate
- 25 October 2018 26
+ 17 March 2019 28
-LATEXMK(1) General Commands Manual LATEXMK(1)
- See the default values in the section "List of configuration variables
- usable in initialization files" for what is normally the most appropri-
- ate usage.
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
- If you omit to supply any placeholders whatever in the specification of
- a command, latexmk will supply what its author thinks are appropriate
defaults. This gives compatibility with configuration files for previ-
ous versions of latexmk, which didn't use placeholders.
"Detaching" a command: Normally when latexmk runs a command, it waits
for the command to run to completion. This is appropriate for commands
like latex, of course. But for previewers, the command should normally
- run detached, so that latexmk gets the previewer running and then
- returns to its next task (or exits if there is nothing else to do). To
+ run detached, so that latexmk gets the previewer running and then re-
+ turns to its next task (or exits if there is nothing else to do). To
achieve this effect of detaching a command, you need to precede the
command name with "start ", as in
@@ -1742,8 +1868,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
This will be translated to whatever is appropriate for your operating
system.
- Notes: (1) In some circumstances, latexmk will always run a command
- detached. This is the case for a previewer in preview continuous mode,
+ Notes: (1) In some circumstances, latexmk will always run a command de-
+ tached. This is the case for a previewer in preview continuous mode,
since otherwise previewing continuously makes no sense. (2) This pre-
cludes the possibility of running a command named start. (3) If the
word start occurs more than once at the beginning of the command
@@ -1754,8 +1880,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Command names containing spaces: Under MS-Windows it is common that the
name of a command includes spaces, since software is often installed in
- a subdirectory of "C:\Program Files". Such command names should be
- enclosed in double quotes, as in
+ a subdirectory of "C:\Program Files". Such command names should be en-
+ closed in double quotes, as in
$lpr_pdf = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p
%S';
@@ -1774,23 +1900,23 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Command names under Cygwin: If latexmk is executed by Cygwin's Perl,
be particularly certain that pathnames in commands have forward slashes
+ not the usual backslashes for the separator of pathname components.
+ See the above examples. Backslashes often get misinterpreted by the
+ Unix shell used by Cygwin's Perl to execute external commands. Forward
+ slashes don't suffer from this problem, and (when quoted, as above) are
+ equally acceptable to MS-Windows.
- 25 October 2018 27
+ 17 March 2019 29
-LATEXMK(1) General Commands Manual LATEXMK(1)
+LATEXMK(1) General Commands Manual LATEXMK(1)
- not the usual backslashes for the separator of pathname components.
- See the above examples. Backslashes often get misinterpreted by the
- Unix shell used by Cygwin's Perl to execute external commands. Forward
- slashes don't suffer from this problem, and (when quoted, as above) are
- equally acceptable to MS-Windows.
Using MS-Windows file associations: A useful trick under modern ver-
sions of MS-Windows (e.g., WinXP) is to use just the command 'start' by
@@ -1832,41 +1958,41 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
}
For some of the more exotic possibilities that then become available,
- see the section "ADVANCED CONFIGURATION: Some extra resources and
- advanced tricks". Also see some of the examples in the directory exam-
+ see the section "ADVANCED CONFIGURATION: Some extra resources and ad-
+ vanced tricks". Also see some of the examples in the directory exam-
ple_rcfiles in the latexmk distribution.
Advanced tricks: Normally one specifies a single command for the com-
- mands invoked by latexmk. Naturally, if there is some complicated
- additional processing you need to do in your special situation, you can
+ mands invoked by latexmk. Naturally, if there is some complicated ad-
+ ditional processing you need to do in your special situation, you can
write a script (or batch file) to do the processing, and then configure
+ latexmk to use your script in place of the standard program.
+ You can also use a Perl subroutine instead of a script -- see above.
+ This is generally the most flexible and portable solution.
+ It is also possible to configure latexmk to run multiple commands. For
- 25 October 2018 28
+ 17 March 2019 30
-LATEXMK(1) General Commands Manual LATEXMK(1)
- latexmk to use your script in place of the standard program.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- You can also use a Perl subroutine instead of a script -- see above.
- This is generally the most flexible and portable solution.
- It is also possible to configure latexmk to run multiple commands. For
example, if when running pdflatex to generate a pdf file from a tex
- file you need to run another program after pdflatex to perform some
- extra processing, you could do something like:
+ file you need to run another program after pdflatex to perform some ex-
+ tra processing, you could do something like:
$pdflatex = 'pdflatex --shell-escape %O %S; pst2pdf_for_latexmk
%B';
- This definition assumes you are using a UNIX-like system (which
- includes Linux and OS-X), so that the two commands to be run are sepa-
+ This definition assumes you are using a UNIX-like system (which in-
+ cludes Linux and OS-X), so that the two commands to be run are sepa-
rated by the semicolon in the middle of the string.
If you are using MS-Windows, you would replace the above line by
@@ -1888,34 +2014,52 @@ LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES
i.e., the behavior does not occur.
+ $allow_switch [1]
+
+ This controls what happens when the output extension of latex,
+ pdflatex, lualatex or xelatex differs from what is expected.
+ (The possible extensions are .dvi, .pdf, .xdv.) This can happen
+ with the use of the \pdfoutput macro in a document compiled un-
+ der latex or pdflatex, or with the use of the \outputmode macro
+ under lualatex. It can also happen with certain kinds of incor-
+ rect configuration.
+
+ In such a case, latexmk can appropriately adjust its network of
+ rules. The adjustment is made if $allow_switch is on, and if no
+ request for a dvi or ps file has been made.
+
+ See the section ALLOWING FOR CHANGE OF OUTPUT EXTENSION.
+
+
$always_view_file_via_temporary [0]
Whether .ps and .pdf files are initially to be made in a tempo-
- rary directory and then moved to the final location. (This
- applies to dvips, dvipdf, and ps2pdf operations, and the filter-
- ing operators on .dvi and .ps files. It does not apply to
- pdflatex, unfortunately, since pdflatex provides no way of spec-
- ifying a chosen name for the output file.)
+ rary directory and then moved to the final location. (This ap-
+ plies to dvips, dvipdf, and ps2pdf operations, and the filtering
+ operators on .dvi and .ps files. It does not apply to pdflatex,
+ unfortunately, since pdflatex provides no way of specifying a
+ chosen name for the output file.)
- This use of a temporary file solves a problem that the making of
- these files can occupy a substantial time. If a viewer (notably
- gv) sees that the file has changed, it may read the new file
- before the program writing the file has not yet finished its
- work, which can cause havoc.
- See the $pvc_view_file_via_temporary variable for a setting that
- applies only if preview-continuous mode (-pvc option) is used.
- See $tmpdir for the setting of the directory where the temporary
- file is created.
+ 17 March 2019 31
- 25 October 2018 29
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ This use of a temporary file solves a problem that the making of
+ these files can occupy a substantial time. If a viewer (notably
+ gv) sees that the file has changed, it may read the new file be-
+ fore the program writing the file has not yet finished its work,
+ which can cause havoc.
+
+ See the $pvc_view_file_via_temporary variable for a setting that
+ applies only if preview-continuous mode (-pvc option) is used.
+ See $tmpdir for the setting of the directory where the temporary
+ file is created.
$analyze_input_log_always [1]
@@ -1960,30 +2104,30 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Important note: The effect of $aux_dir, if different from
$out_dir, is achieved by giving (pdf)latex the -aux-directory.
- Currently (Dec. 2011 and later) this only works on the MiKTeX
- version of (pdf)latex.
- See also the documentation of $out_dir for some complications on
- what directory names are suitable.
- If you also use the -cd option, and $out_dir (or $aux_dir) con-
- tains a relative path, then the path is interpreted relative to
- the document directory.
- $banner [0]
- If nonzero, the banner message is printed across each page when
+ 17 March 2019 32
- 25 October 2018 30
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ Currently (Dec. 2011 and later) this only works on the MiKTeX
+ version of (pdf)latex.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ See also the documentation of $out_dir for some complications on
+ what directory names are suitable.
+ If you also use the -cd option, and $out_dir (or $aux_dir) con-
+ tains a relative path, then the path is interpreted relative to
+ the document directory.
+ $banner [0]
+ If nonzero, the banner message is printed across each page when
converting the dvi file to postscript. Without modifying the
variable $banner_message, this is equivalent to specifying the
-d option.
@@ -2012,8 +2156,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
@BIBINPUTS
This is an array variable, now mostly obsolete, that specifies
- directories where latexmk should look for .bib files. By
- default it is set from the BIBINPUTS environment variable of the
+ directories where latexmk should look for .bib files. By de-
+ fault it is set from the BIBINPUTS environment variable of the
operating system. If that environment variable is not set, a
single element list consisting of the current directory is set.
The format of the directory names depends on your operating sys-
@@ -2026,29 +2170,28 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
@BIBINPUTS = ( ".", "/usr/local/texmf/bibtex/bib" );
Note that under MS Windows, either a forward slash "/" or a
- backward slash "\" can be used to separate pathname components,
- so the first two and the second two examples are equivalent.
- Each backward slash should be doubled to avoid running afoul of
- Perl's rules for writing strings.
-
- Important note: This variable is now mostly obsolete in the cur-
- rent version of latexmk, since it has a better method of search-
- ing for files using the kpsewhich command. However, if your
- system is an unusual one without the kpsewhich command, you may
- need to set the variable @BIBINPUTS.
+ 17 March 2019 33
- 25 October 2018 31
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ backward slash "\" can be used to separate pathname components,
+ so the first two and the second two examples are equivalent.
+ Each backward slash should be doubled to avoid running afoul of
+ Perl's rules for writing strings.
+ Important note: This variable is now mostly obsolete in the cur-
+ rent version of latexmk, since it has a better method of search-
+ ing for files using the kpsewhich command. However, if your
+ system is an unusual one without the kpsewhich command, you may
+ need to set the variable @BIBINPUTS.
$biber ["biber %O %S"]
The biber processing program.
@@ -2064,8 +2207,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
When using bibtex, whether to take special action to allow bib-
tex to work when $out_dir or $aux_dir is specified. In May
2018, there was planned an update to bibtex to correct a bug,
- after that update, the special action will no longer be
- required.
+ after that update, the special action will no longer be re-
+ quired.
$bibtex_silent_switch ["-terse"]
Switch(es) for the BibTeX processing program when silent mode is
@@ -2093,42 +2236,51 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
tionally delete .bbl files in a cleanup (i.e., delete them only
when the bib files all exist).
2: run bibtex or biber whenever it appears necessary to update
- the bbl files, without testing for the existence of the bib
- files; always delete .bbl files in a cleanup.
- Note that the value 1.5 does not work properly if the document
- uses biber instead of bibtex. (There's a long story why not.)
+ 17 March 2019 34
- $cleanup_includes_cusdep_generated [0]
- If nonzero, specifies that cleanup also deletes files that are
- generated by custom dependencies. (When doing a clean up, e.g.,
- 25 October 2018 32
-
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ the bbl files, without testing for the existence of the bib
+ files; always delete .bbl files in a cleanup.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ Note that the value 1.5 does not work properly if the document
+ uses biber instead of bibtex. (There's a long story why not.)
+ $cleanup_includes_cusdep_generated [0]
+ If nonzero, specifies that cleanup also deletes files that are
+ generated by custom dependencies. (When doing a clean up, e.g.,
by use of the -C option, custom dependencies are those listed in
the .fdb_latexmk file from a previous run.)
$cleanup_includes_generated [0]
If nonzero, specifies that cleanup also deletes files that are
- detected in log file as being generated (see the \openout lines
- in the log file). It will also include files made from these
- first generation generated files.
+ detected in the fls file (or failing that, in log file) as being
+ generated. It will also include files made from these first
+ generation generated files.
+
+ This operation is somewhat dangerous, and can have unintended
+ consequences, since the files to be deleted are determined from
+ a file created by (pdf)latex, which can contain erroneous infor-
+ mation. Therefore this variable is turned off by default, and
+ then files to be deleted are restricted to those explictly spec-
+ ified by patterns configured in the variables clean_ext,
+ clean_full_ext, and @generated_exts, together with those very
+ standard cases that are hardwired into latexmk (e.g., .log
+ files).
$cleanup_mode [0]
If nonzero, specifies cleanup mode: 1 for full cleanup, 2 for
- cleanup except for .dvi, .ps and .pdf files, 3 for cleanup
- except for dep and aux files. (There is also extra cleaning as
+ cleanup except for .dvi, .ps and .pdf files, 3 for cleanup ex-
+ cept for dep and aux files. (There is also extra cleaning as
specified by the $clean_ext, $clean_full_ext and @generated_exts
variables.)
@@ -2146,11 +2298,23 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
be deleted, by using the place holder %R, as in commands, and it
is also possible to use wildcards. Thus setting
- $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-
+ $clean_ext = "out %R-blx.bib %R-figures*.log pythontex-
files-%R/*";
- in an initialization file will imply that when a clean-up opera-
- tion is specified, not only is the standard set of files
+ in an initialization file will imply that when a clean-up
+
+
+
+ 17 March 2019 35
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ operation is specified, not only is the standard set of files
deleted, but also files of the form FOO.out, FOO-blx.bib, %R-
figures*.log, and pythontex-files-FOO/*, where FOO stands for
the basename of the file being processed (as in FOO.tex).
@@ -2162,100 +2326,99 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$out_dir, which is the only case supported by TeXLive, unlike
MiKTeX.)
+ The filenames specfied for a clean-up operation can refer not
+ only to regular files but also to directories. Directories are
+ only deleted if they are empty. An example of an application is
+ to pythontex, which creates files in a particular directory.
+ You can arrange to remove both the files and the directory by
+ setting
+
+ $clean_ext = "pythontex-files-%R pythontex-files-%R";
+
+ See also the variable @generated_exts.
$clean_full_ext [""]
- Extra extensions of files for latexmk to remove when the -C
- option is selected, i.e., extensions of files to remove when the
+ Extra extensions of files for latexmk to remove when the -C op-
+ tion is selected, i.e., extensions of files to remove when the
.dvi, etc files are to be cleaned-up.
More general patterns are allowed, as for $clean_ext.
+ The files specified by $clean_full_ext to be deleted are rela-
+ tive to the directory specified by $out_dir.
+ $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
+ [""]
- 25 October 2018 33
+ These variables specify commands that are executed at certain
+ points of compilations during preview-continuous mode. One mo-
+ tivation for their existance is to allow very useful convenient
+ visual indications of compilation status even when the window
+ receiving the screen output of the compilation is hidden.
+ The commands are executed at the following points: $compil-
+ ing_cmd at the start of compilation, $success_cmd at the end of
+ a completely successful compilation, $failure_cmd at the end of
+ an unsuccessful compilation, $warning_cmd at the of an otherwise
+ successful compilation that gives warnings about undefined cita-
+ tions or references or about multiply defined references. If any
+ of above variables is undefined or blank (the default situa-
+ tion), then the corresponding command is not executed.
+ However, when $warning_cmd is not set, then in the case of a
+ compilation with warnings about references or citations, but
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ 17 March 2019 36
- The files specified by $clean_full_ext to be deleted are rela-
- tive to the directory specified by $out_dir.
- $compiling_cmd [""], $failure_cmd [""], $warning_cmd [""], $success_cmd
- [""]
- These variables specify commands that are executed at certain
- points of compilations during preview-continuous mode. One
- motivation for their existance is to allow very useful conve-
- nient visual indications of compilation status even when the
- window receiving the screen output of the compilation is hidden.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- The commands are executed at the following points: $compil-
- ing_cmd at the start of compilation, $success_cmd at the end of
- a completely successful compilation, $failure_cmd at the end of
- an unsuccessful compilation, $warning_cmd at the of an otherwise
- successful compilation that gives warnings about undefined cita-
- tions or references or about multiply defined references. If any
- of above variables is undefined or blank (the default situa-
- tion), then the corresponding command is not executed.
- However, when $warning_cmd is not set, then in the case of a
- compilation with warnings about references or citations, but
- with no other error, one or other of $success_cmd or $fail-
- ure_cmd is used (if it is set) according to the setting of
+ with no other error, one or other of $success_cmd or $fail-
+ ure_cmd is used (if it is set) according to the setting of
$warnings_as_errors.
An example of a simple setting of these variables is as follows
- $compiling_cmd = "xdotool search --name \"%D\" set_window
+ $compiling_cmd = "xdotool search --name \"%D\" set_window
--name \"%D compiling\"";
- $success_cmd = "xdotool search --name \"%D\" set_window
+ $success_cmd = "xdotool search --name \"%D\" set_window
--name \"%D OK\"";
$warning_cmd = "xdotool search --name \"%D\" ".
"set_window --name \"%D CITE/REF ISSUE\"";
- $failure_cmd = "xdotool search --name \"%D\" set_window
+ $failure_cmd = "xdotool search --name \"%D\" set_window
--name \"%D FAILURE\"";
- These assume that the program xdotool is installed, that the
- previewer is using an X-Window system for display, and that the
- title of the window contains the name of the displayed file, as
- it normally does. When the commands are executed, the place-
- holder string %D is replaced by the name of the destination
+ These assume that the program xdotool is installed, that the
+ previewer is using an X-Window system for display, and that the
+ title of the window contains the name of the displayed file, as
+ it normally does. When the commands are executed, the place-
+ holder string %D is replaced by the name of the destination
file, which is the previewed file. The above commands result in
an appropriate string being appended to the filename in the win-
dow title: " compiling", " OK", or " FAILURE".
- Other placeholders that can be used are %S, %T, and %R, with %S
- and %T normally being identical. These can be useful for a com-
- mand changing the title of the edit window. The visual indica-
- tion in a window title can useful, since the user does not have
- to keep shifting attention to the (possibly hidden) compilation
+ Other placeholders that can be used are %S, %T, and %R, with %S
+ and %T normally being identical. These can be useful for a com-
+ mand changing the title of the edit window. The visual indica-
+ tion in a window title can useful, since the user does not have
+ to keep shifting attention to the (possibly hidden) compilation
window to know the status of the compilation.
-
-
- 25 October 2018 34
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- More complicated situations can best be handled by defining a
- Perl subroutine to invoke the necessary commands, and using the
- "internal" keyword in the definitions to get the subroutine to
+ More complicated situations can best be handled by defining a
+ Perl subroutine to invoke the necessary commands, and using the
+ "internal" keyword in the definitions to get the subroutine to
be invoked. (See the section "Format of Command Specifications"
for how to do this.)
- Naturally, the above settings that invoke the xdotool program
- are only applicable when the X-Window system is used for the
+ Naturally, the above settings that invoke the xdotool program
+ are only applicable when the X-Window system is used for the
relevant window(s). For other cases, you will have to find what
software solutions are available.
@@ -2264,123 +2427,122 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Custom dependency list -- see section on "Custom Dependencies".
@default_excluded_files [()]
- When latexmk is invoked with no files specified on the command
+ When latexmk is invoked with no files specified on the command
line, then, by default, it will process all files in the current
directory with the extension .tex. (In general, it will process
the files specified in the @default_files variable.)
- But sometimes you want to exclude particular files from this
- default list. In that case you can specify the excluded files
- in the array @default_excluded_files. For example if you wanted
- to process all .tex files with the exception of common.tex,
- which is a not a standard alone LaTeX file but a file input by
- some or all of the others, you could do
+ But sometimes you want to exclude particular files from this de-
+ fault list. In that case you can specify the excluded files in
+
+
+
+ 17 March 2019 37
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ the array @default_excluded_files. For example if you wanted to
+ process all .tex files with the exception of common.tex, which
+ is a not a standard alone LaTeX file but a file input by some or
+ all of the others, you could do
@default_files = ("*.tex");
@default_excluded_files = ("common.tex");
If you have a variable or large number of files to be processed,
- this method saves you from having to list them in detail in
- @default_files and having to update the list every time you
- change the set of files to be processed.
+ this method saves you from having to list them in detail in @de-
+ fault_files and having to update the list every time you change
+ the set of files to be processed.
- Notes: 1. This variable has no effect except when no files are
+ Notes: 1. This variable has no effect except when no files are
specified on the latexmk command line. 2. Wildcards are allowed
in @default_excluded_files.
@default_files [("*.tex")]
Default list of files to be processed.
- If no filenames are specified on the command line, latexmk pro-
- cesses all tex files specified in the @default_files variable,
- which by default is set to all tex files ("*.tex") in the cur-
- rent directory. This is a convenience: just run latexmk and it
- will process an appropriate set of files. But sometimes you
+ If no filenames are specified on the command line, latexmk pro-
+ cesses all tex files specified in the @default_files variable,
+ which by default is set to all tex files ("*.tex") in the cur-
+ rent directory. This is a convenience: just run latexmk and it
+ will process an appropriate set of files. But sometimes you
want only some of these files to be processed. In this case you
- can list the files to be processed by setting @default_files in
- an initialization file (e.g., the file "latexmkrc" in the cur-
- rent directory). Then if no files are specified on the command
- line then the files you specify by setting @default_files are
+ can list the files to be processed by setting @default_files in
+ an initialization file (e.g., the file "latexmkrc" in the cur-
+ rent directory). Then if no files are specified on the command
+ line then the files you specify by setting @default_files are
+ processed.
+ Three examples:
+ @default_files = ("paper_current");
- 25 October 2018 35
+ @default_files = ("paper1", "paper2.tex");
+ @default_files = ("*.tex", "*.dtx");
+ Note that more than file may be given, and that the default ex-
+ tension is ".tex". Wild cards are allowed. The parentheses are
+ because @default_files is an array variable, i.e., a sequence of
+ filename specifications is possible.
+ If you want latexmk to process all .tex files with a few excep-
+ tions, see the @default_excluded_files array variable.
+ $dependents_phony [0]
+ If a list of dependencies is output, this variable determines
+ whether to include a phony target for each source file. If you
+ use the dependents list in a Makefile, the dummy rules work
+ around errors make gives if you remove header files without
-LATEXMK(1) General Commands Manual LATEXMK(1)
- processed.
+ 17 March 2019 38
- Three examples:
- @default_files = ("paper_current");
- @default_files = ("paper1", "paper2.tex");
- @default_files = ("*.tex", "*.dtx");
- Note that more than file may be given, and that the default
- extension is ".tex". Wild cards are allowed. The parentheses
- are because @default_files is an array variable, i.e., a
- sequence of filename specifications is possible.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- If you want latexmk to process all .tex files with a few excep-
- tions, see the @default_excluded_files array variable.
- $dependents_phony [0]
- If a list of dependencies is output, this variable determines
- whether to include a phony target for each source file. If you
- use the dependents list in a Makefile, the dummy rules work
- around errors make gives if you remove header files without
updating the Makefile to match.
$dependents_list [0]
- Whether to display a list(s) of dependencies at the end of a
+ Whether to display a list(s) of dependencies at the end of a
run.
$deps_file ["-"]
- Name of file to receive list(s) of dependencies at the end of a
- run, to be used if $dependesnt_list is set. If the filename is
- "-", then the dependency list is set to stdout (i.e., normally
+ Name of file to receive list(s) of dependencies at the end of a
+ run, to be used if $dependesnt_list is set. If the filename is
+ "-", then the dependency list is set to stdout (i.e., normally
the screen).
$do_cd [0]
- Whether to change working directory to the directory specified
- for the main source file before processing it. The default
- behavior is not to do this, which is the same as the behavior of
- latex and pdflatex programs. This variable is set by the -cd
+ Whether to change working directory to the directory specified
+ for the main source file before processing it. The default be-
+ havior is not to do this, which is the same as the behavior of
+ latex and pdflatex programs. This variable is set by the -cd
and -cd- options on latexmk's command line.
$dvi_filter [empty]
- The dvi file filter to be run on the newly produced dvi file
- before other processing. Equivalent to specifying the -dF
- option.
+ The dvi file filter to be run on the newly produced dvi file be-
+ fore other processing. Equivalent to specifying the -dF option.
$dvi_mode [See below for default]
If nonzero, generate a dvi version of the document. Equivalent
to the -dvi option.
- The variable $dvi_mode defaults to 0, but if no explicit
- requests are made for other types of file (postscript, pdf),
- then $dvi_mode will be set to 1. In addition, if a request for
-
-
-
- 25 October 2018 36
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- a file for which a .dvi file is a prerequisite, then $dvi_mode
+ The variable $dvi_mode defaults to 0, but if no explicit re-
+ quests are made for other types of file (postscript, pdf), then
+ $dvi_mode will be set to 1. In addition, if a request for a
+ file for which a .dvi file is a prerequisite, then $dvi_mode
will be set to 1.
$dvi_previewer ["start xdvi %O %S" under UNIX]
@@ -2405,6 +2567,17 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
the MS-Windows start program, which will cause to be run what-
ever command the system has associated with .dvi files.]
+
+
+ 17 March 2019 39
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
$dvipdf ["dvipdf %O %S %D"]
Command to convert .dvi to .pdf file. A common reconfiguration
is to use the dvipdfm command, which needs its arguments in a
@@ -2429,23 +2602,11 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$dvips ["dvips %O -o %D %S"]
The program to used as a filter to convert a .dvi file to a .ps
file. If pdf is going to be generated from pdf, then the value
- of the $dvips_pdf_switch variable -- see below -- will be
- included in the options substituted for "%O".
+ of the $dvips_pdf_switch variable -- see below -- will be in-
+ cluded in the options substituted for "%O".
$dvips_landscape ["dvips -tlandscape %O -o %D %S"]
The program to used as a filter to convert a .dvi file to a .ps
-
-
-
- 25 October 2018 37
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
file in landscape mode.
$dvips_pdf_switch ["-P pdf"]
@@ -2464,13 +2625,25 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$dvi_update_method [2 under UNIX, 1 under MS-Windows]
How the dvi viewer updates its display when the dvi file has
- changed. The values here apply equally to the
- $pdf_update_method and to the $ps_update_method variables.
+ changed. The values here apply equally to the $pdf_up-
+ date_method and to the $ps_update_method variables.
0 => update is automatic,
1=> manual update by user, which may only mean a mouse click
on the viewer's window or may mean a more serious action.
2 => Send the signal, whose number is in the variable
$dvi_update_signal. The default value under UNIX is suitable
+
+
+
+ 17 March 2019 40
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
for xdvi.
3 => Viewer cannot do an update, because it locks the file.
(As with acroread under MS-Windows.)
@@ -2484,8 +2657,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
value]
The number of the signal that is sent to the dvi viewer when it
is updated by sending a signal -- see the information on the
- variable $dvi_update_method. The default value is the one
- appropriate for xdvi on a UNIX system.
+ variable $dvi_update_method. The default value is the one ap-
+ propriate for xdvi on a UNIX system.
$failure_cmd [undefined]
See the documentation for $compiling_cmd.
@@ -2498,36 +2671,24 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$filetime_causality_threshold [5]; $filetime_offset_report_threshold
[30]. (Units of seconds.)
- These variables control how latexmk deals with the following
- issue, which can affect the use of files that are on a remote
-
-
-
- 25 October 2018 38
-
-
-
-
-
-LATEXMK(1) General Commands Manual LATEXMK(1)
-
-
- filesystem (network share) instead of being on a file system
- local to the computer running latexmk. Almost users will not
- have to worry about these settings, and can ignore the following
- explanation.
+ These variables control how latexmk deals with the following is-
+ sue, which can affect the use of files that are on a remote
+ filesystem (network share) instead of being on a file system lo-
+ cal to the computer running latexmk. Almost users will not have
+ to worry about these settings, and can ignore the following ex-
+ planation.
In almost all situations, latexmk does not need to use the time
stamps of the files it works with. However, there are a couple
of situations when it needs to know whether a certain file was
created in the current run of a program (e.g., (pdf)latex) or is
a leftover file from a previous run. It does this by comparing
- the modification time of the file with the system time just
- before the program was started. If the modification time is ear-
+ the modification time of the file with the system time just be-
+ fore the program was started. If the modification time is ear-
lier than when the program was started, the file is a leftover
file, which latexmk treats as if it were not created. If the
- filetime is at least the program start time, then it can be
- assumed that the file was created in the current run.
+ filetime is at least the program start time, then it can be as-
+ sumed that the file was created in the current run.
Unfortunately, this test can fail if the file is on a remote
system, since its system time is not necessarily synchronized
@@ -2538,6 +2699,17 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
(a second or so, or a few seconds). But even a small difference
can mess up latexmk's test.
+
+
+ 17 March 2019 41
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
Latexmk measures the time difference between the time on the two
systems and compensates for this. But the measurement (in a
system-independent way) is only accurate to a second or two. So
@@ -2567,46 +2739,49 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
ing unrecognized cross references. Equivalent to specifying the
-f option.
+ @generated_exts [( aux , bbl , idx , ind , lof , lot , out , toc ,
+ $fdb_ext )]
+ This contains a list of extensions for files that are generated
+ during a LaTeX run and that are read in by LaTeX in later runs,
+ either directly or indirectly.
+ This list specifies files known to be generated by latex (and
+ pdflatex, etc). It is used in two ways: (a) The specified files
+ are deleted in a cleanup operation (with the -c, -C, -CA, -g and
+ -gg options), and (b) It affects the determination of whether a
+ rerun of (pdf)LaTeX is needed after a run that gives an error.
+
+ (Concerning item (b): Normally, a change of a source file during
+ a run should provoke a rerun. This includes a file generated by
+ LaTeX, e.g., an aux file, that is read in on subsequent runs.
+ But after a run that results in an error, a new run should not
+ occur until the user has made a change in the files. But the
+ user may have corrected an error in a source .tex file during
+ the run. So latexmk needs to distinguish user-generated and au-
+ tomatically generated files; it determines the automatically
+ generated files as those with extensions in the list in @gener-
+ ated_exts.)
- 25 October 2018 39
+ A convenient way to add an extra extension to the list, without
+ losing the already defined ones is to use a push command in the
+ 17 March 2019 42
-LATEXMK(1) General Commands Manual LATEXMK(1)
- @generated_exts [( aux , bbl , idx , ind , lof , lot , out , toc ,
- $fdb_ext )]
- This contains a list of extensions for files that are generated
- during a LaTeX run and that are read in by LaTeX in later runs,
- either directly or indirectly.
- This list has two uses: (a) to set the kinds of file to be
- deleted in a cleanup operation (with the -c, -C, -CA, -g and -gg
- options), and (b) in the determination of whether a rerun of
- (pdf)LaTeX is needed after a run that gives an error.
-
- (Normally, a change of a source file during a run should provoke
- a rerun. This includes a file generated by LaTeX, e.g., an aux
- file, that is read in on subsequent runs. But after a run that
- results in an error, a new run should occur until the user has
- made a change in the files. But the user may have corrected an
- error in a source .tex file during the run. So latexmk needs to
- distinguish user-generated and automatically generated files; it
- determines the automatically generated files as those with
- extensions in the list in @generated_exts.)
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
- A convenient way to add an extra extension to the list, without
- losing the already defined ones is to use a push command in the
line in an RC file. E.g.,
push @generated_exts, "end";
- adds the extension "end" to the list of predefined generated
- extensions. (This extension is used by the RevTeX package, for
+ adds the extension "end" to the list of predefined generated ex-
+ tensions. (This extension is used by the RevTeX package, for
example.)
$go_mode [0]
@@ -2632,40 +2807,40 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: ';
+ This creates a rule for files with extension .eps about lines to
+ ignore. The left-hand side is a Perl idiom for setting an item
+ in a hash. Note that the file extension is specified without a
+ period. The value, on the right-hand side, is a string contain-
+ ing a regular expresssion. (See documentation on Perl for how
+ they are to be specified in general.) This particular regular
+ expression specifies that lines beginning with "%%CreationDate:
+ " are to be ignored in deciding whether a file of the given ex-
+ tension .eps has changed.
+ There is only one regular expression available for each exten-
+ sion. If you need more one pattern to specify lines to ignore,
+ then you need to combine the patterns into a single regular ex-
+ pression. The simplest method is separate the different simple
+ patterns by a vertical bar character (indicating "alternation"
+ in the jargon of regular expressions). For example,
+ $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate: |^%%Ti-
+ tle: ';
- 25 October 2018 40
+ causes lines starting with either "^%%CreationDate: " or "^%%Ti-
+ tle: " to be ignored.
+ 17 March 2019 43
-LATEXMK(1) General Commands Manual LATEXMK(1)
- This creates a rule for files with extension .eps about lines to
- ignore. The left-hand side is a Perl idiom for setting an item
- in a hash. Note that the file extension is specified without a
- period. The value, on the right-hand side, is a string contain-
- ing a regular expresssion. (See documentation on Perl for how
- they are to be specified in general.) This particular regular
- expression specifies that lines beginning with "%%CreationDate:
- " are to be ignored in deciding whether a file of the given
- extension .eps has changed.
- There is only one regular expression available for each exten-
- sion. If you need more one pattern to specify lines to ignore,
- then you need to combine the patterns into a single regular
- expression. The simplest method is separate the different sim-
- ple patterns by a vertical bar character (indicating "alterna-
- tion" in the jargon of regular expressions). For example,
- $hash_calc_ignore_pattern{'eps'} = '^%%CreationDate:
- |^%%Title: ';
+LATEXMK(1) General Commands Manual LATEXMK(1)
- causes lines starting with either "^%%CreationDate: " or
- "^%%Title: " to be ignored.
It may happen that a pattern to be ignored is specified in, for
example, in a system or user initialization file, and you wish
@@ -2675,33 +2850,56 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
delete $hash_calc_ignore_pattern{'eps'};
+ $jobname [""]
+
+ This specifies the jobname, i.e., the basename that is used for
+ generated files (.aux, .log, .dvi, .ps, .pdf, etc). If this
+ variable is a null string, then the basename is the basename of
+ the main tex file. (At present, the string in $jobname should
+ not contain spaces.)
+
+ The placeholder '%A' is permitted. This will be substituted by
+ the basename of the TeX file. The primary purpose is when a va-
+ riety of tex files are to be processed, and you want to use a
+ different jobname for each but one that is distinct for each.
+ Thus if you wanted to compare compilations of a set of files on
+ different operating systems, with distinct filenames for all the
+ cases, you could set
+
+ $jobname = "%A-$^O";
+
+ in an initialization file. (Here $^O is a variable provided by
+ perl that contains perl's name for the operating system.)
+
+ Suppose you had .tex files test1.tex and test2.tex. Then when
+ you run
+
+ latexmk -pdf *.tex
+
+ both files will be compiled. The .aux, .log, and .pdf files
+ will have basenames test1-MSWin32 ante test2-MSWin32 on a MS-
+ Windows system, test1-darwin and test2-darwin on an OS-X system,
+ and a variety of similar cases on linux systems.
+
+
$kpsewhich ["kpsewhich %S"]
- The program called to locate a source file when the name alone
- is not sufficient. Most filenames used by latexmk have suffi-
- cient path information to be found directly. But sometimes,
- notably when a .bib or a .bst file is found from the log file of
- a bibtex or biber run, only the base name of the file is known,
+ The program called to locate a source file when the name alone
+ is not sufficient. Most filenames used by latexmk have suffi-
+ cient path information to be found directly. But sometimes, no-
+ tably when a .bib or a .bst file is found from the log file of a
+ bibtex or biber run, only the base name of the file is known,
but not its path. The program specified by $kpsewhich is used to
find it.
- (For advanced users: Because of the different way in which
- latexmk uses the command specified in $kpsewhich, some of the
- possibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do
- not apply. The internal and start keywords are not available. A
+ (For advanced users: Because of the different way in which la-
+ texmk uses the command specified in $kpsewhich, some of the pos-
+ sibilities listed in the FORMAT OF COMMAND SPECIFICATIONS do not
+ apply. The internal and start keywords are not available. A
simple command specification with possible options and then "%S"
- is all that is guaranteed to work. Note that for other com-
- mands, "%S" is substituted by a single source file. In contrast,
- for $kpsewhich, "%S" may be substituted by a long list of space-
- separated filenames, each of which is quoted. The result on
- STDOUT of running the command is then piped to latexmk.)
-
- See also the @BIBINPUTS variable for another way that latexmk
- also uses to try to locate files; it applies only in the case of
- .bib files.
- 25 October 2018 41
+ 17 March 2019 44
@@ -2710,24 +2908,34 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
+ is all that is guaranteed to work. Note that for other com-
+ mands, "%S" is substituted by a single source file. In contrast,
+ for $kpsewhich, "%S" may be substituted by a long list of space-
+ separated filenames, each of which is quoted. The result on
+ STDOUT of running the command is then piped to latexmk.)
+
+ See also the @BIBINPUTS variable for another way that latexmk
+ also uses to try to locate files; it applies only in the case of
+ .bib files.
+
$kpsewhich_show [0]
- Whether to show diagnostics about invocations of kpsewhich: the
- command line use to invoke it and the results. These diagnos-
- tics are shown if $kpsewhich_show is non-zero or if diagnostics
- mode is on. (But in the second case, lots of other diagnostics
- are also shown.) Without these diagnostics there is nothing
- visible in latexmk's screen output about invocations of kpse-
+ Whether to show diagnostics about invocations of kpsewhich: the
+ command line use to invoke it and the results. These diagnos-
+ tics are shown if $kpsewhich_show is non-zero or if diagnostics
+ mode is on. (But in the second case, lots of other diagnostics
+ are also shown.) Without these diagnostics there is nothing
+ visible in latexmk's screen output about invocations of kpse-
which.
$landscape_mode [0]
If nonzero, run in landscape mode, using the landscape mode pre-
- viewers and dvi to postscript converters. Equivalent to the -l
+ viewers and dvi to postscript converters. Equivalent to the -l
option. Normally not needed with current previewers.
$latex ["latex %O %S"]
- Specifies the command line for the LaTeX processing program.
- Note that as with other programs, you can use this variable not
- just to change the name of the program used, but also specify
+ Specifies the command line for the LaTeX processing program.
+ Note that as with other programs, you can use this variable not
+ just to change the name of the program used, but also specify
options to the program. E.g.,
$latex = "latex --src-specials %O %S";
@@ -2737,78 +2945,78 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
%latex_input_extensions
- This variable specifies the extensions tried by latexmk when it
- finds that a LaTeX run resulted in an error that a file has not
- been found, and the file is given without an extension. This
- typically happens when LaTeX commands of the form \input{file}
- or \includegraphics{figure}, when the relevant source file does
+ This variable specifies the extensions tried by latexmk when it
+ finds that a LaTeX run resulted in an error that a file has not
+ been found, and the file is given without an extension. This
+ typically happens when LaTeX commands of the form \input{file}
+ or \includegraphics{figure}, when the relevant source file does
not exist.
- In this situation, latexmk searches for custom dependencies to
- make the missing file(s), but restricts it to the extensions
- specified by the variable %latex_input_extensions. The default
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %latex_input_extensions. The default
extensions are 'tex' and 'eps'.
- (For Perl experts: %latex_input_extensions is a hash whose keys
- are the extensions. The values are irrelevant.) Two subrou-
- tines are provided for manipulating this and the related vari-
- able %pdflatex_input_extensions, add_input_ext and
- remove_input_ext. They are used as in the following examples
- are possible lines in an initialization file:
+ (For Perl experts: %latex_input_extensions is a hash whose keys
+ are the extensions. The values are irrelevant.) Two subrou-
+ tines are provided for manipulating this and the related vari-
+ able %pdflatex_input_extensions, add_input_ext and remove_in-
+ put_ext. They are used as in the following examples are
- remove_input_ext( 'latex', 'tex' );
- removes the extension 'tex' from latex_input_extensions
- add_input_ext( 'latex', 'asdf' );
+ 17 March 2019 45
- add the extension 'asdf to latex_input_extensions. (Naturally
- with such an extension, you should have made an appropriate
- 25 October 2018 42
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ possible lines in an initialization file:
+ remove_input_ext( 'latex', 'tex' );
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ removes the extension 'tex' from latex_input_extensions
+ add_input_ext( 'latex', 'asdf' );
- custom dependency for latexmk, and should also have done the
- appropriate programming in the LaTeX source file to enable the
- file to be read. The standard extensions are handled by LaTeX
- and its graphics/graphicx packages.)
+ add the extension 'asdf to latex_input_extensions. (Naturally
+ with such an extension, you should have made an appropriate cus-
+ tom dependency for latexmk, and should also have done the appro-
+ priate programming in the LaTeX source file to enable the file
+ to be read. The standard extensions are handled by LaTeX and
+ its graphics/graphicx packages.)
$latex_silent_switch ["-interaction=batchmode"]
- Switch(es) for the LaTeX processing program when silent mode is
+ Switch(es) for the LaTeX processing program when silent mode is
on.
- If you use MikTeX, you may prefer the results if you configure
- the options to include -c-style-errors, e.g., by the following
+ If you use MikTeX, you may prefer the results if you configure
+ the options to include -c-style-errors, e.g., by the following
line in an initialization file
- $latex_silent_switch = "-interaction=batchmode -c-style-
- errors";
+ $latex_silent_switch = "-interaction=batchmode -c-style-er-
+ rors";
$lpr ["lpr %O %S" under UNIX/Linux, "NONE lpr" under MS-Windows]
The command to print postscript files.
- Under MS-Windows (unlike UNIX/Linux), there is no standard pro-
+ Under MS-Windows (unlike UNIX/Linux), there is no standard pro-
gram for printing files. But there are ways you can do it. For
example, if you have gsview installed, you could use it with the
option "/p":
$lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
- If gsview is installed in a different directory, you will need
- to make the appropriate change. Note the combination of single
- and double quotes around the name. The single quotes specify
- that this is a string to be assigned to the configuration vari-
- able $lpr. The double quotes are part of the string passed to
- the operating system to get the command obeyed; this is neces-
+ If gsview is installed in a different directory, you will need
+ to make the appropriate change. Note the combination of single
+ and double quotes around the name. The single quotes specify
+ that this is a string to be assigned to the configuration vari-
+ able $lpr. The double quotes are part of the string passed to
+ the operating system to get the command obeyed; this is neces-
sary because one part of the command name ("Program Files") con-
tains a space which would otherwise be misinterpreted.
@@ -2818,33 +3026,31 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$lpr_pdf ["NONE lpr_pdf"]
The printing program to print pdf files.
- Under MS-Windows you could set this to use gsview, if it is
- installed, e.g.,
-
- $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+ Under MS-Windows you could set this to use gsview, if it is in-
+ stalled, e.g.,
- If gsview is installed in a different directory, you will need
- to make the appropriate change. Note the double quotes around
- the name: this is necessary because one part of the command name
- ("Program Files") contains a space which would otherwise be mis-
- interpreted.
+ 17 March 2019 46
- 25 October 2018 43
-
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ $lpr = '"c:/Program Files/Ghostgum/gsview/gsview32.exe" /p';
+ If gsview is installed in a different directory, you will need
+ to make the appropriate change. Note the double quotes around
+ the name: this is necessary because one part of the command name
+ ("Program Files") contains a space which would otherwise be mis-
+ interpreted.
$lualatex ["lualatex %O %S"]
Specifies the command line for the LaTeX processing program that
- is to be used when the lualatex program is called for (e.g., by
+ is to be used when the lualatex program is called for (e.g., by
the option -lualatex.
To do a coordinated setting of all of $latex, $pdflatex, $luala-
@@ -2852,26 +3058,26 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
%lualatex_input_extensions
- This variable specifies the extensions tried by latexmk when it
- finds that a lualatex run resulted in an error that a file has
- not been found, and the file is given without an extension.
- This typically happens when LaTeX commands of the form
- \input{file} or \includegraphics{figure}, when the relevant
- source file does not exist.
+ This variable specifies the extensions tried by latexmk when it
+ finds that a lualatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
+ file does not exist.
- In this situation, latexmk searches for custom dependencies to
- make the missing file(s), but restricts it to the extensions
- specified by the variable %pdflatex_input_extensions. The
- default extensions are 'tex', 'pdf', 'jpg, and 'png'.
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %pdflatex_input_extensions. The de-
+ fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
See details of the %latex_input_extensions for other information
that equally applies to %lualatex_input_extensions.
$lualatex_silent_switch ["-interaction=batchmode"]
- Switch(es) for the lualatex program (specified in the variable
+ Switch(es) for the lualatex program (specified in the variable
$lualatex) when silent mode is on.
- See details of the $latex_silent_switch for other information
+ See details of the $latex_silent_switch for other information
that equally applies to $lualatex_silent_switch.
$make ["make"]
@@ -2881,91 +3087,83 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
The index processing program.
$makeindex_silent_switch ["-q"]
- Switch(es) for the index processing program when silent mode is
+ Switch(es) for the index processing program when silent mode is
on.
$max_repeat [5]
- The maximum number of times latexmk will run latex/pdflatex
- before deciding that there may be an infinite loop and that it
+ The maximum number of times latexmk will run latex/pdflatex be-
+ fore deciding that there may be an infinite loop and that it
needs to bail out, rather than rerunning latex/pdflatex again to
- resolve cross-references, etc. The default value covers all
- normal cases.
- (Note that the "etc" covers a lot of cases where one run of
- latex/pdflatex generates files to be read in on a later run.)
- $MSWin_back_slash [1]
- This configuration variable only has an effect when latexmk is
+ 17 March 2019 47
- 25 October 2018 44
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ resolve cross-references, etc. The default value covers all
+ normal cases.
+ (Note that the "etc" covers a lot of cases where one run of la-
+ tex/pdflatex generates files to be read in on a later run.)
+ $MSWin_back_slash [1]
+ This configuration variable only has an effect when latexmk is
running under MS-Windows. It determines whether, when a command
- is executed under MS-Windows, there should be substituted "\"
- for the separator character between components of a directory
- name. Internally, latexmk uses "/" for the directory separator
+ is executed under MS-Windows, there should be substituted "\"
+ for the separator character between components of a directory
+ name. Internally, latexmk uses "/" for the directory separator
character, which is the character used by Unix-like systems.
For many programs under MS-Windows, both "\" and "/" are accept-
- able as the directory separator character. But some programs
- only accept "\" on the command line. So for safety latexmk
- makes a translation, by default. It is conceivable that under
+ able as the directory separator character. But some programs
+ only accept "\" on the command line. So for safety latexmk
+ makes a translation, by default. It is conceivable that under
certain situations this is undesirable, so the configuration can
be changed. (A possible example might be when some of the soft-
- ware is implemented using Cygwin, which provides a Unix-like
- environment inside MS-Windows.)
+ ware is implemented using Cygwin, which provides a Unix-like en-
+ vironment inside MS-Windows.)
$new_viewer_always [0]
- This variable applies to latexmk only in continuous-preview
+ This variable applies to latexmk only in continuous-preview
mode. If $new_viewer_always is 0, latexmk will check for a pre-
- viously running previewer on the same file, and if one is run-
- ning will not start a new one. If $new_viewer_always is non-
- zero, this check will be skipped, and latexmk will behave as if
+ viously running previewer on the same file, and if one is run-
+ ning will not start a new one. If $new_viewer_always is non-
+ zero, this check will be skipped, and latexmk will behave as if
no viewer is running.
$out_dir [""]
- If non-blank, this variable specifies the directory in which
+ If non-blank, this variable specifies the directory in which
output files are to be written by a run of (pdf)latex. See also
the variable $aux_dir.
- The effect of this variable (when non-blank) is achieved by
- using the -output-directory option of (pdf)latex. This exists
- in the usual current (Dec. 2011 and later) implementations of
- TeX, i.e., MiKTeX and TeXLive. But it may not be present in
- other versions.
+ The effect of this variable (when non-blank) is achieved by us-
+ ing the -output-directory option of (pdf)latex. This exists in
+ the usual current (Dec. 2011 and later) implementations of TeX,
+ i.e., MiKTeX and TeXLive. But it may not be present in other
+ versions.
- If you also use the -cd option, and $out_dir (or $aux_dir) con-
- tains a relative path, then the path is interpreted relative to
+ If you also use the -cd option, and $out_dir (or $aux_dir) con-
+ tains a relative path, then the path is interpreted relative to
the document directory.
- Commonly, the directory specified for output files is a subdi-
+ Commonly, the directory specified for output files is a subdi-
rectory of the current working directory. However, if you spec-
- ify some other directory, e.g., "/tmp/foo" or "../output", be
- aware that this could cause problems, e.g., with makeindex or
- bibtex. This is because modern versions of these programs, by
- default, will refuse to work when they find that they are asked
- to write to a file in a directory that appears not to be the
+ ify some other directory, e.g., "/tmp/foo" or "../output", be
+ aware that this could cause problems, e.g., with makeindex or
+ bibtex. This is because modern versions of these programs, by
+ default, will refuse to work when they find that they are asked
+ to write to a file in a directory that appears not to be the
current working directory or one of its subdirectories. This is
- part of security measures by the whole TeX system that try to
- prevent malicious or errant TeX documents from incorrectly mess-
- ing with a user's files. If for $out_dir or $aux_dir you really
- do need to specify an absolute pathname (e.g., "/tmp/foo") or a
- path (e.g., "../output") that includes a higher-level directory,
- and you need to use makeindex or bibtex, then you need to dis-
- able the security measures (and assume any risks). One way of
- doing this is to temporarily set an operating system environment
- 25 October 2018 45
+ 17 March 2019 48
@@ -2974,26 +3172,34 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
- variable openout_any to "a" (as in "all"), to override the
- default "paranoid" setting.
+ part of security measures by the whole TeX system that try to
+ prevent malicious or errant TeX documents from incorrectly mess-
+ ing with a user's files. If for $out_dir or $aux_dir you really
+ do need to specify an absolute pathname (e.g., "/tmp/foo") or a
+ path (e.g., "../output") that includes a higher-level directory,
+ and you need to use makeindex or bibtex, then you need to dis-
+ able the security measures (and assume any risks). One way of
+ doing this is to temporarily set an operating system environment
+ variable openout_any to "a" (as in "all"), to override the de-
+ fault "paranoid" setting.
$pdf_mode [0]
- If zero, do NOT generate a pdf version of the document. If
- equal to 1, generate a pdf version of the document using pdfla-
- tex, using the command specified by the $pdflatex variable. If
- equal to 2, generate a pdf version of the document from the ps
- file, by using the command specified by the $ps2pdf variable.
- If equal to 3, generate a pdf version of the document from the
- dvi file, by using the command specified by the $dvipdf vari-
- able. If equal to 4, generate a pdf version of the document
- using lualatex, using the command specified by the $lualatex
- variable. If equal to 5, generate a pdf version (and an xdv
- version) of the document using xelatex, using the commands spec-
- ified by the $xelatex and xdvipdfmx variables.
-
- In $pdf_mode=2, it is ensured that .dvi and .ps files are also
- made. In $pdf_mode=3, it is ensured that a .dvi file is also
- made.
+ If zero, do NOT generate a pdf version of the document. If
+ equal to 1, generate a pdf version of the document using pdfla-
+ tex, using the command specified by the $pdflatex variable. If
+ equal to 2, generate a pdf version of the document from the ps
+ file, by using the command specified by the $ps2pdf variable.
+ If equal to 3, generate a pdf version of the document from the
+ dvi file, by using the command specified by the $dvipdf vari-
+ able. If equal to 4, generate a pdf version of the document us-
+ ing lualatex, using the command specified by the $lualatex vari-
+ able. If equal to 5, generate a pdf version (and an xdv ver-
+ sion) of the document using xelatex, using the commands speci-
+ fied by the $xelatex and xdvipdfmx variables.
+
+ In $pdf_mode=2, it is ensured that .dvi and .ps files are also
+ made. In $pdf_mode=3, it is ensured that a .dvi file is also
+ made. But this may be overridden by the document.
$pdflatex ["pdflatex %O %S"]
Specifies the command line for the LaTeX processing program in a
@@ -3004,100 +3210,92 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$pdflatex = "pdflatex --shell-escape %O %S";
- (In some earlier versions of latexmk, you needed to use an
- assignment to $pdflatex to allow the use of lualatex or xelatex
+ (In some earlier versions of latexmk, you needed to use an as-
+ signment to $pdflatex to allow the use of lualatex or xelatex
instead of pdflatex. There are now separate configuration vari-
- ables for the use of lualatex or xelatex. See $lualatex and
+ ables for the use of lualatex or xelatex. See $lualatex and
$xelatex.)
To do a coordinated setting of all of $latex, $pdflatex, $luala-
tex, and $xelatex, see the section "Advanced Configuration".
%pdflatex_input_extensions
- This variable specifies the extensions tried by latexmk when it
- finds that a pdflatex run resulted in an error that a file has
- not been found, and the file is given without an extension.
- This typically happens when LaTeX commands of the form
- \input{file} or \includegraphics{figure}, when the relevant
- source file does not exist.
+ This variable specifies the extensions tried by latexmk when it
+ finds that a pdflatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
+ file does not exist.
- In this situation, latexmk searches for custom dependencies to
- make the missing file(s), but restricts it to the extensions
- specified by the variable %pdflatex_input_extensions. The
- default extensions are 'tex', 'pdf', 'jpg, and 'png'.
- See details of the %latex_input_extensions for other information
- that equally applies to %pdflatex_input_extensions.
+ 17 March 2019 49
- 25 October 2018 46
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %pdflatex_input_extensions. The de-
+ fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
+ See details of the %latex_input_extensions for other information
+ that equally applies to %pdflatex_input_extensions.
$pdflatex_silent_switch ["-interaction=batchmode"]
- Switch(es) for the pdflatex program (specified in the variable
+ Switch(es) for the pdflatex program (specified in the variable
$pdflatex) when silent mode is on.
- See details of the $latex_silent_switch for other information
+ See details of the $latex_silent_switch for other information
that equally applies to $pdflatex_silent_switch.
$pdf_previewer ["start acroread %O %S"]
The command to invoke a pdf-previewer.
- On MS-Windows, the default is changed to "cmd /c start """;
- under more recent versions of Windows, this will cause to be run
+ On MS-Windows, the default is changed to "cmd /c start """; un-
+ der more recent versions of Windows, this will cause to be run
whatever command the system has associated with .pdf files. But
- this may be undesirable if this association is to acroread --
+ this may be undesirable if this association is to acroread --
see the notes in the explanation of the -pvc option.]
- On OS-X the default is changed to "open %S", which results in
- OS-X starting up (and detaching) the viewer associated with the
- file. By default, for pdf files this association is to OS-X's
+ On OS-X the default is changed to "open %S", which results in
+ OS-X starting up (and detaching) the viewer associated with the
+ file. By default, for pdf files this association is to OS-X's
preview, which is quite satisfactory.
- WARNING: Problem under MS-Windows: if acroread is used as the
- pdf previewer, and it is actually viewing a pdf file, the pdf
- file cannot be updated. Thus makes acroread a bad choice of
- previewer if you use latexmk's previous-continuous mode (option
- -pvc) under MS-windows. This problem does not occur if, for
- example, SumatraPDF or gsview is used to view pdf files.
+ WARNING: Problem under MS-Windows: if acroread is used as the
+ pdf previewer, and it is actually viewing a pdf file, the pdf
+ file cannot be updated. Thus makes acroread a bad choice of
+ previewer if you use latexmk's previous-continuous mode (option
+ -pvc) under MS-windows. This problem does not occur if, for ex-
+ ample, SumatraPDF or gsview is used to view pdf files.
- Important note: Normally you will want to have a previewer run
+ Important note: Normally you will want to have a previewer run
detached, so that latexmk doesn't wait for the previewer to ter-
- minate before continuing its work. So normally you should pre-
- fix the command by "start ", which flags to latexmk that it
- should do the detaching of the previewer itself (by whatever
- method is appropriate to the operating system). But sometimes
+ minate before continuing its work. So normally you should pre-
+ fix the command by "start ", which flags to latexmk that it
+ should do the detaching of the previewer itself (by whatever
+ method is appropriate to the operating system). But sometimes
letting latexmk do the detaching is not appropriate (for a vari-
- ety of non-trivial reasons), so you should put the "start " bit
+ ety of non-trivial reasons), so you should put the "start " bit
in yourself, whenever it is needed.
$pdf_update_command [""]
- When the pdf previewer is set to be updated by running a com-
- mand, this is the command that is run. See the information for
+ When the pdf previewer is set to be updated by running a com-
+ mand, this is the command that is run. See the information for
the variable $pdf_update_method.
$pdf_update_method [1 under UNIX, 3 under MS-Windows]
- How the pdf viewer updates its display when the pdf file has
- changed. See the information on the variable $dvi_update_method
- for the codes. (Note that information needs be changed slightly
- so that for the value 4, to run a command to do the update, the
- command is specified by the variable $pdf_update_command, and
- for the value 2, to specify update by signal, the signal is
- specified by $pdf_update_signal.)
+ How the pdf viewer updates its display when the pdf file has
+ changed. See the information on the variable $dvi_update_method
- Note that acroread under MS-Windows (but not UNIX) locks the pdf
- file, so the default value is then 3.
-
- 25 October 2018 47
+ 17 March 2019 50
@@ -3106,6 +3304,15 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
+ for the codes. (Note that information needs be changed slightly
+ so that for the value 4, to run a command to do the update, the
+ command is specified by the variable $pdf_update_command, and
+ for the value 2, to specify update by signal, the signal is
+ specified by $pdf_update_signal.)
+
+ Note that acroread under MS-Windows (but not UNIX) locks the pdf
+ file, so the default value is then 3.
+
Arranging to use a command to get a previewer explicitly updated
requires three variables to be set. For example:
@@ -3113,101 +3320,102 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$pdf_update_method = 4;
$pdf_update_command = "xpdf -remote %R -reload";
- The first setting arranges for the xpdf program to be used in
- its "remote server mode", with the server name specified as the
- rootname of the TeX file. The second setting arranges for
- updating to be done in response to a command, and the third set-
+ The first setting arranges for the xpdf program to be used in
+ its "remote server mode", with the server name specified as the
+ rootname of the TeX file. The second setting arranges for up-
+ dating to be done in response to a command, and the third set-
ting sets the update command.
- $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent
+ $pdf_update_signal [Under UNIX: SIGHUP, which is a system-dependent
value]
- The number of the signal that is sent to the pdf viewer when it
- is updated by sending a signal -- see the information on the
- variable $pdf_update_method. The default value is the one
- appropriate for gv on a UNIX system.
+ The number of the signal that is sent to the pdf viewer when it
+ is updated by sending a signal -- see the information on the
+ variable $pdf_update_method. The default value is the one ap-
+ propriate for gv on a UNIX system.
$pid_position[1 under UNIX, -1 under MS-Windows]
- 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
+ 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, Linux, and OS-X
with their default settings of $pscmd.
- Setting the variable to -1 is used to indicate that $pscmd is
+ Setting the variable to -1 is used to indicate that $pscmd is
not to be used.
$postscript_mode [0]
- If nonzero, generate a postscript version of the document.
+ If nonzero, generate a postscript version of the document.
Equivalent to the -ps option.
- If some other request is made for which a postscript file is
+ If some other request is made for which a postscript file is
needed, then $postscript_mode will be set to 1.
$pre_tex_code ['']
- Sets TeX code to be executed before inputting the source file.
- This works if the relevant one of $latex, etc contains a suit-
+ Sets TeX code to be executed before inputting the source file.
+ This works if the relevant one of $latex, etc contains a suit-
able command line with a %P or %U substitution. For example you
could do
$latex = 'latex %O %P';
- $pre_tex_code = '1{An initial messagear}';
- To set all of $latex, $pdflatex, $lualatex, and $xelatex you
- could use the subroutine alt_tex_cmds:
- &alt_tex_cmds;
- $pre_tex_code = '1{An initial messagear}';
+ 17 March 2019 51
- 25 October 2018 48
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ $pre_tex_code = '1{An initial messagear}';
+ To set all of $latex, $pdflatex, $lualatex, and $xelatex you
+ could use the subroutine alt_tex_cmds:
+
+ &alt_tex_cmds;
+ $pre_tex_code = '1{An initial messagear}';
-LATEXMK(1) General Commands Manual LATEXMK(1)
$preview_continuous_mode [0]
- If nonzero, run a previewer to view the document, and continue
+ If nonzero, run a previewer to view the document, and continue
running latexmk to keep .dvi up-to-date. Equivalent to the -pvc
- option. Which previewer is run depends on the other settings,
+ option. Which previewer is run depends on the other settings,
see the command line options -view=, and the variable $view.
$preview_mode [0]
If nonzero, run a previewer to preview the document. Equivalent
- to the -pv option. Which previewer is run depends on the other
- settings, see the command line options -view=, and the variable
+ to the -pv option. Which previewer is run depends on the other
+ settings, see the command line options -view=, and the variable
$view.
$printout_mode [0]
- If nonzero, print the document using the command specified in
+ If nonzero, print the document using the command specified in
the $lpr variable. Equivalent to the -p option. This is recom-
- mended not to be set from an RC file, otherwise you could waste
+ mended not to be set from an RC file, otherwise you could waste
lots of paper.
$print_type = ["auto"]
- Type of file to printout: possibilities are "auto", "dvi",
+ Type of file to printout: possibilities are "auto", "dvi",
"none", "pdf", or "ps". See the option -print= for the meaning
of the "auto" value.
$pscmd 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 latexmk needs to signal
+ 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 latexmk needs to signal
the previewer about file changes).
Each line of the output of this command is assumed to correspond
- to one process. See the $pid_position variable for how the
+ to one process. See the $pid_position variable for how the
process number is determined.
- The default for pscmd is "NONE" under MS-Windows and cygwin
- (i.e., the command is not used), "ps -ww -u $ENV{USER}" under
- OS-X, and "ps -f -u $ENV{USER}" under other operating systems
+ The default for pscmd is "NONE" under MS-Windows and cygwin
+ (i.e., the command is not used), "ps -ww -u $ENV{USER}" under
+ OS-X, and "ps -f -u $ENV{USER}" under other operating systems
(including Linux). In these specifications "$ENV{USER}" is sub-
stituted by the username.
@@ -3215,21 +3423,11 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
Command to convert .ps to .pdf file.
$ps_filter [empty]
- The postscript file filter to be run on the newly produced post-
- script file before other processing. Equivalent to specifying
- the -pF option.
-
- $ps_previewer ["start gv %O %S", but start %O %S under MS-Windows]
- The command to invoke a ps-previewer. (The default under MS-
- Windows will cause to be run whatever command the system has
- associated with .ps files.)
+ The postscript file filter to be run on the newly produced
- Note that gv could be used with the -watch option updates its
- display whenever the postscript file changes, whereas ghostview
-
- 25 October 2018 49
+ 17 March 2019 52
@@ -3238,64 +3436,64 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
- does not. However, different versions of gv have slightly dif-
- ferent ways of writing this option. You can configure this
+ postscript file before other processing. Equivalent to specify-
+ ing the -pF option.
+
+ $ps_previewer ["start gv %O %S", but start %O %S under MS-Windows]
+ The command to invoke a ps-previewer. (The default under MS-
+ Windows will cause to be run whatever command the system has as-
+ sociated with .ps files.)
+
+ Note that gv could be used with the -watch option updates its
+ display whenever the postscript file changes, whereas ghostview
+ does not. However, different versions of gv have slightly dif-
+ ferent ways of writing this option. You can configure this
variable appropriately.
WARNING: Linux systems may have installed one (or more) versions
- of gv under different names, e.g., ggv, kghostview, etc, but
+ of gv under different names, e.g., ggv, kghostview, etc, but
perhaps not one actually called gv.
- Important note: Normally you will want to have a previewer run
+ Important note: Normally you will want to have a previewer run
detached, so that latexmk doesn't wait for the previewer to ter-
- minate before continuing its work. So normally you should pre-
- fix the command by "start ", which flags to latexmk that it
- should do the detaching of the previewer itself (by whatever
- method is appropriate to the operating system). But sometimes
+ minate before continuing its work. So normally you should pre-
+ fix the command by "start ", which flags to latexmk that it
+ should do the detaching of the previewer itself (by whatever
+ method is appropriate to the operating system). But sometimes
letting latexmk do the detaching is not appropriate (for a vari-
- ety of non-trivial reasons), so you should put the "start " bit
+ ety of non-trivial reasons), so you should put the "start " bit
in yourself, whenever it is needed.
- $ps_previewer_landscape ["start gv -swap %O %S", but start %O %S under
+ $ps_previewer_landscape ["start gv -swap %O %S", but start %O %S under
MS-Windows]
The command to invoke a ps-previewer in landscape mode.
$ps_update_command [""]
- When the postscript previewer is set to be updated by running a
- command, this is the command that is run. See the information
+ When the postscript previewer is set to be updated by running a
+ command, this is the command that is run. See the information
for the variable $ps_update_method.
$ps_update_method [0 under UNIX, 1 under MS-Windows]
- How the postscript viewer updates its display when the .ps file
- has changed. See the information on the variable
- $dvi_update_method for the codes. (Note that information needs
- be changed slightly so that for the value 4, to run a command to
- do the update, the command is specified by the variable
- $ps_update_command, and for the value 2, to specify update by
- signal, the signal is specified by $ps_update_signal.)
-
- $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent
+ How the postscript viewer updates its display when the .ps file
+ has changed. See the information on the variable $dvi_up-
+ date_method for the codes. (Note that information needs be
+ changed slightly so that for the value 4, to run a command to do
+ the update, the command is specified by the variable $ps_up-
+ date_command, and for the value 2, to specify update by signal,
+ the signal is specified by $ps_update_signal.)
+
+ $ps_update_signal [Under UNIX: SIGHUP, which is a system-dependent
value]
- The number of the signal that is sent to the pdf viewer when it
- is updated by sending a signal -- see $ps_update_method. The
+ The number of the signal that is sent to the pdf viewer when it
+ is updated by sending a signal -- see $ps_update_method. The
default value is the one appropriate for gv on a UNIX system.
- $pvc_timeout [0]
- If this variable is nonzero, there will be a timeout in pvc
- mode after a period of inactivity. Inactivity means a period
- when latexmk has detected no file changes and hence has not
- taken any actions like compiling the document. The period of
- inactivity is in the variable $pvc_timeout_mins.
-
- $pvc_timeout_mins [30]
- The period of inactivity, in minutes, after which pvc mode times
- out. This is used if $pvc_timeout is nonzero.
- 25 October 2018 50
+ 17 March 2019 53
@@ -3304,6 +3502,18 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
+ $pvc_timeout [0]
+ If this variable is nonzero, there will be a timeout in pvc
+ mode after a period of inactivity. Inactivity means a period
+ when latexmk has detected no file changes and hence has not
+ taken any actions like compiling the document. The period of in-
+ activity is in the variable $pvc_timeout_mins.
+
+
+ $pvc_timeout_mins [30]
+ The period of inactivity, in minutes, after which pvc mode times
+ out. This is used if $pvc_timeout is nonzero.
+
$pvc_view_file_via_temporary [1]
The same as $always_view_file_via_temporary, except that it only
applies in preview-continuous mode (-pvc option).
@@ -3311,57 +3521,45 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
$quote_filenames [1]
This specifies whether substitutions for placeholders in command
specifications (as in $pdflatex) are surrounded by double
- quotes. If this variable is 1 (or any other value Perl regards
+ quotes. If this variable is 1 (or any other value Perl regards
as true), then quoting is done. Otherwise quoting is omitted.
- The quoting method used by latexmk is tested to work correctly
- under UNIX systems (including Linux and Mac OS-X) and under MS-
- Windows. It allows the use of filenames containing special
- characters, notably spaces. (But note that many versions of
- latex and pdflatex cannot correctly deal with TeX files whose
- names contain spaces. Latexmk's quoting only ensures that such
+ The quoting method used by latexmk is tested to work correctly
+ under UNIX systems (including Linux and Mac OS-X) and under MS-
+ Windows. It allows the use of filenames containing special
+ characters, notably spaces. (But note that many versions of la-
+ tex and pdflatex cannot correctly deal with TeX files whose
+ names contain spaces. Latexmk's quoting only ensures that such
filenames are correctly treated by the operating system in pass-
ing arguments to programs.)
$recorder [1]
- Whether to use the -recorder option to latex and pdflatex. Use
- of this option results in a file of extension .fls containing a
- list of the files that these programs have read and written.
- Latexmk will then use this file to improve its detection of
- source files and generated files after a run of latex or pdfla-
+ Whether to use the -recorder option to latex and pdflatex. Use
+ of this option results in a file of extension .fls containing a
+ list of the files that these programs have read and written.
+ Latexmk will then use this file to improve its detection of
+ source files and generated files after a run of latex or pdfla-
tex.
- It is generally recommended to use this option (or to configure
- the $recorder variable to be on.) But it only works if
- (pdf)latex supports the -recorder option, which is true for most
- current implementations
-
- Note about the name of the .fls file: Most implementations of
- (pdf)latex produce an .fls file with the same basename as the
- main document's LaTeX, e.g., for Document.tex, the .fls file is
- Document.fls. However, some implementations instead produce
- files named for the program, i.e., latex.fls or pdflatex.fls.
- In this second case, latexmk copies the latex.fls or pdfla-
- tex.fls to a file with the basename of the main LaTeX document,
+ It is generally recommended to use this option (or to configure
+ the $recorder variable to be on.) But it only works if (pdf)la-
+ tex supports the -recorder option, which is true for most cur-
+ rent implementations
+
+ Note about the name of the .fls file: Most implementations of
+ (pdf)latex produce an .fls file with the same basename as the
+ main document's LaTeX, e.g., for Document.tex, the .fls file is
+ Document.fls. However, some implementations instead produce
+ files named for the program, i.e., latex.fls or pdflatex.fls.
+ In this second case, latexmk copies the latex.fls or pdfla-
+ tex.fls to a file with the basename of the main LaTeX document,
e.g., Document.fls.
- $search_path_separator [See below for default]
- The character separating paths in the environment variables TEX-
- INPUTS, BIBINPUTS, and BSTINPUTS. This variable is mainly used
- by latexmk when the -outdir, -output-directory, -auxdir, and/or
- -aux-directory options are used. In that case latexmk needs to
- communicate appropriately modified search paths to bibtex,
- dvipdf, dvips, and (pdf)latex.
-
- [Comment to technically savvy readers: (pdf)latex doesn't actu-
- ally need the modified search path. But, surprisingly, dvipdf
- and dvips do, because sometimes graphics files get generated in
- the output or aux directories.]
- 25 October 2018 51
+ 17 March 2019 54
@@ -3370,130 +3568,130 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
- The default under MSWin and Cygwin is ';' and under UNIX-like
- operating systems (including Linux and OS-X) is ':'. Normally
- the defaults give correct behavior. But there can be difficul-
- ties if your operating system is of one kind, but some of your
- software is running under an emulator for the other kind of
- operating system; in that case you'll need to find out what is
- needed, and set $search_path_separator explicitly. (The same
- goes, of course, for unusual operating systems that are not in
+ $search_path_separator [See below for default]
+ The character separating paths in the environment variables TEX-
+ INPUTS, BIBINPUTS, and BSTINPUTS. This variable is mainly used
+ by latexmk when the -outdir, -output-directory, -auxdir, and/or
+ -aux-directory options are used. In that case latexmk needs to
+ communicate appropriately modified search paths to bibtex,
+ dvipdf, dvips, and (pdf)latex.
+
+ [Comment to technically savvy readers: (pdf)latex doesn't actu-
+ ally need the modified search path. But, surprisingly, dvipdf
+ and dvips do, because sometimes graphics files get generated in
+ the output or aux directories.]
+
+ The default under MSWin and Cygwin is ';' and under UNIX-like
+ operating systems (including Linux and OS-X) is ':'. Normally
+ the defaults give correct behavior. But there can be difficul-
+ ties if your operating system is of one kind, but some of your
+ software is running under an emulator for the other kind of op-
+ erating system; in that case you'll need to find out what is
+ needed, and set $search_path_separator explicitly. (The same
+ goes, of course, for unusual operating systems that are not in
the MSWin, Linux, OS-X, Unix collection.)
$show_time [0]
Whether to show CPU time used.
$silence_logfile_warnings [0]
- Whether after a run of (pdf)latex to summarize warnings in the
- log file about undefined citations and references. Setting
- $silence_logfile_warnings=0 gives the summary of warnings (pro-
- vided silent mode isn't also set), and this is useful to locate
- undefined citations and references without searching through the
- much more verbose log file or the screen output of (pdf)latex.
- But the summary can also be excessively annoying. The default
- is not to give these warnings. The command line options
- -silence_logfile_warning_list and -silence_logfile_warning_list-
+ Whether after a run of (pdf)latex to summarize warnings in the
+ log file about undefined citations and references. Setting $si-
+ lence_logfile_warnings=0 gives the summary of warnings (provided
+ silent mode isn't also set), and this is useful to locate unde-
+ fined citations and references without searching through the
+ much more verbose log file or the screen output of (pdf)latex.
+ But the summary can also be excessively annoying. The default
+ is not to give these warnings. The command line options -si-
+ lence_logfile_warning_list and -silence_logfile_warning_list-
also set this variable.
- Note that multiple occurrences for the same undefined object on
+ Note that multiple occurrences for the same undefined object on
the same page and same line will be compressed to a single warn-
ing.
$silent [0]
- Whether to run silently. Setting $silent to 1 has the same
- effect as the -quiet of -silent options on the command line.
+ Whether to run silently. Setting $silent to 1 has the same ef-
+ fect as the -quiet of -silent options on the command line.
$sleep_time [2]
- The time to sleep (in seconds) between checking for source file
+ The time to sleep (in seconds) between checking for source file
changes when running with the -pvc option. This is subject to a
- minimum of one second delay, except that zero delay is also
- allowed.
+ minimum of one second delay, except that zero delay is also al-
+ lowed.
- A value of exactly 0 gives no delay, and typically results in
+ A value of exactly 0 gives no delay, and typically results in
100% CPU usage, which may not be desirable.
- $texfile_search [""]
- This is an obsolete variable, replaced by the @default_files
- variable.
- For backward compatibility, if you choose to set $tex-
- file_search, it is a string of space-separated filenames, and
- then latexmk replaces @default_files with the filenames in $tex-
- file_search to which is added "*.tex".
- $success_cmd [undefined]
- See the documentation for $compiling_cmd.
+ 17 March 2019 55
- 25 October 2018 52
-
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ $texfile_search [""]
+ This is an obsolete variable, replaced by the @default_files
+ variable.
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ For backward compatibility, if you choose to set $tex-
+ file_search, it is a string of space-separated filenames, and
+ then latexmk replaces @default_files with the filenames in $tex-
+ file_search to which is added "*.tex".
+ $success_cmd [undefined]
+ See the documentation for $compiling_cmd.
$tmpdir [See below for default]
- Directory to store temporary files that latexmk may generate
+ Directory to store temporary files that latexmk may generate
while running.
- The default under MSWindows (including cygwin), is to set
- $tmpdir to the value of the first of whichever of the system
- environment variables TMPDIR or TEMP exists, otherwise to the
- current directory. Under other operating systems (expected to
- be UNIX/Linux, including OS-X), the default is the value of the
- system environment variable TMPDIR if it exists, otherwise
+ The default under MSWindows (including cygwin), is to set $tm-
+ pdir to the value of the first of whichever of the system envi-
+ ronment variables TMPDIR or TEMP exists, otherwise to the cur-
+ rent directory. Under other operating systems (expected to be
+ UNIX/Linux, including OS-X), the default is the value of the
+ system environment variable TMPDIR if it exists, otherwise
"/tmp".
$use_make_for_missing_files [0]
Whether to use make to try and make files that are missing after
- a run of latex or pdflatex, and for which a custom dependency
- has not been found. This is generally useful only when latexmk
- is used as part of a bigger project which is built by using the
+ a run of latex or pdflatex, and for which a custom dependency
+ has not been found. This is generally useful only when latexmk
+ is used as part of a bigger project which is built by using the
make program.
Note that once a missing file has been made, no further calls to
- make will be made on a subsequent run of latexmk to update the
- file. Handling this problem is the job of a suitably defined
- Makefile. See the section "USING latexmk WITH make" for how to
- do this. The intent of calling make from latexmk is merely to
+ make will be made on a subsequent run of latexmk to update the
+ file. Handling this problem is the job of a suitably defined
+ Makefile. See the section "USING latexmk WITH make" for how to
+ do this. The intent of calling make from latexmk is merely to
detect dependencies.
$view ["default"]
- Which kind of file is to be previewed if a previewer is used.
- The possible values are "default", "dvi", "ps", "pdf". The
+ Which kind of file is to be previewed if a previewer is used.
+ The possible values are "default", "dvi", "ps", "pdf". The
value of "default" means that the "highest" of the kinds of file
generated is to be used (among .dvi, .ps and .pdf).
$warnings_as_errors [0]
- Normally latexmk copies the behavior of latex in treating unde-
- fined references and citations and multiply defined references
- as conditions that give a warning but not an error. The vari-
+ Normally latexmk copies the behavior of latex in treating unde-
+ fined references and citations and multiply defined references
+ as conditions that give a warning but not an error. The vari-
able $warnings_as_errors controls whether this behavior is modi-
fied.
- When the variable is non-zero, latexmk at the end of its run
- will return a non-zero status code to the operating system if
- any of the files processed gives a warning about problems with
- citations or references (i.e., undefined citations or references
- or multiply defined references). This is after latexmk has com-
- pleted all the runs it needs to try and resolve references and
- citations. Thus $warnings_as_errors being nonzero causes
- latexmk to treat such warnings as errors, but only when they
- occur on the last run of (pdf)latex and only after processing is
- complete. A non-zero value $warnings_as_errors can be set by
- the command-line option -Werror.
-
- The default behavior is normally satisfactory in the usual edit-
- compile-edit cycle. But, for example, latexmk can also be used
+ When the variable is non-zero, latexmk at the end of its run
+ will return a non-zero status code to the operating system if
- 25 October 2018 53
+ 17 March 2019 56
@@ -3502,92 +3700,104 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
- as part of a build process for some bigger project, e.g., for
- creating documentation in the build of a software application.
- Then it is often sensible to treat citation and reference warn-
- ings as errors that require the overall build process to be
- aborted. Of course, since multiple runs of (pdf)latex are gen-
- erally needed to resolve references and citations, what matters
- is not the warnings on the first run, but the warnings on the
+ any of the files processed gives a warning about problems with
+ citations or references (i.e., undefined citations or references
+ or multiply defined references). This is after latexmk has com-
+ pleted all the runs it needs to try and resolve references and
+ citations. Thus $warnings_as_errors being nonzero causes la-
+ texmk to treat such warnings as errors, but only when they occur
+ on the last run of (pdf)latex and only after processing is com-
+ plete. A non-zero value $warnings_as_errors can be set by the
+ command-line option -Werror.
+
+ The default behavior is normally satisfactory in the usual edit-
+ compile-edit cycle. But, for example, latexmk can also be used
+ as part of a build process for some bigger project, e.g., for
+ creating documentation in the build of a software application.
+ Then it is often sensible to treat citation and reference warn-
+ ings as errors that require the overall build process to be
+ aborted. Of course, since multiple runs of (pdf)latex are gen-
+ erally needed to resolve references and citations, what matters
+ is not the warnings on the first run, but the warnings on the
last run; latexmk takes this into account appropriately.
- In addition, when preview-continuous mode is used, a non-zero
- value for $warnings_as_errors changes the use of the commands
- $failure_cmd, $warning_cmd, and $success_cmd after a complia-
+ In addition, when preview-continuous mode is used, a non-zero
+ value for $warnings_as_errors changes the use of the commands
+ $failure_cmd, $warning_cmd, and $success_cmd after a complia-
tion. If there are citation or reference warnings, but no other
- errors, the behavior is as follows. If $warning_cmd is set, it
- is used. If it is not set, then then if $warnings_as_errors is
- non-zero and $failure_cmd is set, then $failure_cmd. Otherwise
- $success_cmd is used, if it is set. (The foregoing explanation
+ errors, the behavior is as follows. If $warning_cmd is set, it
+ is used. If it is not set, then then if $warnings_as_errors is
+ non-zero and $failure_cmd is set, then $failure_cmd. Otherwise
+ $success_cmd is used, if it is set. (The foregoing explanation
is rather complicated, because latexmk has to deal with the case
that one or more of the commands isn't set.)
$xdvipdfmx ["xdvipdfmx -o %D %O %S"]
- The program to make a pdf file from an xdv file (used in con-
+ The program to make a pdf file from an xdv file (used in con-
junction with xelatex when $pdf_mode=5).
$xdvipdfmx_silent_switch ["-q"]
Switch(es) for the xdvipdfmx program when silent mode is on.
$xelatex ["xelatex %O %S"]
- Specifies the command line for the LaTeX processing program of
- when the xelatex program is called for. See the documentation
- of the -xelatex option for some special properties of latexmk's
+ Specifies the command line for the LaTeX processing program of
+ when the xelatex program is called for. See the documentation
+ of the -xelatex option for some special properties of latexmk's
use of xelatex.
- Note about xelatex: Now latexmk uses xelatex to make an .xdv
- rather than .pdf file, with the .pdf file being created in a
- separate step. This is enforced by the use of the -no-pdf
- option. If %O is part of the command for invoking xelatex, then
- latexmk will insert the -no-pdf option automatically, otherwise
+ Note about xelatex: Now latexmk uses xelatex to make an .xdv
+ rather than .pdf file, with the .pdf file being created in a
+ separate step. This is enforced by the use of the -no-pdf op-
+ tion. If %O is part of the command for invoking xelatex, then
+ latexmk will insert the -no-pdf option automatically, otherwise
you must provide the option yourself
- To do a coordinated setting of all of $latex, $pdflatex, $luala-
- tex, and $xelatex, see the section "Advanced Configuration".
- %xelatex_input_extensions
- This variable specifies the extensions tried by latexmk when it
- finds that an xelatex run resulted in an error that a file has
- not been found, and the file is given without an extension.
- This typically happens when LaTeX commands of the form
- \input{file} or \includegraphics{figure}, when the relevant
- source file does not exist.
+ 17 March 2019 57
- 25 October 2018 54
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ To do a coordinated setting of all of $latex, $pdflatex, $luala-
+ tex, and $xelatex, see the section "Advanced Configuration".
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ %xelatex_input_extensions
+ This variable specifies the extensions tried by latexmk when it
+ finds that an xelatex run resulted in an error that a file has
+ not been found, and the file is given without an extension.
+ This typically happens when LaTeX commands of the form \in-
+ put{file} or \includegraphics{figure}, when the relevant source
+ file does not exist.
- In this situation, latexmk searches for custom dependencies to
- make the missing file(s), but restricts it to the extensions
- specified by the variable %xelatex_input_extensions. The
- default extensions are 'tex', 'pdf', 'jpg, and 'png'.
+ In this situation, latexmk searches for custom dependencies to
+ make the missing file(s), but restricts it to the extensions
+ specified by the variable %xelatex_input_extensions. The de-
+ fault extensions are 'tex', 'pdf', 'jpg, and 'png'.
See details of the %latex_input_extensions for other information
that equally applies to %xelatex_input_extensions.
$xelatex_silent_switch ["-interaction=batchmode"]
- Switch(es) for the xelatex program (specified in the variable
+ Switch(es) for the xelatex program (specified in the variable
$xelatex) when silent mode is on.
- See details of the $latex_silent_switch for other information
+ See details of the $latex_silent_switch for other information
that equally applies to $xelatex_silent_switch.
CUSTOM DEPENDENCIES
- In any RC file a set of custom dependencies can be set up to convert a
+ 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 latexmk to convert a .fig file to .eps to be included
in the .tex file.
@@ -3595,9 +3805,9 @@ CUSTOM DEPENDENCIES
Defining a custom dependency:
The old method of configuring latexmk to use a custom dependency was to
- directly manipulate the @cus_dep_list array that contains information
- defining the custom dependencies. (See the section "Old Method of
- Defining Custom Dependencies" for details.) This method still works,
+ directly manipulate the @cus_dep_list array that contains information
+ defining the custom dependencies. (See the section "Old Method of
+ Defining Custom Dependencies" for details.) This method still works,
but is no longer preferred.
A better method is to use the subroutines that allow convenient manipu-
@@ -3609,23 +3819,11 @@ CUSTOM DEPENDENCIES
The arguments are as follows:
- from extension:
- The extension of the file we are converting from (e.g. "fig").
- It is specified without a period.
-
- to extension:
- The extension of the file we are converting to (e.g. "eps"). It
- is specified without a period.
- must: If non-zero, the file from which we are converting must exist,
- if it doesn't exist latexmk will give an error message and exit
- unless the -f option is specified. If must is zero and the file
- we are converting from doesn't exist, then no action is taken.
- Generally, the appropriate value of must is zero.
- 25 October 2018 55
+ 17 March 2019 58
@@ -3634,79 +3832,94 @@ CUSTOM DEPENDENCIES
LATEXMK(1) General Commands Manual LATEXMK(1)
+ from extension:
+ The extension of the file we are converting from (e.g. "fig").
+ It is specified without a period.
+
+ to extension:
+ The extension of the file we are converting to (e.g. "eps"). It
+ is specified without a period.
+
+ must: If non-zero, the file from which we are converting must exist,
+ if it doesn't exist latexmk will give an error message and exit
+ unless the -f option is specified. If must is zero and the file
+ we are converting from doesn't exist, then no action is taken.
+ Generally, the appropriate value of must is zero.
+
function:
- The name of the subroutine that latexmk should call to perform
- the file conversion. The first argument to the subroutine is
+ The name of the subroutine that latexmk 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 Perl. The func-
- tion should return 0 if it was successful and a nonzero number
+ The subroutines are declared in the syntax of Perl. The func-
+ tion should return 0 if it was successful and a nonzero number
if it failed.
- Naturally add_cus_dep adds a custom dependency with the specified from
- and to extensions. If a custom dependency has been previously defined
- (e.g., in an rcfile that was read earlier), then it is replaced by the
+ Naturally add_cus_dep adds a custom dependency with the specified from
+ and to extensions. If a custom dependency has been previously defined
+ (e.g., in an rcfile that was read earlier), then it is replaced by the
new one.
- The subroutine remove_cus_dep removes the specified custom dependency.
+ The subroutine remove_cus_dep removes the specified custom dependency.
The subroutine show_cus_dep causes a list of the currently defined cus-
tom dependencies to be sent to the screen output.
How custom dependencies are used:
- An instance of a custom dependency rule is created whenever latexmk
- detects that a run of latex/pdflatex needs to read a file, like a
- graphics file, whose extension is the to-extension of a custom depen-
- dency. Then latexmk examines whether a file exists with the same name,
- but with the corresponding from-extension, as specified in the custom-
- dependency. If it does, then a corresponding instance of the custom
- dependency is created, after which the rule is invoked whenever the
- destination file (the one with the to-extension) is out-of-date with
- respect to the corresponding source file.
-
- To make the new destination file, the Perl subroutine specified in the
+ An instance of a custom dependency rule is created whenever latexmk de-
+ tects that a run of latex/pdflatex needs to read a file, like a graph-
+ ics file, whose extension is the to-extension of a custom dependency.
+ Then latexmk examines whether a file exists with the same name, but
+ with the corresponding from-extension, as specified in the custom-de-
+ pendency. If it does, then a corresponding instance of the custom de-
+ pendency is created, after which the rule is invoked whenever the des-
+ tination file (the one with the to-extension) is out-of-date with re-
+ spect to the corresponding source file.
+
+ To make the new destination file, the Perl subroutine specified in the
rule is invoked, with an argument that is the base name of the files in
- question. Simple cases just involve a subroutine invoking an external
- program; this can be done by following the templates below, even by
- those without knowledge of the Perl programming language. Of course,
+ question. Simple cases just involve a subroutine invoking an external
+ program; this can be done by following the templates below, even by
+ those without knowledge of the Perl programming language. Of course,
experts could do something much more elaborate.
- One item in the specification of each custom-dependency rule, labeled
- "must" above, specifies how the rule should be applied when the source
+ One item in the specification of each custom-dependency rule, labeled
+ "must" above, specifies how the rule should be applied when the source
file fails to exist.
- When latex reports that an input file (e.g., a graphics file) does not
- exist, latexmk tries to find a source file and a custom dependency that
- can be used to make it. If it succeeds, then it creates an instance of
- the custom dependency and invokes it to make the missing file, after
- which the next pass of latex etc will be able to read the newly created
- file.
- Note for advanced usage: The operating system's environment variable
- TEXINPUTS can be used to specify a search path for finding files by
- latex etc. Correspondingly, when a missing file is reported, latexmk
- looks in the directories specified in TEXINPUTS as well as in the cur-
- rent directory, to find a source file from which an instance of a cus-
- tom dependency can be used to make the missing file.
+ 17 March 2019 59
- 25 October 2018 56
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ When latex reports that an input file (e.g., a graphics file) does not
+ exist, latexmk tries to find a source file and a custom dependency that
+ can be used to make it. If it succeeds, then it creates an instance of
+ the custom dependency and invokes it to make the missing file, after
+ which the next pass of latex etc will be able to read the newly created
+ file.
+
+ Note for advanced usage: The operating system's environment variable
+ TEXINPUTS can be used to specify a search path for finding files by la-
+ tex etc. Correspondingly, when a missing file is reported, latexmk
+ looks in the directories specified in TEXINPUTS as well as in the cur-
+ rent directory, to find a source file from which an instance of a cus-
+ tom dependency can be used to make the missing file.
Function to implement custom dependency, traditional method:
- The function that implements a custom dependency gets the information
+ The function that implements a custom dependency gets the information
on the files to be processed in two ways. The first is through its one
- argument; the argument contains the base name of the source and desti-
+ argument; the argument contains the base name of the source and desti-
nation files. The second way is described later.
- A simple and typical example of code in an initialization rcfile using
+ A simple and typical example of code in an initialization rcfile using
the first method is:
add_cus_dep( 'fig', 'eps', 0, 'fig2eps' );
@@ -3714,92 +3927,92 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
system( "fig2dev -Leps \"$_[0].fig\" \"$_[0].eps\"" );
}
- The first line adds a custom dependency that converts a file with
- extension "fig", as created by the xfig program, to an encapsulated
- postscript file, with extension "eps". The remaining lines define a
- subroutine that carries out the conversion. If a rule for converting
- "fig" to "eps" files already exists (e.g., from a previously read-in
- initialization file), the latexmk will delete this rule before making
+ The first line adds a custom dependency that converts a file with ex-
+ tension "fig", as created by the xfig program, to an encapsulated post-
+ script file, with extension "eps". The remaining lines define a sub-
+ routine that carries out the conversion. If a rule for converting
+ "fig" to "eps" files already exists (e.g., from a previously read-in
+ initialization file), the latexmk will delete this rule before making
the new one.
- Suppose latexmk is using this rule to convert a file "figure.fig" to
- "figure.eps". Then it will invoke the fig2eps subroutine defined in
- the above code with a single argument "figure", which is the basename
- of each of the files (possibly with a path component). This argument
- is referred to by Perl as $_[0]. In the example above, the subroutine
+ Suppose latexmk is using this rule to convert a file "figure.fig" to
+ "figure.eps". Then it will invoke the fig2eps subroutine defined in
+ the above code with a single argument "figure", which is the basename
+ of each of the files (possibly with a path component). This argument
+ is referred to by Perl as $_[0]. In the example above, the subroutine
uses the Perl command system to invoke the program fig2dev. The double
quotes around the string are a Perl idiom that signify that each string
- of the form of a variable name, $_[0] in this case, is to be substi-
+ of the form of a variable name, $_[0] in this case, is to be substi-
tuted by its value.
- If the return value of the subroutine is non-zero, then latexmk will
- assume an error occurred during the execution of the subroutine. In
- the above example, no explicit return value is given, and instead the
- return value is the value returned by the last (and only) statement,
+ If the return value of the subroutine is non-zero, then latexmk will
+ assume an error occurred during the execution of the subroutine. In
+ the above example, no explicit return value is given, and instead the
+ return value is the value returned by the last (and only) statement,
i.e., the invocation of system, which returns the value 0 on success.
- If you use pdflatex instead of latex, then you will probably prefer to
- convert your graphics files to pdf format, in which case you would
- replace the above code in an initialization file by
+ If you use pdflatex instead of latex, then you will probably prefer to
- add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
- sub fig2pdf {
- system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
- }
- Note 1: In the command lines given in the system commands in the above
- examples, double quotes have been inserted around the file names
- (implemented by '\"' in the Perl language). They immunize the running
- of the program against special characters in filenames. Very often
- these quotes are not necessary, i.e., they can be omitted. But it is
- normally safer to keep them in. Even though the rules for quoting vary
- between operating systems, command shells and individual pieces of
+ 17 March 2019 60
- 25 October 2018 57
+LATEXMK(1) General Commands Manual LATEXMK(1)
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ convert your graphics files to pdf format, in which case you would re-
+ place the above code in an initialization file by
+ add_cus_dep( 'fig', 'pdf, 0, 'fig2pdf' );
+ sub fig2pdf {
+ system( "fig2dev -Lpdf \"$_[0].fig\" \"$_[0].pdf\"" );
+ }
+ Note 1: In the command lines given in the system commands in the above
+ examples, double quotes have been inserted around the file names (im-
+ plemented by '\"' in the Perl language). They immunize the running of
+ the program against special characters in filenames. Very often these
+ quotes are not necessary, i.e., they can be omitted. But it is nor-
+ mally safer to keep them in. Even though the rules for quoting vary
+ between operating systems, command shells and individual pieces of
software, the quotes in the above examples do not cause problems in the
cases I have tested.
- Note 2: One case in which the quotes are important is when the files
- are in a subdirectory and your operating system is Microsoft Windows.
- Then the separator character for directory components can be either a
- forward slash '/' or Microsoft's more usual backward slash '\'. For-
- ward slashes are generated by latexmk, to maintain its sanity from
- software like MiKTeX that mixes both directory separators; but their
+ Note 2: One case in which the quotes are important is when the files
+ are in a subdirectory and your operating system is Microsoft Windows.
+ Then the separator character for directory components can be either a
+ forward slash '/' or Microsoft's more usual backward slash '\'. For-
+ ward slashes are generated by latexmk, to maintain its sanity from
+ software like MiKTeX that mixes both directory separators; but their
correct use normally requires quoted filenames. (See a log file from a
- run of MiKTeX (at least in v. 2.9) for an example of the use of both
+ run of MiKTeX (at least in v. 2.9) for an example of the use of both
directory separators.)
- Note 3: The subroutines implementing custom dependencies in the exam-
- ples given just have a single line invoking an external program.
- That's the usual situation. But since the subroutines are in the Perl
- language, you can implement much more complicated processing if you
+ Note 3: The subroutines implementing custom dependencies in the exam-
+ ples given just have a single line invoking an external program.
+ That's the usual situation. But since the subroutines are in the Perl
+ language, you can implement much more complicated processing if you
need it.
Removing custom dependencies, and when you might need to do this:
- If you have some general custom dependencies defined in the system or
- user initialization file, you may find that for a particular project
- they are undesirable. So you might want to delete the unneeded ones.
- A situation where this would be desirable is where there are multiple
- custom dependencies with the same from-extension or the same to-exten-
- sion. In that case, latexmk might choose a different one from the one
+ If you have some general custom dependencies defined in the system or
+ user initialization file, you may find that for a particular project
+ they are undesirable. So you might want to delete the unneeded ones.
+ A situation where this would be desirable is where there are multiple
+ custom dependencies with the same from-extension or the same to-exten-
+ sion. In that case, latexmk might choose a different one from the one
you want for a specific project. As an example, to remove any "fig" to
"eps" rule you would use:
remove_cus_dep( 'fig', 'eps' );
- If you have complicated sets of custom dependencies, you may want to
- get a listing of the custom dependencies. This is done by using the
+ If you have complicated sets of custom dependencies, you may want to
+ get a listing of the custom dependencies. This is done by using the
line
show_cus_dep();
@@ -3807,23 +4020,8 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
in an initialization file.
- Function implementing custom dependency, alternative methods:
- So far the examples for functions to implement custom dependencies have
- used the argument of the function to specify the base name of converted
- file. This method has been available since very old versions of
- latexmk, and many examples can be found, e.g., on the web.
-
- However in later versions of latexmk the internal structure of the
- implementation of its "rules" for the steps of processing, including
- custom dependencies, became much more powerful. The function imple-
- menting a custom dependency is executed within a special context where
- a number of extra variables and subroutines are defined. Publicly doc-
- umented ones, intended to be long-term stable, are listed below, under
- the heading "Variables and subroutines for processing a rule".
-
-
- 25 October 2018 58
+ 17 March 2019 61
@@ -3832,18 +4030,32 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
LATEXMK(1) General Commands Manual LATEXMK(1)
- Examples of their use is given in the following examples, concerning
+ Function implementing custom dependency, alternative methods:
+ So far the examples for functions to implement custom dependencies have
+ used the argument of the function to specify the base name of converted
+ file. This method has been available since very old versions of la-
+ texmk, and many examples can be found, e.g., on the web.
+
+ However in later versions of latexmk the internal structure of the im-
+ plementation of its "rules" for the steps of processing, including cus-
+ tom dependencies, became much more powerful. The function implementing
+ a custom dependency is executed within a special context where a number
+ of extra variables and subroutines are defined. Publicly documented
+ ones, intended to be long-term stable, are listed below, under the
+ heading "Variables and subroutines for processing a rule".
+
+ Examples of their use is given in the following examples, concerning
multiple index files and glossaries.
- The only index-file conversion built-in to latexmk is from an ".idx"
- file written on one run of latex/pdflatex to an ".ind" file to be read
- in on a subsequent run. But with the index.sty package, for example,
- you can create extra indexes with extensions that you configure.
- Latexmk does not know how to deduce the extensions from the information
- it has. But you can easily write a custom dependency. For example if
- your latex file uses the command "\newindex{special}{ndx}{nnd}{Special
- index}" you will need to get latexmk to convert files with the exten-
- sion .ndx to .nnd. The most elementary method is to define a custom
+ The only index-file conversion built-in to latexmk is from an ".idx"
+ file written on one run of latex/pdflatex to an ".ind" file to be read
+ in on a subsequent run. But with the index.sty package, for example,
+ you can create extra indexes with extensions that you configure. La-
+ texmk does not know how to deduce the extensions from the information
+ it has. But you can easily write a custom dependency. For example if
+ your latex file uses the command "\newindex{special}{ndx}{nnd}{Special
+ index}" you will need to get latexmk to convert files with the exten-
+ sion .ndx to .nnd. The most elementary method is to define a custom
dependency as follows:
add_cus_dep( 'ndx', 'nnd', 0, 'ndx2nnd' );
@@ -3852,14 +4064,14 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
}
push @generated_exts, 'ndx', 'nnd';
- Notice the added line compared with earlier examples. The extra line
+ Notice the added line compared with earlier examples. The extra line
gets the extensions "ndx" and "nnd" added to the list of extensions for
generated files; then the extra index files will be deleted by clean-up
operations
- But if you have yet more indexes with yet different extensions, e.g.,
- "adx" and "and", then you will need a separate function for each pair
- of extensions. This is quite annoying. You can use the Run_subst
+ But if you have yet more indexes with yet different extensions, e.g.,
+ "adx" and "and", then you will need a separate function for each pair
+ of extensions. This is quite annoying. You can use the Run_subst
function to simplify the definitions to use a single function:
add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
@@ -3872,55 +4084,55 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
You could also instead use
add_cus_dep( 'ndx', 'nnd', 0, 'dx2nd' );
- add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
- sub dx2nd {
- return Run_subst( $makeindex );
- }
- push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
- This last example uses the command specification in $makeindex, and so
- any customization you have made for the standard index also applies to
- your extra indexes.
- Similar techniques can be applied for glossaries.
- Those of you with experience with Makefiles, may get concerned that the
- .ndx file is written during a run of latex/pdflatex and is always later
+ 17 March 2019 62
- 25 October 2018 59
+LATEXMK(1) General Commands Manual LATEXMK(1)
+ add_cus_dep( 'adx', 'and', 0, 'dx2nd' );
+ sub dx2nd {
+ return Run_subst( $makeindex );
+ }
+ push @generated_exts, 'ndx', 'nnd', 'adx', 'and';
-LATEXMK(1) General Commands Manual LATEXMK(1)
+ This last example uses the command specification in $makeindex, and so
+ any customization you have made for the standard index also applies to
+ your extra indexes.
+ Similar techniques can be applied for glossaries.
- than the .nnd last read in. Thus the .nnd appears to be perpetually
- out-of-date. This situation, of circular dependencies, is endemic to
+ Those of you with experience with Makefiles, may get concerned that the
+ .ndx file is written during a run of latex/pdflatex and is always later
+ than the .nnd last read in. Thus the .nnd appears to be perpetually
+ out-of-date. This situation, of circular dependencies, is endemic to
latex, and is one of the issues that latexmk is programmed to overcome.
- It examines the contents of the files (by use of a checksum), and only
+ It examines the contents of the files (by use of a checksum), and only
does a remake when the file contents have actually changed.
- Of course if you choose to write random data to the .nnd (or the .aux
- file, etc) that changes on each new run, then you will have a problem.
- For real experts: See the %hash_cal_ignore_pattern if you have to deal
+ Of course if you choose to write random data to the .nnd (or the .aux
+ file, etc) that changes on each new run, then you will have a problem.
+ For real experts: See the %hash_cal_ignore_pattern if you have to deal
with such problems.
Old Method of Defining Custom Dependencies:
- In much older versions of latexmk, the only method of defining custom
- dependencies was to directly manipulate the table of custom dependen-
+ In much older versions of latexmk, the only method of defining custom
+ dependencies was to directly manipulate the table of custom dependen-
cies. This is contained in the @cus_dep_list array. It is an array of
- strings, and each string in the array has four items in it, each sepa-
- rated by a space, the from-extension, the to-extension, the "must"
- item, and the name of the subroutine for the custom dependency. These
+ strings, and each string in the array has four items in it, each sepa-
+ rated by a space, the from-extension, the to-extension, the "must"
+ item, and the name of the subroutine for the custom dependency. These
were all defined above.
An example of the old method of defining custom dependencies is as fol-
- lows. It is the code in an RC file to ensure automatic conversion of
+ lows. It is the code in an RC file to ensure automatic conversion of
.fig files to .eps files:
push @cus_dep_list, "fig eps 0 fig2eps";
@@ -3928,56 +4140,94 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
return system( "fig2dev -Lps \"$_[0].fig\" \"$_[0].eps\"" );
}
- This method still works, and is almost equivalent to the code given
- earlier that used the add_cus_dep subroutine. However, the old method
- doesn't delete any previous custom-dependency for the same conversion.
+ This method still works, and is almost equivalent to the code given
+ earlier that used the add_cus_dep subroutine. However, the old method
+ doesn't delete any previous custom-dependency for the same conversion.
So the new method is preferable.
ADVANCED CONFIGURATION: Some extra resources and advanced tricks
- For most purposes, simple configuration for latexmk along the lines of
- the examples given is sufficient. But sometimes you need something
- harder. In this section, I indicate some extra possibilities. Gener-
- ally to use these, you need to be fluent in the Perl language, since
+ For most purposes, simple configuration for latexmk along the lines of
+ the examples given is sufficient. But sometimes you need something
+
+
+
+ 17 March 2019 63
+
+
+
+
+
+LATEXMK(1) General Commands Manual LATEXMK(1)
+
+
+ harder. In this section, I indicate some extra possibilities. Gener-
+ ally to use these, you need to be fluent in the Perl language, since
this is what is used in the rc files.
- See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See also the
+ See also the section DEALING WITH ERRORS, PROBLEMS, ETC. See also the
examples in the directory example_rcfiles in the latexmk distributions.
Even if none of the examples apply to your case, they may give you use-
ful ideas
+ Utility subroutines
+ ensure_path( var, values ...)
+
+ The first parameter is the name of one of the system's environ-
+ ment variables for search paths. The remaining parameters are
+ values that should be in the variable. For each of the value
+ parameters, if it isn't already in the variable, then it is
+ prepended to the variable; in that case the environment variable
+ is created if it doesn't already exist. For separating values,
+ the character appropriate the the operating system is used --
+ see the configuration variable $search_path_separator.
+
+ Example:
+
+ ensure_path( 'TEXINPUTS', './custom_cls_sty_files//' );
+
+ (In this example, the trailing '//' is documented by TeX systems
+ to mean that latex, pdflatex, etc search for files in the speci-
+ fied directory and in all subdirectories.)
+
+ Technically ensure_path works by setting Perl's variable
+ $ENV{var}, where var is the name of the target variable. The
+ changed value is then passed as an environment variable to any
+ invoked programs.
+
+
Variables and subroutines for processing a rule
A step in the processing is called a rule. One possibility to implement
- the processing of a rule is by a Perl subroutine. This is always the
- case for custom dependencies. Also, for any other rule, you can use a
+ the processing of a rule is by a Perl subroutine. This is always the
+ case for custom dependencies. Also, for any other rule, you can use a
+ subroutine by prefixing the command specification by the word "inter-
+ nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
+ When you use a subroutine for processing a rule, all the possibilities
+ of Perl programming are available, of course. In addition, some of la-
+ texmk's internal variables and subroutines are available. The ones
+ listed below are intended to be available to (advanced) users, and
+ their specifications will generally have stability under upgrades. Gen-
+ erally, the variables should be treated as read-only: Changing their
+ values can have bad consequences, since it is liable to mess up the
+ consistency of what latexmk is doing.
+ $rule This variable has the name of the rule, as known to latexmk.
+ Note that the exact contents of this variable for a given rule
- 25 October 2018 60
+ 17 March 2019 64
-LATEXMK(1) General Commands Manual LATEXMK(1)
- subroutine by prefixing the command specification by the word "inter-
- nal" -- see the section FORMAT OF COMMAND SPECIFICATIONS.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- When you use a subroutine for processing a rule, all the possibilities
- of Perl programming are available, of course. In addition, some of
- latexmk's internal variables and subroutines are available. The ones
- listed below are intended to be available to (advanced) users, and
- their specifications will generally have stability under upgrades. Gen-
- erally, the variables should be treated as read-only: Changing their
- values can have bad consequences, since it is liable to mess up the
- consistency of what latexmk is doing.
- $rule This variable has the name of the rule, as known to latexmk.
- Note that the exact contents of this variable for a given rule
may be dependent on the version of latexmk
$$Psource
@@ -3985,198 +4235,197 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
dollar signs.
$$Pdest
- This gives the name of the main output file if any. Note the
+ This gives the name of the main output file if any. Note the
double dollar signs.
rdb_ensure_file( $rule, file )
- This a subroutine that ensures that the given file is among the
+ This a subroutine that ensures that the given file is among the
source files for the specified rule. It is typically used when,
- during the processing of a rule, it is known that a particular
- extra file is among the dependencies that latexmk should know,
+ during the processing of a rule, it is known that a particular
+ extra file is among the dependencies that latexmk should know,
but its default methods don't find the dependency. Almost always
- the first argument is the name of the rule currently being pro-
+ the first argument is the name of the rule currently being pro-
cessed, so it is then appropriate to specify it by $rule.
- For examples of its use, see some of the files in the directory
- example_rcfiles of latexmk's distribution. Currently the cases
- that use this subroutine are bib2gls-latexmkrc, excel-
- tex_latexmkrc and texinfo-latexmkrc. These illustrate typical
- cases where latexmk's normal processing fails to detect certain
- extra source files.
+ For examples of its use, see some of the files in the directory
+ example_rcfiles of latexmk's distribution. Currently the cases
+ that use this subroutine are bib2gls-latexmkrc, exceltex_la-
+ texmkrc and texinfo-latexmkrc. These illustrate typical cases
+ where latexmk's normal processing fails to detect certain extra
+ source files.
rdb_remove_files( $rule, file, ... )
- This subroutine removes one or more files from the dependency
+ This subroutine removes one or more files from the dependency
list for the given rule.
rdb_list_source( $rule )
- This subroutine returns the list of source files (i.e., the
- dependency list) for the given rule.
+ This subroutine returns the list of source files (i.e., the de-
+ pendency list) for the given rule.
rdb_set_source( $rule, file, ... )
rdb_set_source( $rule, @files )
- This subroutine sets the dependency list for the given rule to
+ This subroutine sets the dependency list for the given rule to
be the specified files. Files that are already in the list have
- unchanged information. Files that were not in the list are
-
+ unchanged information. Files that were not in the list are
+ added to it. Files in the previous dependency list that are not
+ in the newly specified list of files are removed from the depen-
+ dency list.
+ Run_subst( command_spec )
+ This subroutine runs the command specified by command_spec. The
+ specification is a string in the format listed in the section
+ "Format of Command Specifications". An important action of the
+ Run_subst is to make substitutions of placeholders, e.g., %S and
+ %D for source and destination files; these get substituted be-
+ fore the command is run. In addition, the command after substi-
+ tution is printed to the screen unless latexmk is running in
+ silent mode.
- 25 October 2018 61
+ 17 March 2019 65
-LATEXMK(1) General Commands Manual LATEXMK(1)
- added to it. Files in the previous dependency list that are not
- in the newly specified list of files are removed from the depen-
- dency list.
- Run_subst( command_spec )
- This subroutine runs the command specified by command_spec. The
- specification is a string in the format listed in the section
- "Format of Command Specifications". An important action of the
- Run_subst is to make substitutions of placeholders, e.g., %S and
- %D for source and destination files; these get substituted
- before the command is run. In addition, the command after sub-
- stitution is printed to the screen unless latexmk is running in
- silent mode.
+LATEXMK(1) General Commands Manual LATEXMK(1)
Coordinated Setting of Commands for *latex
- To set all of $latex, $pdflatex, $lualatex, and $xelatex to a common
- pattern, you can use one of the following subroutines, std_tex_cmds,
+ To set all of $latex, $pdflatex, $lualatex, and $xelatex to a common
+ pattern, you can use one of the following subroutines, std_tex_cmds,
alt_tex_cmds, and set_tex_cmds.
They work as follows
&std_tex_cmds;
- This results in $latex = 'latex %O %S', and similarly for $pdflatex,
- $lualatex, and $xelatex. Note the ampersand in the invocation; this
+ This results in $latex = 'latex %O %S', and similarly for $pdflatex,
+ $lualatex, and $xelatex. Note the ampersand in the invocation; this
indicates to Perl that a subroutine is being called.
&alt_tex_cmds;
- This results in $latex = 'latex %O %P', and similarly for $pdflatex,
- $lualatex, and $xelatex. Note the ampersand in the invocation; this
+ This results in $latex = 'latex %O %P', and similarly for $pdflatex,
+ $lualatex, and $xelatex. Note the ampersand in the invocation; this
indicates to Perl that a subroutine is being called.
set_tex_cmds( CMD_SPEC );
- Here CMD_SPEC is the command line without the program name. This
- results in $latex = 'CMD_SPEC', and similarly for $pdflatex, $lualatex,
+ Here CMD_SPEC is the command line without the program name. This re-
+ sults in $latex = 'CMD_SPEC', and similarly for $pdflatex, $lualatex,
and $xelatex. An example would be
set_tex_cmds( '--interaction=batchmode %O %S' );
Advanced configuration: Using latexmk with make
- This section is targeted only at advanced users who use the make pro-
+ This section is targeted only at advanced users who use the make pro-
gram for complex projects, as for software development, with the depen-
dencies specified by a Makefile.
- Now the basic task of latexmk is to run the appropriate programs to
- make a viewable version of a LaTeX document. However, the usual make
- program is not suited to this purpose for at least two reasons. First
+ Now the basic task of latexmk is to run the appropriate programs to
+ make a viewable version of a LaTeX document. However, the usual make
+ program is not suited to this purpose for at least two reasons. First
is that the use of LaTeX involves circular dependencies (e.g., via .aux
files), and these cannot be handled by the standard make program. Sec-
- ond is that in a large document the set of source files can change
+ ond is that in a large document the set of source files can change
+ quite frequently, particularly with included graphics files; in this
+ situation keeping a Makefile manually updated is inappropriate and er-
+ ror-prone, especially when the dependencies can be determined automati-
+ cally. Latexmk solves both of these problems robustly.
+
+ Thus for many standard LaTeX documents latexmk can be used by itself
+ without the make program. In a complex project it simply needs to be
+ suitably configured. A standard configuration would be to define cus-
+ tom dependencies to make graphics files from their source files (e.g.,
+ as created by the xfig program). Custom dependencies are latexmk's
+ equivalent of pattern rules in Makefiles.
+ Nevertheless there are projects for which a Makefile is appropriate,
+ and it is useful to know how to use latexmk from a Makefile. A typical
+ example would be to generate documentation for a software project.
- 25 October 2018 62
+ 17 March 2019 66
-LATEXMK(1) General Commands Manual LATEXMK(1)
+LATEXMK(1) General Commands Manual LATEXMK(1)
- quite frequently, particularly with included graphics files; in this
- situation keeping a Makefile manually updated is inappropriate and
- error-prone, especially when the dependencies can be determined auto-
- matically. Latexmk solves both of these problems robustly.
-
- Thus for many standard LaTeX documents latexmk can be used by itself
- without the make program. In a complex project it simply needs to be
- suitably configured. A standard configuration would be to define cus-
- tom dependencies to make graphics files from their source files (e.g.,
- as created by the xfig program). Custom dependencies are latexmk's
- equivalent of pattern rules in Makefiles.
- Nevertheless there are projects for which a Makefile is appropriate,
- and it is useful to know how to use latexmk from a Makefile. A typical
- example would be to generate documentation for a software project.
- Potentially the interaction with the rest of the rules in the Makefile
+ Potentially the interaction with the rest of the rules in the Makefile
could be quite complicated, for example if some of the source files for
a LaTeX document are generated by the project's software.
In this section, I give a couple of examples of how latexmk can be use-
- fully invoked from a Makefile. The examples use specific features of
- current versions of GNU make, which is the default on both linux and
+ fully invoked from a Makefile. The examples use specific features of
+ current versions of GNU make, which is the default on both linux and
OS-X systems. They may need modifications for other versions of make.
- The simplest method is simply to delegate all the relevant tasks to
- latexmk, as is suitable for a straightforward LaTeX document. For this
- a suitable Makefile is like
+ The simplest method is simply to delegate all the relevant tasks to la-
+ texmk, as is suitable for a straightforward LaTeX document. For this a
+ suitable Makefile is like
.PHONY : FORCE_MAKE
all : try.pdf
%.pdf : %.tex FORCE_MAKE
latexmk -pdf -dvi- -ps- $<
- (Note: the last line must be introduced by a tab for the Makefile to
- function correctly!) Naturally, if making try.pdf from its associated
- LaTeX file try.tex were the only task to be performed, a direct use of
- latexmk without a Makefile would normally be better. The benefit of
- using a Makefile for a LaTeX document would be in a larger project,
+ (Note: the last line must be introduced by a tab for the Makefile to
+ function correctly!) Naturally, if making try.pdf from its associated
+ LaTeX file try.tex were the only task to be performed, a direct use of
+ latexmk without a Makefile would normally be better. The benefit of
+ using a Makefile for a LaTeX document would be in a larger project,
where lines such as the above would be only be a small part of a larger
Makefile.
The above example has a pattern rule for making a .pdf file from a .tex
- file, and it is defined to use latexmk in the obvious way. There is a
+ file, and it is defined to use latexmk in the obvious way. There is a
conventional default target named "all", with a prerequisite of
- try.pdf. So when make is invoked, by default it makes try.pdf. The
- only complication is that there may be many source files beyond
+ try.pdf. So when make is invoked, by default it makes try.pdf. The
+ only complication is that there may be many source files beyond
try.tex, but these aren't specified in the Makefile, so changes in them
- will not by themselves cause latexmk to be invoked. Instead, the pat-
- tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
- the effect of causing the rule to be always out-of-date, so that
- latexmk is always run. It is latexmk that decides whether any action
- is needed, e.g., a rerun of pdflatex. Effectively the Makefile dele-
- gates all decisions to latexmk, while make has no knowledge of the list
- of source files except for primary LaTeX file for the document. If
-
+ will not by themselves cause latexmk to be invoked. Instead, the pat-
+ tern rule is equipped with a "phony" prerequisite FORCE_MAKE; this has
+ the effect of causing the rule to be always out-of-date, so that la-
+ texmk is always run. It is latexmk that decides whether any action is
+ needed, e.g., a rerun of pdflatex. Effectively the Makefile delegates
+ all decisions to latexmk, while make has no knowledge of the list of
+ source files except for primary LaTeX file for the document. If there
+ are, for example, graphics files to be made, these must be made by cus-
+ tom dependencies configured in latexmk.
+
+ But something better is needed in more complicated situations, for ex-
+ ample, when the making of graphics files needs to be specified by rules
+ in the Makefile. To do this, one can use a Makefile like the follow-
+ ing:
+ TARGETS = document1.pdf document2.pdf
+ DEPS_DIR = .deps
+ LATEXMK = latexmk -recorder -use-make -deps \
+ -e 'warn qq(In Makefile, turn off custom dependencies\n);' \
+ -e '@cus_dep_list = ();' \
+ -e 'show_cus_dep();'
+ all : $(TARGETS)
- 25 October 2018 63
+ 17 March 2019 67
-LATEXMK(1) General Commands Manual LATEXMK(1)
- there are, for example, graphics files to be made, these must be made
- by custom dependencies configured in latexmk.
+LATEXMK(1) General Commands Manual LATEXMK(1)
- But something better is needed in more complicated situations, for
- example, when the making of graphics files needs to be specified by
- rules in the Makefile. To do this, one can use a Makefile like the
- following:
- TARGETS = document1.pdf document2.pdf
- DEPS_DIR = .deps
- LATEXMK = latexmk -recorder -use-make -deps \
- -e 'warn qq(In Makefile, turn off custom dependencies\n);' \
- -e '@cus_dep_list = ();' \
- -e 'show_cus_dep();'
- all : $(TARGETS)
$(foreach file,$(TARGETS),$(eval -include $(DEPS_DIR)/$(file)P))
$(DEPS_DIR) :
mkdir $@
@@ -4186,86 +4435,86 @@ LATEXMK(1) General Commands Manual LATEXMK(1)
%.pdf : %.fig
fig2dev -Lpdf $< $@
- (Again, the lines containing the commands for the rules should be
+ (Again, the lines containing the commands for the rules should be
started with tabs.) This example was inspired by how GNU automake han-
dles automatic dependency tracking of C source files.
- After each run of latexmk, dependency information is put in a file in
- the .deps subdirectory. The Makefile causes these dependency files to
+ After each run of latexmk, dependency information is put in a file in
+ the .deps subdirectory. The Makefile causes these dependency files to
be read by make, which now has the full dependency information for each
- target .pdf file. To make things less trivial it is specificed that
- two files document1.pdf and document2.pdf are the targets. The depen-
+ target .pdf file. To make things less trivial it is specificed that
+ two files document1.pdf and document2.pdf are the targets. The depen-
dency files are .deps/document1.pdfP and .deps/document2.pdfP.
- There is now no need for the phony prerequisite for the rule to make
+ There is now no need for the phony prerequisite for the rule to make
.pdf files from .tex files. But I have added a rule to make .pdf files
- from .fig files produced by the xfig program; these are commonly used
- for graphics insertions in LaTeX documents. Latexmk is arranged to
- output a dependency file after each run. It is given the -recorder
- option, which improves its detection of files generated during a run of
- pdflatex; such files should not be in the dependency list. The -e
- options are used to turn off all custom dependencies, and to document
- this. Instead the -use-make is used to delegate the making of missing
+ from .fig files produced by the xfig program; these are commonly used
+ for graphics insertions in LaTeX documents. Latexmk is arranged to
+ output a dependency file after each run. It is given the -recorder op-
+ tion, which improves its detection of files generated during a run of
+ pdflatex; such files should not be in the dependency list. The -e op-
+ tions are used to turn off all custom dependencies, and to document
+ this. Instead the -use-make is used to delegate the making of missing
files to make itself.
- Suppose in the LaTeX file there is a command \includegraphics{graph},
- and an xfig file "graph.fig" exists. On a first run, pdflatex reports
- a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
+ Suppose in the LaTeX file there is a command \includegraphics{graph},
+ and an xfig file "graph.fig" exists. On a first run, pdflatex reports
+ a missing file, named "graph". Latexmk succeeds in making "graph.pdf"
by calling "make graph.pdf", and after completion of its work, it lists
"fig.pdf" among the dependents of the file latexmk is making. Then let
- "fig.fig" be updated, and then let make be run. Make first remakes
+ "fig.fig" be updated, and then let make be run. Make first remakes
"fig.pdf", and only then reruns latexmk.
+ Thus we now have a method by which all the subsidiary processing is
+ delegated to make.
+SEE ALSO
+ latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
- 25 October 2018 64
+BUGS
+ Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
+ its creation is started but before the file is complete. Work around:
+ manually refresh (or reopen) display. Or use one of the other preview-
+ ers and update methods.
+ (The following isn't really a bug, but concerns features of preview-
+ ers.) Preview continuous mode only works perfectly with certain
+ 17 March 2019 68
-LATEXMK(1) General Commands Manual LATEXMK(1)
- Thus we now have a method by which all the subsidiary processing is
- delegated to make.
-SEE ALSO
- latex(1), bibtex(1), lualatex(1), pdflatex(1), xelatex(1).
+LATEXMK(1) General Commands Manual LATEXMK(1)
-BUGS
- Sometimes a viewer (gv) tries to read an updated .ps or .pdf file after
- its creation is started but before the file is complete. Work around:
- manually refresh (or reopen) display. Or use one of the other preview-
- ers and update methods.
- (The following isn't really a bug, but concerns features of preview-
- ers.) Preview continuous mode only works perfectly with certain pre-
- viewers: 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 updated. (Remedy: configure latexmk to use suma-
+ 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 updated. (Remedy: configure latexmk to use suma-
trapdf instead.)
THANKS TO
- Authors of previous versions. Many users with their feedback, and
- especially David Coppit (username david at node coppit.org) who made
- many useful suggestions that contributed to version 3, and Herbert
- Schulz. (Please note that the e-mail addresses are not written in
- their standard form to avoid being harvested too easily.)
+ Authors of previous versions. Many users with their feedback, and es-
+ pecially David Coppit (username david at node coppit.org) who made many
+ useful suggestions that contributed to version 3, and Herbert Schulz.
+ (Please note that the e-mail addresses are not written in their stan-
+ dard form to avoid being harvested too easily.)
AUTHOR
- Current version, by John Collins (username jcc8 at node psu.edu).
- (Version 4.61).
+ Current version, by John Collins (username jcc8 at node psu.edu).
+ (Version 4.63b).
- Released version can be obtained from CTAN:
- <http://www.ctan.org/pkg/latexmk/>, and from the author's website
+ Released version can be obtained from CTAN:
+ <http://www.ctan.org/pkg/latexmk/>, and from the author's website
<http://www.personal.psu.edu/jcc8/latexmk/>.
Modifications and enhancements by Evan McLean (Version 2.0)
Original script called "go" by David J. Musliner (RCS Version 3.2)
@@ -4285,6 +4534,21 @@ AUTHOR
- 25 October 2018 65
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 17 March 2019 69
diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl
index 9a9588160c7..ed200a7c225 100755
--- a/Master/texmf-dist/scripts/latexmk/latexmk.pl
+++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl
@@ -1,5 +1,10 @@
#!/usr/bin/env perl
+#!!!!!!!!!!!!!!!!!!!????????? CLEAN UP INITIALIZATION
+#!!! See all FIX items.
+
+# Perhaps add subroutine rdb_change_active( (rules to deactivate), (rules to activate))
+
# ?? Still need to fix bcf error issue.
# Don't keep looping after error
# pvc: Only re-run on USER FILE CHANGE.
@@ -119,71 +124,6 @@ use warnings;
# Test for already running previewer gets wrong answer if another
# process has the viewed file in its command line
-$my_name = 'latexmk';
-$My_name = 'Latexmk';
-$version_num = '4.61';
-$version_details = "$My_name, John Collins, 25 October 2018";
-
-use Config;
-use File::Basename;
-use File::Copy;
-use File::Spec;
-
-# If possible, use better glob, which does not use space as item separator.
-# It's either File::Glob::bsd_glob or File::Glob::glob
-# The first does not exist in old versions of Perl, while the second
-# is deprecated in more recent versions and will be removed
-$have_bsd_glob = 0;
-sub my_glob {
- if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
- else { return glob( $_[0] ); }
-}
-use File::Glob;
-if ( eval{ File::Glob->import('bsd_glob'); 1; } ) {
- # Success in importing bsd_glob
- $have_bsd_glob = 1;
-}
-elsif ( eval{ File::Glob->import('glob'); 1; } ) {
- warn "$My_name: I could not import File::Glob:bsd_glob, probably because your\n",
- " Perl is too old. I have arranged to use the deprecated File::Glob:glob\n",
- " instead.\n",
- " WARNING: It may malfunction on clean up operation on filenames containing\n",
- " spaces.\n";
- $have_bsd_glob = 0;
-}
-else {
- die "Could not import 'File::Glob:bsd_glob' or 'File::Glob:glob'\n";
-}
-
-use File::Path 2.08 qw( make_path );
-use FileHandle;
-use File::Find;
-use List::Util qw( max );
-use Cwd; # To be able to change cwd
-use Cwd "chdir"; # Ensure $ENV{PWD} tracks cwd
-use Digest::MD5;
-
-#use strict;
-
-# The following variables are assigned once and then used in symbolic
-# references, so we need to avoid warnings 'name used only once':
-use vars qw( $dvi_update_command $ps_update_command $pdf_update_command );
-
-# Translation of signal names to numbers and vv:
-%signo = ();
-@signame = ();
-if ( defined $Config{sig_name} ) {
- $i = 0;
- foreach $name (split('\s+', $Config{sig_name})) {
- $signo{$name} = $i;
- $signame[$i] = $name;
- $i++;
- }
-}
-else {
- warn "Something wrong with the perl configuration: No signals?\n";
-}
-
## Copyright John Collins 1998-2018
## (username jcc8 at node psu.edu)
## (and thanks to David Coppit (username david at node coppit.org)
@@ -222,64 +162,44 @@ else {
##
## 12 Jan 2012 STILL NEED TO DOCUMENT some items below
##
+## 17 Mar 2019 John Collins Further test for problems when linking rules
+## 17 Mar 2019 John Collins V. 4.63b.
+## 17 Mar 2019 John Collins Fix problem revealed by bibtopic package
+## 15 Mar 2019 John Collins Corrections
+## 14 Mar 2019 John Collins Version to 4.63a
+## 12-14 Mar 2019 John Collins Jobname has placeholder
+## 8-11 Mar 2019 John Collins Correct aux-dir bugs
+## 8 Mar 2019 John Collins Version to 4.63
+## 1 Jan 2019 John Collins Correct bug in output switching code
+## 31 Dec 2018 John Collins Correct bug that with $cleanup_includes_generated
+## -c mode deletes final output files (e.g., .dvi, .pdf).
+## 13 Dec 2018 John Collins Fixes, cleanup
+## 12 Dec 2018 John Collins Fix rdb_read
+## 11 Dec 2018 John Collins For output-switch: Reorganize initialization
+## Remove possibility of more than one primary.
+## 1 Dec 2018 John Collins Clean up some code.
+## 30 Nov 2018 John Collins Allow any characters in directory part of tex
+## filename when cd mode on. (Still standard
+## set of disallowed characters applies basename.)
+## 21 Nov 2018 John Collins Infrastructure finished, I think, for active flag
+## Start on output switch
+## 16 Nov 2018 John Collins Remove in non-diagnostics mode a warning about
+## rule not in use in this session that is given
+## when reading an fdb_latexmk file.
+## 2 Nov 2018 John Collins Start implementing active flag for rules.
+## 1 Nov 2018 John Collins Fix finding of missing files that are relative to aux_dir
+## 29-31 Oct 2018 John Collins Some cleanup.
+## 27,28 Oct 2018 John Collins Fix bug that in -pvc mode, after an error in
+## certain rules, new rounds of compilation
+## are triggered because of changes in generated
+## files, instead of only by later user-generated
+## changes.
+## Improve linking of rules.
+## 25 Oct 2018 John Collins V. 4.62
+## Clean up can remove (empty) directories
## 25 Oct 2018 John Collins Fix definition of clean up substitution for %R
## so that something with intermediate %R works,
## as in 'pythontex-files-%R/*'.
-## 24 Oct 2018 John Collins V. 4.61
-## 16 Oct 2018 John Collins Routines for setting all of $latex, etc.
-## Variables, options, substitutable parameters
-## for executing code in *latex before inputting
-## source file.
-## 10 Oct 2018 John Collins Fix problem that if biber gets a remote file,
-## it would be deleted and latexmk would report
-## it as missing, incorrectly.
-## 8 Oct 2018 John Collins Report count of warnings about missing characters
-## (typically unavailable Unicode characters).
-## Messages about this may appear only in the .log
-## file and are therefore easily missed by the user.
-## V. 4.60a
-## 21 Sep 2018 John Collins Fix bug that --gg with --deps-file doesn't
-## create deps file.
-## 3 Sep 2018 John Collins -pdfxelatex and -pdflualatex options
-## 3 Sep 2018 John Collins V. 4.60
-## 7 Aug 2018 John Collins V. 4.59 Released on CTAN
-## 1 Aug 2018 John Collins Correct sub rdb_find_source_file.
-## 30 Jul 2018 John Collins Change handling of warnings for a difference
-## between actual and expected output filenames
-## for a run of a primary rule. Only give a
-## warning if the extensions differ.
-## In all other cases, there were significant
-## numbers of false positives and no true positives.
-## Improve providing of -no-pdf option to xelatex, to
-## ensure it's used even after a user redefinition
-## of $xelatex. Works if %O is in definition.
-## 25 Jul 2018 John Collins Clean up of code.
-## 24 Jul 2018 John Collins Fatal error when filename has initial '&'. This
-## is not allowed for TeX file, since TeX et al
-## treat the initial '&' as specifying the format.
-## 20,21,23 Jul 2018 John Collins Improve quoting in file-not-found messages
-## On MS-Win change \ to / on files on command line
-## 18,19 Jul 2018 John Collins Complete TEXINPUTS stuff
-## Fix reading of file database file when
-## custom dependency no longer exists.
-## 13,17 Jul 2018 John Collins Deal with double quotes in specified filename,
-## and filenames not allowed by TeX.
-## Illegal characters and unbalanced quotes give fatal error.
-## 10 Jul 2018 John Collins Use TEXINPUTS for finding source file for cus dep.
-## Version 4.58.
-## 21 Jun 2018 John Collins Version 4.57.
-## In get_checksum_md5, open file with mode :bytes,
-## to avoid error about malformed utf8 characters
-## that can happen if PERL_UNICODE is set.
-## 15 Jun 2018 John Collins Configuration to be able to turn off bibtex fudge.
-## 24,25 May 2018 John Collins Fix problem of .bib files not found with msys.
-## Add use of environment variable LATEXMKRCSYS
-## 12 May 2018 John Collins Simplify code in run_bibtex.
-## 3,9 May 2018 John Collins Improved diagnostics on mismatch of output filenames
-## 28,30 Apr 2018 John Collins Improve error messages for bib files not found
-## 26 Apr 2018 John Collins In testing for different expected and actual
-## output of primary run, normalize $$Pdest, to
-## avoid spurious warnings.
##
## 1998-2018, John Collins. Many improvements and fixes.
## See CHANGE-log.txt for full list, and CHANGES for summary
@@ -299,6 +219,71 @@ else {
## 20 = probable bug
## or retcode from called program.
+$my_name = 'latexmk';
+$My_name = 'Latexmk';
+$version_num = '4.63b';
+$version_details = "$My_name, John Collins, 17 March 2019";
+
+use Config;
+use File::Basename;
+use File::Copy;
+use File::Spec;
+
+# If possible, use better glob, which does not use space as item separator.
+# It's either File::Glob::bsd_glob or File::Glob::glob
+# The first does not exist in old versions of Perl, while the second
+# is deprecated in more recent versions and will be removed
+$have_bsd_glob = 0;
+sub my_glob {
+ if ($have_bsd_glob) { return bsd_glob( $_[0] ); }
+ else { return glob( $_[0] ); }
+}
+use File::Glob;
+if ( eval{ File::Glob->import('bsd_glob'); 1; } ) {
+ # Success in importing bsd_glob
+ $have_bsd_glob = 1;
+}
+elsif ( eval{ File::Glob->import('glob'); 1; } ) {
+ warn "$My_name: I could not import File::Glob:bsd_glob, probably because your\n",
+ " Perl is too old. I have arranged to use the deprecated File::Glob:glob\n",
+ " instead.\n",
+ " WARNING: It may malfunction on clean up operation on filenames containing\n",
+ " spaces.\n";
+ $have_bsd_glob = 0;
+}
+else {
+ die "Could not import 'File::Glob:bsd_glob' or 'File::Glob:glob'\n";
+}
+
+use File::Path 2.08 qw( make_path );
+use FileHandle;
+use File::Find;
+use List::Util qw( max );
+use Cwd; # To be able to change cwd
+use Cwd "chdir"; # Ensure $ENV{PWD} tracks cwd
+use Digest::MD5;
+
+#use strict;
+
+# The following variables are assigned once and then used in symbolic
+# references, so we need to avoid warnings 'name used only once':
+use vars qw( $dvi_update_command $ps_update_command $pdf_update_command );
+
+# Translation of signal names to numbers and vv:
+%signo = ();
+@signame = ();
+if ( defined $Config{sig_name} ) {
+ $i = 0;
+ foreach $name (split('\s+', $Config{sig_name})) {
+ $signo{$name} = $i;
+ $signame[$i] = $name;
+ $i++;
+ }
+}
+else {
+ warn "Something wrong with the perl configuration: No signals?\n";
+}
+
# Line length in log file that indicates wrapping.
# This number EXCLUDES line-end characters, and is one-based.
@@ -355,8 +340,8 @@ $illegal_in_texname = "\x00\t\f\n\r\$%\\~\x7F";
# Specification of templates for extra rules.
-# See subroutine rdb_make_rule_list for examples of rule templates.
-# See subroutine rdb_set_rules for how they get used to construct rules.
+# See subroutine rdb_initialize_rules for examples of rule templates, and
+# how they get used to construct rules.
# (Documentation obviously needs to be improved!)
%extra_rule_spec = ();
@@ -403,20 +388,25 @@ $pdflatex_silent_switch = '-interaction=batchmode';
$lualatex_silent_switch = '-interaction=batchmode';
$xelatex_silent_switch = '-interaction=batchmode';
+%input_extensions = ();
# %input_extensions maps primary_rule_name to pointer to hash of file extensions
# used for extensionless files specified in the source file by constructs
# like \input{file} \includegraphics{file}
-# Could write
-#%input_extensions = ( 'latex' => { 'tex' => 1, 'eps' => 1 };,
-# 'pdflatex' => { 'tex' => 1, 'pdf' => 1, 'jpg' => 1, 'png' => 1 }; );
-# Instead we'll exercise the user-friendly access routines:
-add_input_ext( 'latex', 'tex', 'eps' );
-add_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf', 'png' );
-add_input_ext( 'lualatex', 'tex', 'jpg', 'pdf', 'png' );
-add_input_ext( 'xelatex', 'tex', 'jpg', 'pdf', 'png' );
-#show_input_ext( 'latex' ); show_input_ext( 'pdflatex' );
+set_input_ext( 'latex', 'tex', 'eps' );
+set_input_ext( 'pdflatex', 'tex', 'jpg', 'pdf', 'png' );
+$input_extensions{lualatex} = $input_extensions{pdflatex};
+$input_extensions{xelatex} = $input_extensions{pdflatex};
+# Save these values as standards to be used when switching output,
+# i.e., when actual primary rule differs from standard.
+%standard_input_extensions = %input_extensions;
%allowed_output_ext = ( ".dvi" => 1, ".xdv" => 1, ".pdf" => 1 );
+# Extensions of files preserved when clean up is by -c rather than -C:
+%small_cleanup_preserved_exts = ();
+foreach ( 'dvi', 'dviF', 'ps', 'psF', 'pdf', 'synctex.gz', 'xdv' ) {
+ $small_cleanup_preserved_exts{$_} = 1;
+}
+
# Information about options to latex and pdflatex that latexmk will simply
# pass through to (pdf)latex
@@ -1120,11 +1110,18 @@ $fdb_ext = 'fdb_latexmk'; # Extension for the file for latexmk's
$fdb_ver = 3; # Version number for kind of fdb_file.
$jobname = ''; # Jobname: as with current tex, etc indicates
- # basename of generated files.
- # Defined so that --jobname=STRING on latexmk's
- # command line has same effect as with current
- # tex, etc. (If $jobname is non-empty, then
- # the --jobname=... option is used on tex.)
+ # basename of generated files. Defined so
+ # that --jobname=STRING on latexmk's command
+ # line has same effect as with current tex,
+ # etc, with the exception listed below. (If
+ # $jobname is non-empty, then the
+ # --jobname=... option is used on tex.)
+ # Extension: $jobname is allowed to contain
+ # placeholder(s) (currently only %A),
+ # which allows construction of jobnames
+ # dependent on name of main TeX file; this is
+ # useful when a jobname is used and latexmk is
+ # invoked on multiple files.
$out_dir = ''; # Directory for output files.
# Cf. --output-directory of current (pdf)latex
$aux_dir = ''; # Directory for aux files (log, aux, etc).
@@ -1403,21 +1400,34 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
%possible_primaries = ( 'latex' => 'primary', 'pdflatex' => 'primary',
'lualatex' => 'primary', 'xelatex' => 'primary' );
-%primaries = (); # Hash of rules for primary part of make. Keys are
- # currently 'latex', 'pdflatex' or both; also 'lualatex'
- # and 'xelatex'. Value is currently irrelevant.
- # Use hash for ease of lookup
- # Make remove this later, if use rdb_makeB
-
-# Hashes, whose keys give names of particular kinds of rule. We use
-# hashes for ease of lookup.
+
+# Hashes, whose keys give names of particular kinds of rule, and targets.
+# We use hashes for ease of lookup.
%possible_one_time = ( 'view' => 1, 'print' => 1, 'update_view' => 1, );
-%requested_filerules = (); # Hash for rules corresponding to requested files.
- # The keys are the rulenames and the value is
+%target_files = (); # Hash for target files.
+ # The keys are the filenames and the value is
# currently irrelevant.
+%target_rules = (); # Hash for target rules beyond those corresponding to files.
+ # The keys are the rule names and the value is
+ # currently irrelevant.
+# The target **files** can only be set inside the FILE loop.
+$current_primary = 'latex'; # Rule to compile .tex file.
+ # Subject to document-dependent override if .tex document
+ # uses metcommands andobeying them is enabled.
+$pdf_method = ''; # How to make pdf file. '' if not requested,
+ # else 'ps2pdf', 'dvipdf', 'pdflatex', 'lualatex' or 'xelatex'
+ # Subject to document-dependent override if .tex document
+ #uses \pdfoutput or c.
+%requested_filetypes = (); # Hash of requested file types (dvi, dviF, etc)
%one_time = (); # Hash for requested one-time-only rules, currently
# possible values 'print' and 'view'.
+%actives = (); # Hash of active rules
+
+$allow_switch = 1; # Allow switch of rule structure to accommodate
+ # changed output file name of primary. Even if
+ # this flag is set on, the switch may be
+ # prohibited by other issues.
%rule_db = (); # Database of all rules:
# Hash: rulename -> [array of rule data]
@@ -1428,7 +1438,7 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
# time_of_last_run, time_of_last_file_check,
# changed
# last_result, last_message,
- # default_extra_generated
+ # default_extra_generated,
# ]
# where
# cmd_type is 'primary', 'external', or 'cusdep'
@@ -1466,6 +1476,7 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
# this rule needs to be run
# (typically because a source
# file has changed).
+ # Other values may be used for special cases.
# 0 otherwise
# out_of_date_user is like out_of_date, except
# that the detection of out-of-dateness
@@ -1503,6 +1514,9 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
# default_extra_generated is a reference to an array
# of specifications of extra generated files (beyond
# the main dest file. Standard place holders are used.
+ # active (1 or 0) is whether the rule is currently active
+ # and hence accessed in recursion and linked to
+ #
# Example ['%Y%R.log'] for (pdf)latex, and ['%R.blg']
# for bibtex. (There's no need for '%R.aux', here,
# since such generated files are detected dynamically.)
@@ -1538,7 +1552,26 @@ if (!$BIBINPUTS) { $BIBINPUTS = '.'; }
# This lists all generated files; the values
# are currently unused, only the keys
-%fdb_current = (); # Fdb-hash for all files used.
+%fdb_current = (); # Hash of information for all files used.
+ # It maps filename to a reference to an array
+ # (time, size, md5_checksum).
+@nofile = (0,-1,0); # What we use for initializing a new entry in fdb
+ # or flagging non-existent file.
+
+# The following provide information about the structure of the network of rules
+# and files. They are set by the routine rdb_set_rule_net
+%from_rules = (); # Used to optimize test for whether a file is generated.
+ # This maps files to rules that generate them. (Files
+ # anywhere in %$PHdest.)
+%from_rules_main = (); # Used to optimize test for whether a file is generated.
+ # This maps files to rules that generate them as the
+ # MAIN output. (I.e., file $$Pdest only.)
+# Classification of rules, for determining order of application
+%current_primaries = (); # Keys are primary rules (latex, etc) that are currently in use.
+@pre_primary = (); # Array of rules that are thought of as pre-primary
+@post_primary = (); # Array of rules that are thought of as post-primary
+@unusual_one_time = (); # Array of rules that are special cases of one-time rules.
+ # Currently not used.
# User's home directory
@@ -1598,15 +1631,15 @@ sub read_first_rc_file_in_list {
if ( $auto_rc_use ) {
# System rc file:
if (exists $ENV{LATEXMKRCSYS} ) {
- push @rc_system_files, $ENV{LATEXMKRCSYS};
- if ( !-e $ENV{LATEXMKRCSYS} ) {
- warn "$My_name: you've specified a system rc file `$ENV{LATEXMKRCSYS}`\n",
- " in environment variable LATEXMKRCSYS, but the file doesn't exist.\n",
- " I won't read any system rc file.\n";
- }
- else {
+ push @rc_system_files, $ENV{LATEXMKRCSYS};
+ if ( !-e $ENV{LATEXMKRCSYS} ) {
+ warn "$My_name: you've specified a system rc file `$ENV{LATEXMKRCSYS}`\n",
+ " in environment variable LATEXMKRCSYS, but the file doesn't exist.\n",
+ " I won't read any system rc file.\n";
+ }
+ else {
process_rc_file( $ENV{LATEXMKRCSYS} );
- }
+ }
}
else {
read_first_rc_file_in_list( @rc_system_files );
@@ -1781,8 +1814,8 @@ while ($_ = $ARGV[0])
"options known to the (pdf)latex programs that are also recognized by\n",
"latexmk and trigger special behavior by latexmk. Since these options\n",
"appear in the main list given by running 'latexmk --help', they do not\n",
- "appear in the following list\n",
- "NOTE ALSO: Not all of these options are supported by all versions of (pdf)latex.\n",
+ "appear in the following list\n",
+ "NOTE ALSO: Not all of these options are supported by all versions of (pdf)latex.\n",
"\n";
foreach $option ( sort( keys %allowed_latex_options, keys %allowed_latex_options_with_arg ) ) {
if (exists $allowed_latex_options{$option} ) { print " $allowed_latex_options{$option}\n"; }
@@ -2030,13 +2063,18 @@ if ($preview_continuous_mode && ($num_files != 1) ) {
}
# If selected jobname, can only apply that to one file:
-if ( ($jobname ne '') && ($num_files > 1) ) {
+if ( ($jobname ne '') && ($jobname !~ /%A/) && ($num_files > 1) ) {
&exit_help(
"Need to specify at most one filename if ".
- "jobname specified, \n".
+ "jobname specified without a %A, \n".
" but $num_files were found (after defaults and wildcarding)."
);
}
+if ( $jobname =~ /%[^A]/ ) {
+ &exit_help(
+ "Jobname '$jobname' contains placeholder other than %A."
+ );
+}
# Normalize the commands, to have place-holders for source, dest etc:
&fix_cmds;
@@ -2096,9 +2134,10 @@ if ( $aux_dir && ($aux_dir ne $out_dir) ) {
\$latex, \$pdflatex, \$lualatex, \$xelatex );
}
-if ( $jobname ne '' ) {
- $jobstring = "--jobname=\"$jobname\"";
- add_option( "$jobstring", \$latex, \$lualatex, \$pdflatex, \$xelatex );
+if ( $jobname ne '' ) {
+ # Since $jobname may include placeholder(s), put %R placeholder
+ # in option, and let %R be substituted by actual jobname at runtime.
+ add_option( "--jobname=%R", \$latex, \$lualatex, \$pdflatex, \$xelatex );
}
# Which kind of file do we preview?
@@ -2124,29 +2163,59 @@ if ( ! ( $dvi_mode || $pdf_mode || $postscript_mode || $printout_mode) ) {
$dvi_mode = 1;
}
-# Set new-style requested rules:
-if ( $dvi_mode ) { $requested_filerules{'latex'} = 1; }
-if ( $pdf_mode == 1 ) { $requested_filerules{'pdflatex'} = 1; }
+# Determine requests.
+if ( $banner ) { $postscript_mode = 1; }
+if ( $dvi_mode ) {
+ $current_primary = 'latex';
+ $requested_filetypes{'dvi'} = 1;
+ if ( length($dvi_filter) != 0 ) { $requested_filetypes{'dviF'} = 1; }
+}
+if ( $postscript_mode ) {
+ $current_primary = 'latex';
+ $requested_filetypes{'ps'} = 1;
+ if ( length($ps_filter) != 0 ) { $requested_filetypes{'psF'} = 1; }
+}
+
+if ($pdf_mode > 5) {
+ warn "$My_name: Non-allowed value of \$pdf_mode = $pdf_mode,",
+ " replaced by 1.\n";
+ $pdf_mode = 1;
+}
+if ( ($dvi_mode || $postscript_mode) && $pdf_mode ) {
+ my %disallowed = ();
+ foreach (1,4,5) { $disallowed{$_} = 1; }
+ if ($disallowed{$pdf_mode}) {
+ warn "$My_name: \$pdf_mode = $pdf_mode is incompatible with dvi and postscript modes\n",
+ " which are required by other requests.\n";
+ if ($postscript_mode) {$pdf_mode = 2;}
+ else { $pdf_mode = 3; }
+ warn " I replaced it by $pdf_mode.\n";
+ }
+}
+if ( $pdf_mode == 0 ) {
+ $pdf_method = '';
+}
+elsif ( $pdf_mode == 1 ) {
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'pdflatex';
+}
elsif ( $pdf_mode == 2 ) {
- $requested_filerules{'latex'} = 1;
- $requested_filerules{'dvips'} = 1;
- $requested_filerules{'ps2pdf'} = 1;
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'ps2pdf';
}
elsif ( $pdf_mode == 3 ) {
- $requested_filerules{'latex'} = 1;
- $requested_filerules{'dvipdf'} = 1;
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'dvipdf';
}
elsif ( $pdf_mode == 4 ) {
- $requested_filerules{'lualatex'} = 1;
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'lualatex';
}
elsif ( $pdf_mode == 5 ) {
- $requested_filerules{'xelatex'} = 1;
- $requested_filerules{'xdvipdfmx'} = 1;
-}
-if ( $postscript_mode ) {
- $requested_filerules{'latex'} = 1;
- $requested_filerules{'dvips'} = 1;
+ $requested_filetypes{'pdf'} = 1;
+ $pdf_method = 'xelatex';
}
+
if ($print_type eq 'auto') {
if ( $postscript_mode ) { $print_type = 'ps'; }
elsif ( $pdf_mode ) { $print_type = 'pdf'; }
@@ -2160,9 +2229,20 @@ if ( $printout_mode ) {
}
}
if ( $preview_continuous_mode || $preview_mode ) { $one_time{'view'} = 1; }
-if ( length($dvi_filter) != 0 ) { $requested_filerules{'dvi_filter'} = 1; }
-if ( length($ps_filter) != 0 ) { $requested_filerules{'ps_filter'} = 1; }
-if ( $banner ) { $requested_filerules{'dvips'} = 1; }
+
+$can_switch = $allow_switch;
+if ( $dvi_mode || $postscript_mode
+ || ( $printout_mode && ($print_type eq 'ps') || ($print_type eq 'dvi') )
+ || ( ($preview_mode || $preview_continuous_mode) && ( ($view eq 'ps') || ($view eq 'dvi') ) )
+ ) {
+ # Automatic switching (e.g., pdf<->dvi o/p) requires pdf files to be
+ # the only destinations. So if ps or dvi files needed, we cannot
+ # allow switching. (There will then be an error condition if a TeX
+ # engine fails to produce the correct type of output file.)
+ warn "$My_name: Disallowing switch of output file as incompatible\n",
+ " with file requests.\n";
+ $can_switch = 0;
+}
if ( $pdf_mode == 2 ) {
@@ -2264,7 +2344,8 @@ foreach $filename ( @file_list )
if ( $do_cd ) {
($filename, $path) = fileparse( $filename );
- warn "$My_name: Changing directory to '$path'\n";
+ warn "$My_name: Changing directory to '$path'\n"
+ if !$silent;
pushd( $path );
}
else {
@@ -2282,7 +2363,7 @@ foreach $filename ( @file_list )
warn "$My_name: you requested output directory '$out_dir',\n",
" but an ordinary file of the same name exists, which will\n",
" probably give an error later\n";
- }
+ }
}
if ( $aux_dir && ($aux_dir ne $out_dir) ) {
@@ -2293,50 +2374,31 @@ foreach $filename ( @file_list )
warn "$My_name: making auxiliary directory '$aux_dir'\n"
if ! $silent;
make_path $aux_dir;
- }
+ }
elsif ( ! -d $aux_dir ) {
warn "$My_name: you requested aux directory '$aux_dir',\n",
" but an ordinary file of the same name exists, which will\n",
" probably give an error later\n";
- }
- }
-
- ## remove extension from filename if was given.
- if ( find_basename($filename, $root_filename, $texfile_name) )
- {
- if ( $force_mode ) {
- warn "$My_name: Could not find file '$texfile_name'\n";
- }
- else {
- &ifcd_popd;
- &exit_msg1( "Could not find file '$texfile_name'",
- 11);
}
}
- if ($jobname ne '' ) {
- $root_filename = $jobname;
- }
&set_names;
-
- # Initialize basic dependency information:
-
# For use under error conditions:
@default_includes = ($texfile_name, $aux_main);
-
- # Initialize rule database.
- # ?? Should I also initialize file database?
- %rule_list = ();
- &rdb_make_rule_list;
- &rdb_set_rules( \%rule_list, \%extra_rule_spec );
-
+ local %rule_db = ();
+ &rdb_initialize_rules;
+
if ( $cleanup_mode > 0 ) {
# ?? MAY NEED TO FIX THE FOLLOWING IF $aux_dir or $out_dir IS SET.
my %other_generated = ();
my @index_bibtex_generated = ();
my @aux_files = ();
my @missing_bib_files = ();
- my $bibs_all_exist = 0;
+ my $bibs_all_exist = 0;
+ my %final_output_files = ();
+ foreach (keys %small_cleanup_preserved_exts) {
+ $final_output_files{"$out_dir1$root_filename.$_"} = 1;
+ }
$have_fdb = 0;
if ( -e $fdb_name ) {
print "$My_name: Examining fdb file '$fdb_name' for rules ...\n"
@@ -2344,7 +2406,7 @@ foreach $filename ( @file_list )
$have_fdb = ( 0 == rdb_read( $fdb_name ) );
}
if ( $have_fdb ) {
- rdb_for_all(
+ rdb_for_actives(
sub { # Find generated files at rule level
my ($base, $path, $ext) = fileparseA( $$Psource );
$base = $path.$base;
@@ -2358,25 +2420,25 @@ foreach $filename ( @file_list )
foreach ( keys %$PHsource ) {
if ( ( /\.bib$/ ) && (! -e $_) ) {
push @missing_bib_files, $_;
- }
- }
- }
- }
+ }
+ }
+ }
+ }
elsif ( exists $other_generated{$$Psource} ) {
-# print "=========== CHECKING: source file of rule '$rule', '$$Psource'\n",
+# print "=========== CHECKING: source file of rule '$rule', '$$Psource'\n",
# " is a generated file.\n";
- ## OLD with apparent bug:
+ ## OLD with apparent bug:
#$other_generated{$$Pdest};
}
- foreach my $key (keys %$PHdest) {
- $other_generated{$key} = 1;
- }
+ foreach my $key (keys %$PHdest) {
+ $other_generated{$key} = 1;
+ }
},
sub { # Find generated files at source file level
if ( $file =~ /\.aux$/ ) { push @aux_files, $file; }
}
- );
- if ($#missing_bib_files == -1) { $bibs_all_exist = 1; }
+ );
+ if ($#missing_bib_files == -1) { $bibs_all_exist = 1; }
}
elsif ( -e $log_name ) {
# No fdb file, but log file exists, so do inferior job by parse_log
@@ -2391,7 +2453,7 @@ foreach $filename ( @file_list )
# Maps output file created and read by (pdf)latex
# to source file of conversion.
local $primary_out = ''; # Actual output file (dvi or pdf). Not used here.
- local $fls_file_analyzed = 0;
+ local $fls_file_analyzed = 0;
&parse_log;
%other_generated = %generated_log;
}
@@ -2399,18 +2461,18 @@ foreach $filename ( @file_list )
print "$My_name: No fdb or log file, so clean up default set of files ...\n"
if $diagnostics;
}
-
+
if ( ($go_mode == 2) && !$silent ) {
warn "$My_name: Removing all generated files\n" unless $silent;
}
- my $keep_bbl = 1;
- if ( ($bibtex_use > 1.6)
- ||
+ my $keep_bbl = 1;
+ if ( ($bibtex_use > 1.6)
+ ||
( ($bibtex_use == 1.5) && ($bibs_all_exist) )
- ) {
+ ) {
$keep_bbl = 0;
- }
- if ($keep_bbl) {
+ }
+ if ($keep_bbl) {
delete $generated_exts_all{'bbl'};
}
# Convert two arrays to hashes:
@@ -2423,14 +2485,16 @@ foreach $filename ( @file_list )
delete( $other_generated{$_} );
}
foreach (@aux_files) {
- if (exists $other_generated{$_} ) {
- $aux_files{$_} = 1;
- }
- else {
- $aux_files_to_save{$_} = 1;
- }
+ if (exists $other_generated{$_} ) {
+ $aux_files{$_} = 1;
+ }
+ else {
+ $aux_files_to_save{$_} = 1;
+ }
}
+ foreach (keys %final_output_files) { delete $other_generated{$_}; }
+
if ($diagnostics) {
show_array( "For deletion, the following were determined from fdb file or log file:\n"
." Generated (from makeindex and bibtex):",
@@ -2445,63 +2509,39 @@ foreach $filename ( @file_list )
show_array( " Aux files to SAVE and not delete:", keys %aux_files_to_save );
}
- &cleanup1( $aux_dir1, $fdb_ext, 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
- split('\s+',$clean_ext),
- keys %generated_exts_all
- );
+ my @clean_args = ( 'blg', 'ilg', 'log', 'aux.bak', 'idx.bak',
+ split('\s+',$clean_ext), keys %generated_exts_all );
+ cleanup1( $aux_dir1, @clean_args );
+ if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @clean_args ); }
+ if ( $cleanup_mode == 1 ) {
+ my @clean_args = ( keys %small_cleanup_preserved_exts, split('\s+', $clean_full_ext) );
+ cleanup1( $aux_dir1, @clean_args );
+ if ( $out_dir1 ne $aux_dir1 ) { cleanup1( $out_dir1, @clean_args ); }
+ }
unlink_or_move( 'texput.log', "texput.aux", "missfont.log",
keys %index_bibtex_generated,
- keys %aux_files );
+ keys %aux_files );
if ($cleanup_includes_generated) {
unlink_or_move( keys %other_generated );
}
if ( $cleanup_includes_cusdep_generated) {
&cleanup_cusdep_generated;
}
- if ( $cleanup_mode == 1 ) {
- &cleanup1( $out_dir1, 'dvi', 'dviF', 'ps', 'psF', 'pdf',
- 'synctex.gz', 'xdv',
- split('\s+', $clean_full_ext)
- );
- }
}
if ($cleanup_fdb) {
unlink_or_move( $fdb_name );
# If the fdb file exists, it will have been read, and therefore changed
# rule database. But deleting the fdb file implies we also want
# a virgin rule database, so we must reset it:
- rdb_set_rules( \%rule_list );
+ &rdb_initialize_rules;
}
if ($cleanup_only) { next FILE; }
-
-#??? The following are not needed if use rdb_make.
-# ?? They may be set too early?
-# Arrays and hashes for picking out accessible rules.
-# Distinguish rules for making files and others
- @accessible_all = sort ( &rdb_accessible( keys %requested_filerules, keys %one_time ));
- %accessible_filerules = ();
- foreach (@accessible_all) {
- unless ( /view/ || /print/ ) { $accessible_filerules{$_} = 1; }
- }
- @accessible_filerules = sort keys %accessible_filerules;
-
-# show_array ( "=======All rules used", @accessible_all );
-# show_array ( "=======Requested file rules", sort keys %requested_filerules );
-# show_array ( "=======Rules for files", @accessible_filerules );
-
if ( $diagnostics ) {
print "$My_name: Rules after start up for '$texfile_name'\n";
rdb_show();
}
- %primaries = ();
- foreach (@accessible_all) {
- if ( ($_ eq 'latex') || ($_ eq 'pdflatex') || ($_ eq 'lualatex')
- || ($_ eq 'xelatex') )
- { $primaries{$_} = 1; }
- }
-
$have_fdb = 0;
if (! -e $aux_main ) {
# No aux file => set up trivial aux file
@@ -2509,10 +2549,10 @@ foreach $filename ( @file_list )
# as minimum, but no more if actual aux file is trivial.
# (Useful on big files without cross references.)
# If aux file doesn't exist, then any fdb file is surely
- # wrong.
- # Previously, I had condition for this as being both aux and
- # fdb files failing to exist. But it's not obvious what to
- # do if aux exists and fdb doesn't. So I won't do anything.
+ # wrong.
+ # Previously, I had condition for this as being both aux and
+ # fdb files failing to exist. But it's not obvious what to
+ # do if aux exists and fdb doesn't. So I won't do anything.
&set_trivial_aux_fdb;
}
@@ -2532,7 +2572,7 @@ foreach $filename ( @file_list )
rdb_for_some( [keys %possible_primaries], \&rdb_set_latex_deps );
}
}
- foreach $rule ( rdb_accessible( uniq1( keys %requested_filerules ) ) ){
+ foreach $rule ( &rdb_accessible ) {
# For all source files of all accessible rules,
# if the file data are not already set (e.g., from fdb_latexmk
# file, set them from disk.
@@ -2543,7 +2583,7 @@ foreach $filename ( @file_list )
if ($go_mode) {
# Force everything to be remade.
- rdb_recurse( [keys %requested_filerules], sub{$$Pout_of_date=1;} );
+ rdb_recurse( [ &rdb_target_array], sub{$$Pout_of_date=1;} );
}
@@ -2575,15 +2615,15 @@ foreach $filename ( @file_list )
#Initialize failure flags now.
$failure = 0;
$failure_msg = '';
- $failure = rdb_make( keys %requested_filerules );
+ $failure = &rdb_make;
if ( ( $failure <= 0 ) || $force_mode ) {
rdb_for_some( [keys %one_time], \&rdb_run1 );
}
if ($#primary_warning_summary > -1) {
- # N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
+ # N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
if ($warnings_as_errors) {
$failure = 1;
- $failure_msg = "Warning(s) from latex (or c.) for '$filename'; treated as error";
+ $failure_msg = "Warning(s) from latex (or c.) for '$filename'; treated as error";
}
}
if ($failure > 0) { next FILE; }
@@ -2599,11 +2639,11 @@ continue {
if ( $failure_msg ) {
#Remove trailing space
$failure_msg =~ s/\s*$//;
- warn "----------------------\n";
- warn "This message may duplicate earlier message.\n";
+ warn "----------------------\n";
+ warn "This message may duplicate earlier message.\n";
warn "$My_name: Failure in processing file '$filename':\n",
" $failure_msg\n";
- warn "----------------------\n";
+ warn "----------------------\n";
$failure = 1;
}
}
@@ -2649,12 +2689,12 @@ if ($failure_count > 0) {
if ( $where_log == 2 ) {
warn "$My_name: You requested aux_dir '$aux_dir_requested',\n".
- " but '$aux_dir' was used by the (pdf)latex engine.\n".
- " That indicates a configuration error.\n";
+ " but '$aux_dir' was used by the (pdf)latex engine.\n".
+ " That indicates a configuration error.\n";
if ( ($tex_distribution !~ /^MiKTeX/i) && ($aux_dir_requested ne $out_dir_requested) ) {
- warn " Probably you set different aux and out directories,\n".
- " but that is not supported by your TeX distribution.\n".
- " The only current distribution supporting this is MiKTeX.\n";
+ warn " Probably you set different aux and out directories,\n".
+ " but that is not supported by your TeX distribution.\n".
+ " The only current distribution supporting this is MiKTeX.\n";
}
}
@@ -2668,7 +2708,7 @@ sub set_tex_cmds {
# Usage, e.g., set_tex_cmds( '%O %S' )
my $args = $_[0];
foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
- ${$cmd} = "$cmd $args";
+ ${$cmd} = "$cmd $args";
}
# N.B. See setting of $latex_default_switches, ...,
# $xelatex_default_switches, etc, for any special options needed.
@@ -2687,28 +2727,37 @@ sub test_fix_texnames {
foreach (@_) {
if ( $^O eq "MSWin32" ) {
# On MS-Win, change directory separator '\' to '/', as needed
- # by the TeX engines, for which '\' introduces a macro name.
- # Remember that '/' is a valid directory separator in MS-Win.
+ # by the TeX engines, for which '\' introduces a macro name.
+ # Remember that '/' is a valid directory separator in MS-Win.
s[\\][/]g;
}
- if ( /[\Q$illegal_in_texname\E]/ ) {
- $illegal_char++;
- warn "$My_name: Filename '$_' contains character not allowed for TeX file.\n";
- }
- my ($filename, $path) = fileparse( $_ );
- if ( $do_cd && ($filename =~ /^&/) ) {
- $illegal_char++;
- warn "$My_name: Filename part of '$_' contains initial '&', which is\n",
- " not allowed for TeX file in my -cd mode.\n";
+ if ($do_cd) {
+ my ($filename, $path) = fileparse( $_ );
+ if ($filename =~ /[\Q$illegal_in_texname\E]/ ) {
+ $illegal_char++;
+ warn "$My_name: Filename '$filename' contains character not allowed for TeX file.\n";
+ }
+ if ($filename =~ /^&/) {
+ $illegal_char++;
+ warn "$My_name: Filename '$filename' contains initial '&', which is\n",
+ " not allowed for TeX file.\n";
+ }
}
- elsif ( /^&/ ) {
- $illegal_char++;
- warn "$My_name: Filename '$_' contains initial '&', which is not allowed for TeX file.\n";
+ else {
+ if ( /[\Q$illegal_in_texname\E]/ ) {
+ $illegal_char++;
+ warn "$My_name: Filename '$_' contains character not allowed for TeX file.\n";
+ }
+ if (/^&/ ) {
+ $illegal_char++;
+ warn "$My_name: Filename '$_' contains initial '&', which is not allowed\n",
+ " for TeX file.\n";
+ }
}
my $count_q = ($_ =~ tr/\"//);
if ( ($count_q % 2) != 0 ) {
warn "$My_name: Filename '$_' contains unbalanced quotes, not allowed.\n";
- $unbalanced_quote++;
+ $unbalanced_quote++;
}
elsif ( $count_q > 0 ) {
warn "$My_name: Removed (balanced quotes) from filename '$_',\n";
@@ -2718,7 +2767,7 @@ sub test_fix_texnames {
}
}
if ($illegal_char || $unbalanced_quote) {
- die "$My_name: Stopping because of bad filename(s).\n";
+ die "$My_name: Stopping because of bad filename(s).\n";
}
}
@@ -2732,18 +2781,18 @@ sub ensure_path {
my $var = shift;
my %cmpts = ();
if ( exists $ENV{$var} ) {
- foreach ( split $search_path_separator, $ENV{$var} ) {
- if ($_ ne '') { $cmpts{$_} = 1; }
- }
+ foreach ( split $search_path_separator, $ENV{$var} ) {
+ if ($_ ne '') { $cmpts{$_} = 1; }
+ }
}
foreach (@_) {
next if ( ($_ eq '') || (exists $cmpts{$_}) );
- if (exists $ENV{$var}) {
- $ENV{$var} = $_ . $search_path_separator . $ENV{$var};
- }
- else {
- $ENV{$var} = $_ . $search_path_separator;
- }
+ if (exists $ENV{$var}) {
+ $ENV{$var} = $_ . $search_path_separator . $ENV{$var};
+ }
+ else {
+ $ENV{$var} = $_ . $search_path_separator;
+ }
}
}
@@ -2762,19 +2811,19 @@ sub set_dirs_etc {
while ( s[^\.\/][] ) {}
}
if ($aux_dir) {
- # Ensure $aux_dir is in BIBINPUTS and TEXINPUTS search paths.
- # TEXINPUTS is used by dvips for files generated by mpost.
- # For BIBINPUTS,
- # at least one widely package (revtex4-1) generates a bib file
- # (which is used in revtex4-1 for putting footnotes in the reference
- # list), and bibtex must be run to use it. But latexmk needs to
- # determine the existence of the bib file by use of kpsewhich, otherwise
- # there is an error. So cope with this situation (and any analogous
- # cases by adding the aux_dir to the relevant path search environment
- # variables. BIBINPUTS seems to be the only one currently affected.
- foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
- ensure_path( $_, $aux_dir );
- }
+ # Ensure $aux_dir is in BIBINPUTS and TEXINPUTS search paths.
+ # TEXINPUTS is used by dvips for files generated by mpost.
+ # For BIBINPUTS,
+ # at least one widely package (revtex4-1) generates a bib file
+ # (which is used in revtex4-1 for putting footnotes in the reference
+ # list), and bibtex must be run to use it. But latexmk needs to
+ # determine the existence of the bib file by use of kpsewhich, otherwise
+ # there is an error. So cope with this situation (and any analogous
+ # cases by adding the aux_dir to the relevant path search environment
+ # variables. BIBINPUTS seems to be the only one currently affected.
+ foreach ( 'BIBINPUTS', 'TEXINPUTS' ) {
+ ensure_path( $_, $aux_dir );
+ }
}
}
@@ -2831,24 +2880,71 @@ sub add_option {
#############################################################
-sub rdb_make_rule_list {
+sub rdb_initialize_rules {
+ # Initialize rule database.
+ # (The rule database may get overridden/extended after the fdb_latexmk
+ # file is read, and after running commands to adjust to dependencies
+ # determined from document.
+ %rule_db = ();
+ %target_rules = ();
+ %target_files = ();
+
+ local %rule_list = ();
+ &rdb_set_rule_templates;
+
+ my %rule_template = %rule_list;
+ while ( my ($key, $value) = each %extra_rule_spec ) {
+ $rule_template{$key} = $value;
+ }
+ foreach my $rule ( keys %rule_template ) {
+ my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$rule_template{$rule}};
+ if ( ! $PA_extra_gen ) { $PA_extra_gen = []; }
+ my $needs_making = 0;
+ # Substitute in the filename variables, since we will use
+ # those for determining filenames. But delay expanding $cmd
+ # until run time, in case of changes.
+ foreach ($base, $source, $dest, @$PA_extra_gen ) {
+ s/%R/$root_filename/g;
+ s/%Y/$aux_dir1/;
+ s/%Z/$out_dir1/;
+ }
+ foreach ($source, $dest ) {
+ s/%B/$base/;
+ s/%T/$texfile_name/;
+ }
+ rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
+ $source, $dest, $base,
+ $needs_making, undef, undef, 1, $PA_extra_gen );
+ } # End rule iteration
+
+ # Ensure we only have one way to make pdf file, and that it is appropriate. Remove other incompatibilities
+ if ($pdf_mode == 1) { rdb_deactivate( 'dvipdf', 'ps2pdf', 'latex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 2) { rdb_deactivate( 'dvipdf', 'pdflatex', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 3) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 4) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'xdvipdfmx', 'xelatex' ); }
+ elsif ($pdf_mode == 5) { rdb_deactivate( 'pdflatex', 'ps2pdf', 'dvipdf', 'lualatex' ); }
+ else { rdb_deactivate( 'dvipdf', 'pdflatex', 'ps2pdf', 'lualatex', 'xdvipdfmx', 'xelatex' ); }
+
+ if ($dvi_mode == 1) {
+ rdb_activate( 'latex' );
+ $target_files{$dvi_final} = 1;
+ }
+ if ($postscript_mode == 1) {
+ rdb_activate( 'latex' );
+ $target_files{$ps_final} = 1;
+ }
+ if ($pdf_mode) { $target_files{$pdf_final} = 1; }
+ &rdb_set_rule_net;
+} # END rdb_initialize_rules
+
+#************************************************************
+
+sub rdb_set_rule_templates {
# Set up specifications for standard rules, adjusted to current conditions
# Substitutions: %S = source, %D = dest, %B = this rule's base
# %T = texfile, %R = root = base for latex.
# %Y for $aux_dir1, %Z for $out_dir1
- # Defaults for dvi, ps, and pdf files
- # Use local, not my, so these variables can be referenced
- local $dvi_final = "%Z%R.dvi";
- local $ps_final = "%Z%R.ps";
- local $pdf_final = "%Z%R.pdf";
- local $xdv_final = "%Z%R.xdv";
- if ( length($dvi_filter) > 0) {
- $dvi_final = "%Z%R.dviF";
- }
- if ( length($ps_filter) > 0) {
- $ps_final = "%Z%R.psF";
- }
my $print_file = '';
my $print_cmd = 'NONE';
@@ -2890,109 +2986,143 @@ sub rdb_make_rule_list {
# This is because, especially for dvi file, the contents of the file may contain
# a pointer to a file to be included, not the contents of the file!
%rule_list = (
- 'latex' => [ 'primary', "$latex", '', "%T", "%Z%B.dvi", "%R", 1, ["%Y%R.log"] ],
- 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", "%Z%B.pdf", "%R", 1, ["%Y%R.log"] ],
- 'lualatex' => [ 'primary', "$lualatex", '', "%T", "%Z%B.pdf", "%R", 1, ["%Y%R.log"] ],
- 'xelatex' => [ 'primary', "$xelatex", '', "%T", "%Z%B.xdv", "%R", 1, ["%Y%R.log"] ],
- 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, "%B.pdf", "%Z%R", 2 ],
- 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, "%B.pdf", "%Z%R", 2 ],
- 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, "%B.ps", "%Z%R", 2 ],
- 'dvifilter'=> [ 'external', $dvi_filter, 'do_viewfile', "%B.dvi", "%B.dviF", "%Z%R", 2 ],
- 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, "%B.pdf", "%Z%R", 2 ],
- 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', "%B.ps", "%B.psF", "%Z%R", 2 ],
- 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
+ 'latex' => [ 'primary', "$latex", '', "%T", $dvi_name, "%R", 1, [$log_name] ],
+ 'pdflatex' => [ 'primary', "$pdflatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
+ 'lualatex' => [ 'primary', "$lualatex", '', "%T", $pdf_name, "%R", 1, [$log_name] ],
+ 'xelatex' => [ 'primary', "$xelatex", '', "%T", $xdv_name, "%R", 1, [$log_name] ],
+ 'dvipdf' => [ 'external', "$dvipdf", 'do_viewfile', $dvi_final, $pdf_name, "%Z%R", 2 ],
+ 'xdvipdfmx' => [ 'external', "$xdvipdfmx", 'do_viewfile', $xdv_final, $pdf_name, "%Z%R", 2 ],
+ 'dvips' => [ 'external', "$dvips", 'do_viewfile', $dvi_final, $ps_name, "%Z%R", 2 ],
+ 'dvifilter' => [ 'external', $dvi_filter, 'do_viewfile', $dvi_name, $dviF_name, "%Z%R", 2 ],
+ 'ps2pdf' => [ 'external', "$ps2pdf", 'do_viewfile', $ps_final, $pdf_name, "%Z%R", 2 ],
+ 'psfilter' => [ 'external', $ps_filter, 'do_viewfile', $ps_name, $psF_name, "%Z%R", 2 ],
+ 'print' => [ 'external', "$print_cmd", 'if_source', $print_file, "", "", 2 ],
'update_view' => [ 'external', $viewer_update_command, $PA_update,
$view_file, "", "", 2 ],
'view' => [ 'external', "$viewer", 'if_source', $view_file, "", "", 2 ],
);
-
-# Ensure we only have one way to make pdf file, and that it is appropriate:
- if ($pdf_mode == 2) { delete $rule_list{'dvipdf'}; delete $rule_list{'pdflatex'}; delete $rule_list{'lualatex'}; delete $rule_list{'xelatex'}; }
- elsif ($pdf_mode == 3) { delete $rule_list{'pdflatex'}; delete $rule_list{'ps2pdf'}; delete $rule_list{'lualatex'}; delete $rule_list{'xelatex'}; }
- elsif ($pdf_mode == 4) { delete $rule_list{'pdflatex'}; delete $rule_list{'ps2pdf'}; delete $rule_list{'dvipdf'}; delete $rule_list{'xelatex'}; }
- elsif ($pdf_mode == 5) { delete $rule_list{'pdflatex'}; delete $rule_list{'ps2pdf'}; delete $rule_list{'dvipdf'}; delete $rule_list{'lualatex'}; }
- else { # Default is to leave pdflatex
- delete $rule_list{'dvipdf'}; delete $rule_list{'ps2pdf'}; delete $rule_list{'lualatex'}; delete $rule_list{'xelatex'};
- }
-
-} # END rdb_make_rule_list
+} # END rdb_set_rule_templates
#************************************************************
-sub rdb_set_rules {
- # Call rdb_set_rules( \%rule_list, ...)
- # Set up rule database from definitions
-
- # Map of files to rules that MAKE them:
- %rule_db = ();
-
- foreach my $Prule_list (@_) {
- foreach my $rule ( keys %$Prule_list) {
- my ( $cmd_type, $ext_cmd, $int_cmd, $source, $dest, $base, $test_kind, $PA_extra_gen ) = @{$$Prule_list{$rule}};
- if ( ! $PA_extra_gen ) { $PA_extra_gen = []; }
- my $needs_making = 0;
- # Substitute in the filename variables, since we will use
- # those for determining filenames. But delay expanding $cmd
- # until run time, in case of changes.
- foreach ($base, $source, $dest, @$PA_extra_gen ) {
- s/%R/$root_filename/;
- s/%Y/$aux_dir1/;
- s/%Z/$out_dir1/;
- }
- foreach ($source, $dest ) {
- s/%B/$base/;
- s/%T/$texfile_name/;
- }
- # print "$rule: $cmd_type, EC='$ext_cmd', IC='$int_cmd', $test_kind,\n",
- # " S='$source', D='$dest', B='$base' $needs_making\n";
- rdb_create_rule( $rule, $cmd_type, $ext_cmd, $int_cmd, $test_kind,
- $source, $dest, $base,
- $needs_making, undef, undef, 1, $PA_extra_gen );
-# !! ?? Last line was
-# $needs_making, undef, ($test_kind==1) );
- }
- } # End arguments of subroutine
+sub rdb_set_rule_net {
+ # Set network of rules, including links
&rdb_make_links;
-} # END rdb_set_rules
+ &rdb_classify_rules;
+}
#************************************************************
sub rdb_make_links {
# ?? Problem if there are multiple rules for getting a file. Notably pdf.
# Which one to choose?
- # Create $from_rule if there's a suitable rule.
- # Map files to rules:
- local %from_rules = ();
- rdb_for_all( sub{ if($$Pdest){$from_rules{$$Pdest} = $rule;} } );
-#?? foreach (sort keys %from_rules) {print "D='$_' F='$from_rules{$_}\n";}
- rdb_for_all(
- 0,
- sub{
- # Set from_rule, but only if it isn't set or is invalid.
- # Don't forget the biber v. bibtex issue
- if ( exists $from_rules{$file}
- && ( (!$$Pfrom_rule) || (! exists $rule_db{$$Pfrom_rule} ) )
- )
- { $$Pfrom_rule = $from_rules{$file};
- }
- }
- );
- rdb_for_all(
+# ?? Problem: what if a rule is inactive,
+# e.g., bibtex because biber is in use,
+# or xelatex when pdflatex is in use
+# or bibtex when $bibtex_use is 0.
+# What if both latex and pdflatex are being used?
+# That has been allowed. But .aux file (also
+# .log file) are made by both.
+
+# Other case: package (like bibtopic) creates bbl or other file when
+# it doesn't exist. Later a rule is created by latexmk to make that
+# file. Then the rule's main destination file should have priority
+# over non-main generated files from other rules.
+
+
+ &rdb_cache_generated;
+ rdb_for_actives(
0,
sub{
- if ( exists $from_rules{$file} ) {
- $$Pfrom_rule = $from_rules{$file};
+ if ( exists $from_rules_main{$file} ) {
+ $$Pfrom_rule = $from_rules_main{$file};
+ }
+ elsif ( exists $from_rules{$file} ) {
+ $$Pfrom_rule = $from_rules{$file};
}
if ( $$Pfrom_rule && (! rdb_rule_exists( $$Pfrom_rule ) ) ) {
$$Pfrom_rule = '';
}
-#?? print "$rule: $file, $$Pfrom_rule\n";
}
- );
+ );
+# &rdb_show;
} # END rdb_make_links
#************************************************************
+sub rdb_cache_generated {
+ # Update %from_rules
+ %from_rules = ();
+ %from_rules_main = ();
+ rdb_for_actives( \&one_from_main_rule_cache );
+ rdb_for_actives( \&one_from_rule_cache );
+} # END rdb_cache_generated
+
+#------------
+
+sub one_from_main_rule_cache {
+ # Rule context assumed.
+ # Set from_rules_main items for one rule
+ if (! $$Pdest) { return; }
+# Error message trigger: if ( $$Pdest =~ /pdf$/) { $from_rules_main{$$Pdest} = 'pdflatexA'; }
+ if ( exists $from_rules_main{$$Pdest} ) {
+ my $old_rule = $from_rules_main{$$Pdest};
+ if ( $old_rule eq $rule ) {
+ # OK
+ }
+ else {
+ warn "$My_name: Possible bug:\n",
+ " In linking rules I already set from_rules_main{$$Pdest} to '$old_rule'\n",
+ " But now I want to set it to '$rule'\n";
+#???? traceback();
+ }
+ }
+ $from_rules_main{$$Pdest} = $rule;
+} # END one_from_main_rule_cache
+
+#------------
+
+sub one_from_rule_cache {
+ # Rule context assumed.
+ # Set from_rules items for one rule
+ foreach ( @$PA_extra_gen, keys %$PHdest ) {
+ # Error message trigger: if ( $_ =~ /aux$/) { $from_rules{$_} = 'pdflatexA'; }
+ if ( exists $from_rules{$_} ) {
+ my $old_rule = $from_rules{$_};
+ if ( $old_rule eq $rule ) {
+ # OK
+ }
+ elsif ( exists $from_rules_main{$_} && ( $from_rules_main{$_} ne $rule ) ) {
+ warn "$My_name: Possible problem:\n",
+ " In linking rules, I already set from_rules_main{$_}\n".
+ " to '$from_rules_main{$_}'\n",
+ " But now I also have a different rule '$rule' that also made the file.\n";
+ }
+ elsif ( exists($possible_primaries{$old_rule}) && exists($possible_primaries{$rule}) ) {
+ # This could be problematic. But we'll let it go,
+ # because it is a common case for .aux and .log files
+ # (etc), and these cases do not appear to mess up
+ # anything (by experience).
+ # Once we allow an active flag for rules and only
+ # examine active rules, the only case of this that
+ # will appear (in the absence of other problems) will
+ # be where two primary rules are active, notably a
+ # latex rule to make dvi and a pdflatex (or other
+ # rule) to make pdf.
+ }
+ else {
+ warn "$My_name: Possible bug:\n",
+ " In linking rules I already set from_rules{$_} to '$old_rule'\n",
+ " But now I want to set it to '$rule'\n";
+#???? traceback();
+ }
+ }
+ $from_rules{$_} = $rule;
+ }
+} #END from_rule_cache
+
+#************************************************************
+
sub set_trivial_aux_fdb {
# 1. Write aux file EXACTLY as would be written if the tex file
# had no cross references, etc. I.e., a minimal .aux file.
@@ -3005,7 +3135,7 @@ sub set_trivial_aux_fdb {
print aux_file "\\relax \n";
close(aux_file);
- foreach my $rule (keys %primaries ) {
+ foreach my $rule (keys %possible_primaries ) {
rdb_ensure_file( $rule, $texfile_name );
rdb_ensure_file( $rule, $aux_main );
rdb_one_rule( $rule,
@@ -3263,6 +3393,7 @@ sub find_basename {
sub make_preview_continuous {
local @changed = ();
+ local @changed_user = ();
local @disappeared = ();
local @no_dest = (); # Non-existent destination files
local @rules_never_run = ();
@@ -3272,9 +3403,8 @@ sub make_preview_continuous {
local %rules_applied = ();
local $updated = 0;
- # What to make?
- my @targets = keys %requested_filerules;
-
+ print "======= Need to update make_preview_continuous for target files\n";
+
$quell_uptodate_msgs = 1;
local $view_file = '';
@@ -3326,7 +3456,9 @@ sub make_preview_continuous {
my $timed_out = 0;
CHANGE:
for (my $first_time = 1; 1; $first_time = 0 ) {
- my %rules_to_watch = %requested_filerules;
+
+ my %rules_to_watch = array_to_hash( &rdb_accessible );
+
$updated = 0;
$failure = 0;
$failure_msg = '';
@@ -3340,7 +3472,7 @@ CHANGE:
if ($compiling_cmd) {
Run_subst( $compiling_cmd );
}
- $failure = rdb_make( @targets );
+ $failure = &rdb_make;
## warn "=========Viewer PID = $$Pviewer_process; updated=$updated\n";
@@ -3388,10 +3520,9 @@ CHANGE:
if ( !$failure_msg ) {
$failure_msg = 'Failure to make the files correctly';
}
- @pre_primary = (); # Array of rules
- @post_primary = (); # Array of rules
- @unusual_one_time = (); # Array of rules
- &rdb_classify_rules( \%possible_primaries, keys %requested_filerules );
+ &rdb_set_rule_net;
+ %rules_to_watch = array_to_hash( &rdb_accessible );
+
# There will be files changed during the run that are irrelevant.
# We need to wait for the user to change the files.
@@ -3412,10 +3543,10 @@ CHANGE:
}
}
else {
- if ( ($#primary_warning_summary > -1) && $warning_cmd ) {
+ if ( ($#primary_warning_summary > -1) && $warning_cmd ) {
Run_subst( $warning_cmd );
}
- elsif ( ($#primary_warning_summary > -1) && $warnings_as_errors && $failure_cmd ) {
+ elsif ( ($#primary_warning_summary > -1) && $warnings_as_errors && $failure_cmd ) {
Run_subst( $failure_cmd );
}
elsif ($success_cmd) {
@@ -3435,21 +3566,24 @@ CHANGE:
warn "Cannot open '$deps_file' for output of dependency information\n";
}
}
- if ( $first_time || $updated || $failure ) {
- print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
- }
- $waiting = 1; if ($diagnostics) { warn "WAITING\n"; }
-# During waiting for file changes, handle ctrl/C and ctrl/break here, rather than letting
-# system handle them by terminating script (and any script that calls it). This allows,
-# for example, the clean up code in the following command line to work:
-# latexmk -pvc foo; cleanup;
+
+ # Now wait for a file to change...
+ &rdb_cache_generated;
+ # During waiting for file changes, handle ctrl/C and ctrl/break here,
+ # rather than letting system handle them by terminating script (and
+ # code in the following command line to work: any script that calls
+ # it). This allows, for example, the command cleanup in the following
+ # command line to work:
+ # latexmk -pvc foo; cleanup;
&catch_break;
$have_break = 0;
$last_action_time = time();
+ $waiting = 1;
+ print "\n=== Watching for updated files. Use ctrl/C to stop ...\n";
WAIT: while (1) {
sleep( $sleep_time );
if ($have_break) { last WAIT; }
- if ( rdb_new_changes(keys %rules_to_watch) ) {
+ if ( rdb_user_changes(keys %rules_to_watch) ) {
if (!$silent) {
warn "$My_name: Need to remake files.\n";
&rdb_diagnose_changes( ' ' );
@@ -3467,8 +3601,8 @@ CHANGE:
}
if ($have_break) { last WAIT; }
if ($pvc_timeout && ( time() > $last_action_time+60*$pvc_timeout_mins ) ) {
- $timed_out = 1;
- last WAIT;
+ $timed_out = 1;
+ last WAIT;
}
} # end WAIT:
&default_break;
@@ -3579,8 +3713,8 @@ sub cleanup1 {
my $root_fixed = fix_pattern( $root_filename );
foreach (@_) {
my $name = /%R/ ? $_ : "%R.$_";
- $name =~ s/%R/${root_fixed}/;
- $name = $dir.$name;
+ $name =~ s/%R/${root_fixed}/;
+ $name = $dir.$name;
unlink_or_move( my_glob( "$name" ) );
}
} #END cleanup1
@@ -3589,7 +3723,7 @@ sub cleanup1 {
sub cleanup_cusdep_generated {
# Remove files generated by custom dependencies
- rdb_for_all( \&cleanup_one_cusdep_generated );
+ rdb_for_actives( \&cleanup_one_cusdep_generated );
} #END cleanup_cusdep_generated
#************************************************************
@@ -3603,15 +3737,15 @@ sub cleanup_one_cusdep_generated {
# NOT cusdep
return;
}
- if ( (-e $$Pdest) && (-e $$Psource) ) {
- unlink_or_move( $$Pdest );
- }
- elsif ( (-e $$Pdest) && (!-e $$Psource) ) {
+ if ( ! -e $$Psource ) {
warn "$My_name: For custom dependency '$rule',\n",
" I won't delete destination file '$$Pdest'\n",
+ " and any other generated files,\n",
" because the source file '$$Psource' doesn't exist,\n",
" so the destination file may not be able to be recreated\n";
+ return;
}
+ unlink_or_move( $$Pdest, keys %$PHdest );
} #END cleanup_one_cusdep_generated
#************************************************************
@@ -3903,9 +4037,9 @@ sub check_biber_log {
# Side effect: add source files @biber_source
my $base = $_[0];
my $Pbiber_source = $_[1];
- my $log_name = "$base.blg";
- my $log_file = new FileHandle;
- open( $log_file, "<$log_name" )
+ my $blg_name = "$base.blg";
+ my $blg_file = new FileHandle;
+ open( $blg_file, "<$blg_name" )
or return 3;
my $have_warning = 0;
my $have_error = 0;
@@ -3920,7 +4054,7 @@ sub check_biber_log {
my $control_file_missing = 0;
my $control_file_malformed = 0;
my %remote = (); # List of extensions of remote files
- while (<$log_file>) {
+ while (<$blg_file>) {
if (/> WARN /) {
print "Biber warning: $_";
$have_warning = 1;
@@ -3939,10 +4073,10 @@ sub check_biber_log {
push @$Pbiber_source, $2;
}
elsif ( /> ERROR - .*\.bcf is malformed/ ) {
- # Special treatment: Malformed .bcf file commonly results from error
- # in (pdf)latex run. This error must be ignored.
- $control_file_malformed = 1;
- }
+ # Special treatment: Malformed .bcf file commonly results from error
+ # in (pdf)latex run. This error must be ignored.
+ $control_file_malformed = 1;
+ }
else {
$have_error = 1;
$error_count ++;
@@ -3952,32 +4086,32 @@ sub check_biber_log {
}
}
elsif ( /> INFO - Data source '([^']*)' is a remote BibTeX data source - fetching/
- ){
- my $spec = $1;
+ ){
+ my $spec = $1;
my ( $base, $path, $ext ) = fileparseA( $spec );
$remote{$ext} = 1;
- }
+ }
elsif ( /> INFO - Found .* '([^']+)'\s*$/
|| /> INFO - Found '([^']+)'\s*$/
|| /> INFO - Reading '([^']+)'\s*$/
|| /> INFO - Processing .* file '([^']+)' .*$/
- ) {
- my $file = $1;
+ ) {
+ my $file = $1;
my ( $base, $path, $ext ) = fileparseA( $file );
- if ($remote{$ext} && ( $base =~ /^biber_remote_data_source/ ) && 1) {
- # Ignore the file, which appears to be a temporary local copy
- # of a remote file. Treating the file as a source file will
- # be misleading, since it will normally have been deleted by
- # biber itself.
- }
+ if ($remote{$ext} && ( $base =~ /^biber_remote_data_source/ ) && 1) {
+ # Ignore the file, which appears to be a temporary local copy
+ # of a remote file. Treating the file as a source file will
+ # be misleading, since it will normally have been deleted by
+ # biber itself.
+ }
elsif ( (defined $Pbiber_source) && (-e $file) ) {
- # Note that biber log file gives full path to file. (No search is
- # needed to find it.) The file must have existed when biber was
- # run. If it doesn't exist now, a few moments later, it must
- # have gotten deleted, probably by biber (e.g., because it is a
- # copy of a remote file).
- # So I have included a condition above that the file must
- # exist to be included in the source-file list.
+ # Note that biber log file gives full path to file. (No search is
+ # needed to find it.) The file must have existed when biber was
+ # run. If it doesn't exist now, a few moments later, it must
+ # have gotten deleted, probably by biber (e.g., because it is a
+ # copy of a remote file).
+ # So I have included a condition above that the file must
+ # exist to be included in the source-file list.
push @$Pbiber_source, $file;
}
}
@@ -3988,7 +4122,7 @@ sub check_biber_log {
$bibers_error_count = $1;
}
}
- close $log_file;
+ close $blg_file;
if ($control_file_malformed){return 11;}
my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source,
@@ -4038,11 +4172,11 @@ sub run_bibtex {
local %ENV = %ENV;
my ( $base, $path, $ext ) = fileparseA( $$Psource );
if ( $path && $bibtex_fudge ) {
- # Since (e.g.,) 'bibtex output/main.aux' doesn't find subsidiary .aux
+ # Since (e.g.,) 'bibtex output/main.aux' doesn't find subsidiary .aux
# files, as from \@include{chap.aux}, we change directory to the
- # directory of the top-level .aux file to run bibtex. But we have to
- # fix search paths for .bib and .bst, since they may be specified
- # relative to the document directory.
+ # directory of the top-level .aux file to run bibtex. But we have to
+ # fix search paths for .bib and .bst, since they may be specified
+ # relative to the document directory.
my $cwd = good_cwd();
foreach ( 'BIBINPUTS', 'BSTINPUTS' ) {
if ( exists $ENV{$_} ) {
@@ -4051,18 +4185,18 @@ sub run_bibtex {
else {
$ENV{$_} = $cwd.$search_path_separator;
}
- }
+ }
pushd( $path );
- if (!$silent) {
- print "$My_name: changed directory to '$path'\n",
- "Set BIBINPUTS='$ENV{BIBINPUTS}'\n",
- "Set BSTINPUTS='$ENV{BSTINPUTS}'\n";
- }
+ if (!$silent) {
+ print "$My_name: changed directory to '$path'\n",
+ "Set BIBINPUTS='$ENV{BIBINPUTS}'\n",
+ "Set BSTINPUTS='$ENV{BSTINPUTS}'\n";
+ }
$return = &Run_subst( undef, undef, '', $base.$ext, '', $base );
popd();
- if (!$silent) {
- print "$My_name: changed directory back to '", cwd(), "'\n";
- }
+ if (!$silent) {
+ print "$My_name: changed directory back to '", cwd(), "'\n";
+ }
}
else {
$return = Run_subst();
@@ -4083,16 +4217,16 @@ sub check_bibtex_log {
# (pdf)latex).
my $base = $_[0];
- my $log_name = "$base.blg";
- my $log_file = new FileHandle;
- open( $log_file, "<$log_name" )
+ my $blg_name = "$base.blg";
+ my $blg_file = new FileHandle;
+ open( $blg_file, "<$blg_name" )
or return 3;
my $have_warning = 0;
my $have_error = 0;
my $missing_citations = 0;
my @missing_aux = ();
my $error_count = 0;
- while (<$log_file>) {
+ while (<$blg_file>) {
if (/^Warning--/) {
#print "Bibtex warning: $_";
$have_warning = 1;
@@ -4109,7 +4243,7 @@ sub check_bibtex_log {
$have_error = 1;
}
}
- close $log_file;
+ close $blg_file;
my $missing = $missing_citations + $#missing_aux + 1;
if ( $#missing_aux > -1 ) {
@@ -4158,10 +4292,62 @@ sub normalize_force_directory {
#**************************************************
sub set_names {
- # Set names of standard files:
- $aux_main = "$aux_dir1$root_filename.aux";
- $log_name = "$aux_dir1$root_filename.log";
- $fdb_name = "$aux_dir1$root_filename.$fdb_ext";
+ # Set names of standard files. These are global variables.
+
+ ## Remove extension from filename if was given.
+ if ( find_basename($filename, $root_filename, $texfile_name) ) {
+ if ( $force_mode ) {
+ warn "$My_name: Could not find file '$texfile_name'\n";
+ }
+ else {
+ &ifcd_popd;
+ &exit_msg1( "Could not find file '$texfile_name'",
+ 11);
+ }
+ }
+ $tex_basename = $root_filename; # Base name of TeX file itself
+ if ($jobname ne '' ) {
+ $root_filename = $jobname;
+ $root_filename =~ s/%A/$tex_basename/g;
+ }
+
+ $aux_main = "%Y%R.aux";
+ $log_name = "%Y%R.log";
+ $fdb_name = "%Y%R.$fdb_ext";
+ # Note: Only MiKTeX allows out_dir ne aux_dir. It puts
+ # .fls file in out_dir, not aux_dir, which seems
+ # not natural.
+ $fls_name = "%Z%R.fls";
+
+ $dvi_name = "%Z%R.dvi";
+ $dviF_name = "%Z%R.dviF";
+ $ps_name = "%Z%R.ps";
+ $psF_name = "%Z%R.psF";
+ $pdf_name = "%Z%R.pdf";
+ ## It would be logical for a .xdv file to be put in the out_dir,
+ ## just like a .dvi file. But the only program, MiKTeX, that
+ ## currently implements aux_dir, and hence allows aux_dir ne out_dir,
+ ## puts .xdv file in aux_dir. So we must use %Y not %Z:
+ $xdv_name = "%Y%R.xdv";
+
+ foreach ( $aux_main, $log_name, $fdb_name, $fls_name,
+ $dvi_name, $ps_name, $pdf_name, $xdv_name, $dviF_name, $psF_name ) {
+ s/%R/$root_filename/g;
+ s/%Y/$aux_dir1/;
+ s/%Z/$out_dir1/;
+ }
+
+ $dvi_final = $dvi_name;
+ $ps_final = $ps_name;
+ $pdf_final = $pdf_name;
+ $xdv_final = $xdv_name;
+
+ if ( length($dvi_filter) > 0) {
+ $dvi_final = $dviF_name;
+ }
+ if ( length($ps_filter) > 0) {
+ $ps_final = $psF_name;
+ }
}
#**************************************************
@@ -4268,7 +4454,7 @@ sub parse_log {
my $line = 0;
my $engine = 'pdfTeX'; # Simple default in case of problems
while(<$log_file>) {
- $line++;
+ $line++;
# Could use chomp here, but that fails if there is a mismatch
# between the end-of-line sequence used by latex and that
# used by perl. (Notably a problem with MSWin latex and
@@ -4282,23 +4468,23 @@ sub parse_log {
# options open by putting the line into @lines before
# and after appending the next line:
my $len = length($_);
- if ($line == 1) {
- if ( /^This is ([^,]+), / ) {
- $engine = $1;
- print "=== TeX engine is '$engine'\n"
- if (!$silent);
- if ( /^This is ([^,]+), [^\(]*\(([^\)]+)\)/ ) {
- $tex_distribution = $2;
- print "=== TeX distribution is '$tex_distribution'\n"
- if ($diagnostics);
- }
- }
- else {
- warn "$My_name: First line of .log file '$log_name' is not in standard format.\n";
- }
- }
- else {
- # LuaTeX sometimes wraps at 80 instead of 79, so work around this
+ if ($line == 1) {
+ if ( /^This is ([^,]+), / ) {
+ $engine = $1;
+ print "=== TeX engine is '$engine'\n"
+ if (!$silent);
+ if ( /^This is ([^,]+), [^\(]*\(([^\)]+)\)/ ) {
+ $tex_distribution = $2;
+ print "=== TeX distribution is '$tex_distribution'\n"
+ if ($diagnostics);
+ }
+ }
+ else {
+ warn "$My_name: First line of .log file '$log_name' is not in standard format.\n";
+ }
+ }
+ else {
+ # LuaTeX sometimes wraps at 80 instead of 79, so work around this
while ( ( ($len == $log_wrap) || ( ($engine eq 'LuaTeX') && ($len == $log_wrap+1) ) )
&& !eof($log_file) ) {
push @lines, $_;
@@ -4306,7 +4492,7 @@ sub parse_log {
$extra =~ s/[\n\r]*$//;
$len = length($extra);
$_ .= $extra;
- }
+ }
}
push @lines, $_;
}
@@ -4388,17 +4574,17 @@ LINE:
}
elsif ( $state == 1 ) {
$state = 2;
- if (-e $source_log) {
- # then the string preceeding $source_log on the line after the
- # ** line is probably the PWD as it appears in filenames in the
+ if (-e $source_log) {
+ # then the string preceeding $source_log on the line after the
+ # ** line is probably the PWD as it appears in filenames in the
# log file, except if the file appears in two locations.
if ( m{^\("([^"]*)[/\\]\Q$source_log\E"} ) {
unshift @pwd_log, $1;
- }
+ }
elsif ( m{^\((.*)[/\\]\Q$source_log\E} ) {
unshift @pwd_log, $1;
}
- }
+ }
}
if ( $block_type ) {
@@ -4444,9 +4630,9 @@ LINE:
$bad_citation++;
}
elsif ( /^Missing character: There is no /
- || /^! Package inputenc Error: Unicode character /
- || /^! Bad character code /
- ) {
+ || /^! Package inputenc Error: Unicode character /
+ || /^! Bad character code /
+ ) {
$bad_character++;
}
elsif ( /^Document Class: / ) {
@@ -4561,15 +4747,19 @@ LINE:
$dependents{normalize_filename($file, @pwd_log)} = 0;
my $file1 = $file;
if ( $aux_dir ) {
- # Allow for the possibility that latex generated
- # a file in $aux_dir, from which the missing file can
- # be created by a cusdep (or other) rule that puts
- # the result in $out_dir. If the announced missing file
- # has no path, then it would be effectively a missing
- # file in $aux_dir, with a path. So give this alternate
- # location.
- my $file1 = normalize_force_directory( $aux_dir1, $file );
- $dependents{$file1} = 0;
+ # Allow for the possibility that latex generated
+ # a file in $aux_dir, from which the missing file can
+ # be created by a cusdep (or other) rule that puts
+ # the result in $out_dir. If the announced missing file
+ # has no path, then it would be effectively a missing
+ # file in $aux_dir, with a path. So give this alternate
+ # location.
+ # It is also possible to have a file that is in a directory
+ # relative to the aux_dir, so allow for that as well
+ my $file1 = normalize_force_directory( $aux_dir1, $file );
+ $dependents{$file1} = 0;
+ $dependents{$aux_dir1.$file} = 0;
+
}
next LINE;
}
@@ -4577,11 +4767,11 @@ LINE:
if ( (! $fls_file_analyzed)
&& /^File: (.+) Graphic file \(type / ) {
# First line of message from includegraphics/x
- # But this does NOT include full path information
- # (if exact match is not found and a non-trivial
- # kpsearch was done by (pdf)latex).
- # But the source-file information is in the fls file,
- # if we are using it.
+ # But this does NOT include full path information
+ # (if exact match is not found and a non-trivial
+ # kpsearch was done by (pdf)latex).
+ # But the source-file information is in the fls file,
+ # if we are using it.
$dependents{normalize_clean_filename($1, @pwd_log)} = 1;
next LINE;
}
@@ -4617,18 +4807,18 @@ LINE:
}
}
- if ( ($fls_file_analyzed) && (! $analyze_input_log_always) ) {
- # Skip the last part, which is all about finding input
- # file names which should all appear more reliably in the
- # fls file.
- next LINE;
- }
-
+ if ( ($fls_file_analyzed) && (! $analyze_input_log_always) ) {
+ # Skip the last part, which is all about finding input
+ # file names which should all appear more reliably in the
+ # fls file.
+ next LINE;
+ }
+
my @new_includes = ();
-
+
GRAPHICS_INCLUDE_CANDIDATE:
while ( /<([^>]+)(>|$)/g ) {
- if ( -f $1 ) { push @new_includes, $1; }
+ if ( -f $1 ) { push @new_includes, $1; }
} # GRAPHICS_INCLUDE_CANDIDATE:
INCLUDE_CANDIDATE:
@@ -4805,7 +4995,7 @@ CANDIDATE:
# so use kpsewhich.
# If the file still is not found, assume non-existent;
$kpsearch_candidates{$candidate} = 1;
- delete $dependents{$candidate};
+ delete $dependents{$candidate};
}
elsif ($code == 2) {
# Candidate is from '(...' construct in log file, for input file
@@ -4850,9 +5040,9 @@ CANDIDATE:
my @kpsearch_candidates = keys %kpsearch_candidates;
if (@kpsearch_candidates) {
- foreach my $result ( kpsewhich( @kpsearch_candidates ) ) {
- $dependents{$result} = 4;
- }
+ foreach my $result ( kpsewhich( @kpsearch_candidates ) ) {
+ $dependents{$result} = 4;
+ }
}
CANDIDATE_PAIR:
@@ -4893,7 +5083,7 @@ CANDIDATE_PAIR:
}
if ( ($#warning_list >= 0) && !$log_silent ) {
- @warning_list = uniqs( @warning_list );
+ @warning_list = uniqs( @warning_list );
show_array( "$My_name: List of undefined refs and citations:",
@warning_list );
}
@@ -4961,46 +5151,46 @@ sub find_set_log {
# Use of $aux_dir different to $out_dir, when (*)latex doesn't support
# the -aux-directory option (notably with TeXLive distribution).
if ($where_log >= 0) {
- # .log file was found on previous run. No need to repeat search, since
- # if the location were to change from run to run, we'd have other
- # serious difficulties that are to hard to deal with.
- return;
+ # .log file was found on previous run. No need to repeat search, since
+ # if the location were to change from run to run, we'd have other
+ # serious difficulties that are to hard to deal with.
+ return;
}
if ( test_gen_file( "$aux_dir1$root_filename.log" ) ) {
- # .log file is in expected place.
- $where_log = 1;
+ # .log file is in expected place.
+ $where_log = 1;
}
elsif ( test_gen_file( "$out_dir1$root_filename.log" ) ) {
- # .log file is in out_dir not in aux_dir.
- # Presumably there is a configuration error
- # that prevents aux_dir from being used by latex.
- # So change $aux_dir to the actually used value.
- $where_log = 2;
- $aux_dir = $out_dir;
+ # .log file is in out_dir not in aux_dir.
+ # Presumably there is a configuration error
+ # that prevents aux_dir from being used by latex.
+ # So change $aux_dir to the actually used value.
+ $where_log = 2;
+ $aux_dir = $out_dir;
}
elsif ( test_gen_file( "$root_filename.log" ) ) {
- # .log file is not in out_dir nor in aux_dir, but is in cwd.
- # Presumably there is a configuration error
- # that prevents the directories from being used by latex.
- # So change $aux_dir to the actually used value.
- $where_log = 3;
- $aux_dir = "";
+ # .log file is not in out_dir nor in aux_dir, but is in cwd.
+ # Presumably there is a configuration error
+ # that prevents the directories from being used by latex.
+ # So change $aux_dir to the actually used value.
+ $where_log = 3;
+ $aux_dir = "";
}
else {
- # No .log file found
- $failure = 1;
- $$Plast_result = 2;
- $where_log = 0;
- $failure_msg
- = "(Pdf)LaTeX didn't generate the expected log file '$log_name'\n";
+ # No .log file found
+ $failure = 1;
+ $$Plast_result = 2;
+ $where_log = 0;
+ $failure_msg
+ = "(Pdf)LaTeX didn't generate the expected log file '$log_name'\n";
}
if ($where_log > 1) {
- warn "$My_name: Changed aux_dir from '$aux_dir_requested' to '$aux_dir'\n".
- " to allow for probable configuration error\n";
- # Allow for the changes associated with change of $aux_dir:
- &set_dirs_etc;
- &set_names;
- warn "$My_name: Actual .log file is\n",
+ warn "$My_name: Changed aux_dir from '$aux_dir_requested' to '$aux_dir'\n".
+ " to allow for probable configuration error\n";
+ # Allow for the changes associated with change of $aux_dir:
+ &set_dirs_etc;
+ &set_names;
+ warn "$My_name: Actual .log file is\n",
" '$log_name'\n",
" instead of the value\n",
" '$aux_dir_requested/$root_filename.log'\n",
@@ -5042,10 +5232,10 @@ sub parse_fls {
if (/^\s*PWD\s+(.*)$/) {
$cwd = $1;
$$Ppwd_latex = $cwd;
- if ( $cwd =~ /\"/ ) {
- warn "$My_name: The working directory has a '\"' character in its name:\n",
+ if ( $cwd =~ /\"/ ) {
+ warn "$My_name: The working directory has a '\"' character in its name:\n",
" '$cwd'\n This can cause me trouble. Beware!\n";
- }
+ }
}
elsif (/^\s*INPUT\s+(.*)$/) {
# Take precautions against aliasing of foo, ./foo and other possibilities for cwd.
@@ -5055,9 +5245,9 @@ sub parse_fls {
# us from coding issues if the PWD contains non-ASCII characters. What
# coding scheme (UTF-8, code page, etc) is used depends on OS, TeX
# implementation, ...
- if ( defined $$Ppwd_latex ) {
+ if ( defined $$Ppwd_latex ) {
$file =~ s(^\Q$$Ppwd_latex\E[\\/])();
- }
+ }
$file = normalize_filename( $file );
if ( (exists $$Poutputs{$file}) && (! exists $$Pinputs{$file}) ) {
$$Pfirst_read_after_write{$file} = 1;
@@ -5184,13 +5374,13 @@ sub parse_aux {
@$Pbst_files = uniqs( @$Pbst_files );
my @bad_bib = ();
foreach ( @$Pbib_files ) {
- if ( /\s/ ) { push @bad_bib, $_; }
+ if ( /\s/ ) { push @bad_bib, $_; }
}
if ($#bad_bib >= 0) {
- warn "$My_name: White space in an argument list for \\bibliography.\n",
+ warn "$My_name: White space in an argument list for \\bibliography.\n",
" which is not allowed by bibtex. Bad arguments:\n";
foreach (@bad_bib ) { warn " '$_'\n"; }
- return 3;
+ return 3;
}
if ( $#not_found < 0) {
warn "$My_name: Found bibliography file(s) [@$Pbib_files]\n"
@@ -5271,7 +5461,7 @@ sub fdb_get {
# that may have changed the file or the last time the file was checked
# for changes --- see below.
# For non-existent file, deletes its entry in fdb_current,
- # and returns (0,-1,0)
+ # and returns (0,-1,0) (whatever is in @nofile).
# As an optimization, the md5 value is taken from the cache in
# fdb_current, if the time and size stamp indicate that the
# file has not changed.
@@ -5293,9 +5483,6 @@ sub fdb_get {
my ($file, $check_time) = @_;
if ( ! defined $check_time ) { $check_time = 0;}
my ($new_time, $new_size) = get_time_size($file);
- my @nofile = (0,-1,0); # What we use for initializing
- # a new entry in fdb or flagging
- # non-existent file
if ( $new_size < 0 ) {
delete $fdb_current{$file};
return @nofile;
@@ -5328,7 +5515,6 @@ sub fdb_get {
$recalculate_md5 = 1;
}
if ($recalculate_md5) {
-#warn "--------- RECALC MD5: $rule $file: (N,O,R,C) \n = $new_time, $time, $$Prun_time, $check_time\n";
@$file_data = ( $new_time, $new_size, get_checksum_md5( $file ) );
}
return @$file_data;;
@@ -5341,7 +5527,7 @@ sub fdb_set {
# Set data in file data cache, i.e., %fdb_current
my ($file, $time, $size, $md5 ) = @_;
if ( ! exists $fdb_current{$file} ) {
- $fdb_current{$file} = [0, -1, 0];
+ $fdb_current{$file} = [@nofile];
}
@{$fdb_current{$file}} = ( $time, $size, $md5 );
} #END fdb_set
@@ -5368,20 +5554,44 @@ sub rdb_read {
# Sets rule database from saved file, in format written by rdb_write.
# Returns -1 if file could not be read else number of errors.
# Thus return value on success is 0
- my $in_name = $_[0];
+ # Requires: Rule database initialized with standard rules, with
+ # conditions corresponding to requests determined by
+ # initialization and command line options.
+ # Asssumption: Normally the fdb_latexmk file contains state of
+ # rules and files corresponding to end of last
+ # compilation, and the rules in the file were
+ # active on that run.
+ # Complications arise when that state does not correspond to current
+ # rule set:
+ # (a) Configuration etc may have changed: e.g., different out_dir,
+ # different target rules and files, including different tex engine.
+ # (b) Output extension of primary rule may be different from current
+ # initialized one, because of document properties (use of
+ # \pdfoutput etc).
+ # (c) The same may arise because of misconfigured rules, a situation
+ # that may or may not have changed in current run.
+ # (d) The primary engine requested may not be the one used in
+ # the previous run, possibly because (i) request has
+ # changed, or (ii) document metacommand was obeyed to change
+ # engine. (The last is not currently implemented, but
+ # may/should be in the future.)
+ # (e) Something else, e.g., copying/editing of fdb_latexmk file.
+ #
+ local $in_name = $_[0];
my $in_handle = new FileHandle;
$in_handle->open( $in_name, '<' )
- or return ();
+ or return ();
my $errors = 0;
my $state = -1; # Values: -1: before start; 0: outside rule;
# 1: in source section;
# 2: in generated file section;
# 10: ignored rule.
my $rule = '';
- my $run_time = 0;
- my $source = '';
- my $dest = '';
+ local $run_time = 0;
+ local $source = '';
+ local $dest = '';
my $base = '';
+ my %old_actives = (); # Hash: keys are rules in fdb_latexmk file
local %new_sources = (); # Hash: rule => { file=>[ time, size, md5, fromrule ] }
my $new_source = undef; # Reference to hash of sources for current rule
LINE:
@@ -5409,6 +5619,7 @@ LINE:
# emacs from misparsing an isolated single quote
$run_time = $check_time = 0;
$source = $dest = $base = '';
+ $old_actives{$rule} = 1;
if ( $tail =~ /^\s*(\S+)\s*$/ ) {
$run_time = $1;
}
@@ -5426,13 +5637,7 @@ LINE:
$check_time = $5;
}
if ( rdb_rule_exists( $rule ) ) {
- rdb_one_rule( $rule,
- sub{
- if ($$Ptest_kind == 3) { $$Ptest_kind = 1; }
- $$Prun_time = $run_time;
- $$Pcheck_time = $check_time;
- }
- );
+ rdb_one_rule( $rule, \&rdb_read_set_rule );
}
elsif ($rule =~ /^cusdep\s+(\S+)\s+(\S+)\s+(.+)$/ ) {
# Create custom dependency
@@ -5445,24 +5650,24 @@ LINE:
foreach my $dep ( @cus_dep_list ) {
my ($tryfromext,$trytoext,$must,$try_func_name) = split('\s+',$dep);
if ( ($tryfromext eq $fromext) && ($trytoext eq $toext) ) {
- $func_name = $try_func_name;
+ $func_name = $try_func_name;
}
}
- if ($func_name) {
- my $PAnew_cmd = ['do_cusdep', $func_name];
+ if ($func_name) {
+ my $PAnew_cmd = ['do_cusdep', $func_name];
# Set source file as non-existent.
# If it existed on last run, it will be in later
# lines of the fdb file
rdb_create_rule( $rule, 'cusdep', '', $PAnew_cmd, 1,
$source, $dest, $base, 0, $run_time, $check_time, 1 );
- }
- else {
- warn "$My_name: In file-database '$in_name', the custom-dependency rule\n",
- " '$rule' is not available in this session.\n",
- " Presumably it's no longer in your configuration for latexmk.\n";
- $state = 10;
- next LINE;
- }
+ }
+ else {
+ warn "$My_name: In file-database '$in_name', the custom-dependency rule\n",
+ " '$rule' is not available in this session.\n",
+ " Presumably it's no longer in your configuration for latexmk.\n";
+ $state = 10;
+ next LINE;
+ }
}
elsif ( $rule =~ /^(makeindex|bibtex|biber)\s*(.*)$/ ) {
my $PA_extra_gen = [];
@@ -5505,9 +5710,10 @@ LINE:
$source, $dest, $base, 0, $run_time, $check_time, 1, $PA_extra_gen );
}
else {
- warn "$My_name: In file-database '$in_name' rule '$rule'\n",
- " is not in use in this session\n"
- if $diagnostics;
+ if ($diagnostics) {
+ warn "$My_name: In file-database '$in_name' rule '$rule'\n",
+ " is not in use in this session\n";
+ }
$new_source = undef;
$state = 10;
next LINE;
@@ -5541,7 +5747,7 @@ LINE:
rdb_ensure_file( $rule, $file, undef, 1 );
rdb_set_file1( $rule, $file, $time, $size, $md5 );
fdb_set( $file, $time, $size, $md5 );
- # Save the rest of the data, especially the from_fule until we know all
+ # Save the rest of the data, especially the from_rule until we know all
# the rules, otherwise the from_rule may not exist.
# Also we'll have a better chance of looping through files.
${$new_source}{$file} = [ $time, $size, $md5, $from_rule ];
@@ -5560,21 +5766,75 @@ LINE:
undef $in_handle;
# Set cus dependencies.
&rdb_set_dependents( keys %rule_db );
-
-#?? Check from_rules exist.
+ &rdb_set_rule_net;
return $errors;
} # END rdb_read
#************************************************************
+sub rdb_read_set_rule {
+ # Rule context assumed. Implicit passing of $dest, $run_time, $check_time,
+ # $in_name used as local variables in calling routine rdb_read;
+ if ($$Ptest_kind == 3) { $$Ptest_kind = 1; }
+ $$Prun_time = $run_time;
+ $$Pcheck_time = $check_time;
+ # Deal with possibility that destination in fdb_latexmk has different name
+ # than the default one. The only case that concerns us is where
+ # the extension is changed (by \pdfoutput, e.g., in tex file). But
+ # it is possible out and aux directories have been chosen differently,
+ # and the user choice there MUST OVERRIDE the value in the fdb_latexmk file.
+ if ($dest ne $$Pdest) {
+ if (! $possible_primaries{$rule} ) {
+ warn "$My_name: In reading rule '$rule' in '$in_name',\n",
+ " name of destination file is not current one; I'll flag rule as out of date.\n";
+ $$Pout_of_date = 10;
+ }
+ elsif ( ! rdb_is_active($rule) ) {
+ warn "$My_name: In reading rule '$rule' in '$in_name',\n",
+ " rule is not currently active.\n";
+ # No fixup now. Causes to be analyzed:
+ # Change of requested files: no action needed.
+ # Obeying of metacommand: not implemented yet.
+ }
+ else {
+ # Get here if rule is active and primary and destination is different
+ warn "$My_name: In reading rule '$rule' in '$in_name',\n",
+ " destination has different name than configured...\n";
+ my ($oldbase, $oldpath, $oldext) = fileparseA( $dest );
+ my ($newbase, $newpath, $newext) = fileparseA( $$Pdest );
+ if ($oldext ne $newext) {
+ if ( ! exists $allowed_output_ext{$oldext} ) {
+ warn " Old extension '$oldext' not allowed.\n";
+ $$Pout_of_date = 10;
+ }
+ else {
+ warn " ===== CHANGING output type from '$newext' to '$oldext' in '$rule'\n";
+ my $switch_error = switch_output( $oldext, $newext );
+ if ($switch_error) {
+ warn " I could not accommodate the changed output extension\n",
+ " (either because the configuration does not allow it\n",
+ " or because there is a conflict with requested filetypes).\n",
+ "===> There may be subsequent warnings, which may or may not be ignorable.\n",
+ "===> If necessary, clean out generated files and try again\n";
+ }
+ }
+ }
+ if ( ($oldbase ne $newbase) || ($oldpath ne $newpath) ) {
+ # There are further issues (e.g., change of out_dir).
+ # Need rerun to correct:
+ $$Pout_of_date = 10;
+ }
+ }
+ }
+} #END rdb_read_set_rule
+
+#************************************************************
+
sub rdb_write {
# Call: rdb_write( $out_name )
# Writes to the given file name the database of file and rule data
# for all rules needed to make final output
- # !!?? Previously was:
- # OLD Writes to the given file name the database of file and rule data
- # OLD accessible from the primary rules.
# Returns 1 on success, 0 if file couldn't be opened.
local $out_name = $_[0];
local $out_handle = new FileHandle;
@@ -5587,20 +5847,10 @@ sub rdb_write {
}
if (!$out_handle) { return 0; }
- local %current_primaries = (); # Hash whose keys are primary rules
- # needed, i.e., known latex-like rules which trigger
- # circular dependencies
- local @pre_primary = (); # Array of rules
- local @post_primary = (); # Array of rules
- local @unusual_one_time = (); # Array of rules
- &rdb_classify_rules( \%possible_primaries, keys %requested_filerules );
+ &rdb_set_rule_net;
print $out_handle "# Fdb version $fdb_ver\n";
-# !!?? Rules or rules accessible from primary
-# my @rules = rdb_accessible( uniq1( keys %possible_primaries ) ) ;
- my @rules = rdb_accessible( uniq1( keys %possible_primaries, keys %requested_filerules ) ) ;
- # Separate call to sort. Otherwise rdb_accessible seems to get wrong argument.
- @rules = sort( @rules );
+ my @rules = sort &rdb_accessible;
rdb_for_some(
\@rules,
sub {
@@ -5727,6 +5977,11 @@ sub rdb_set_latex_deps {
#
# I have not tried to handle the (currently rare) cases that the
# OS is neither UNIX-like nor MSWin-like.
+ #
+ # Assumption: the list of generated files in %PHdest was already initialized earlier.
+ # In principle, I should do it here, but useful possibilities (e.g.,
+ # see pythontex-latexmk) for subroutine called to process a .tex to add items to
+ # %PHdest. So initializing here is too late.
# Rules should only be primary
if ( $$Pcmd_type ne 'primary' ) {
@@ -5739,7 +5994,7 @@ sub rdb_set_latex_deps {
#?? # We'll prune this by all files determined to be needed for source files.
#?? my %unneeded_source = %$PHsource;
- # Parse log file to find relevant filenames
+ # Parse fls and log files to find relevant filenames
# Result in the following variables:
local %dependents = (); # Maps files to status
local @bbl_files = ();
@@ -5758,7 +6013,15 @@ sub rdb_set_latex_deps {
local $pwd_latex = undef; # Cwd as reported in fls file by (pdf)latex
- # The following are also returned, but are global, to be used by caller
+ local %created_rules = (); # Maps files to rules existing or created to
+ # make them. Use to avoid misunderstood
+ # dependencies when a package creates a
+ # missing file during *latex compliation
+ # instead of just allowing to be made later
+ # by another rule.
+
+ # The following are also returned by parsing routines, but are global,
+ # to be used by caller:
# $reference_changed, $bad_reference, $bad_character, $bad_citation, $mult_defined
# Do I have my own eps-to-pdf conversion?
@@ -5770,14 +6033,13 @@ sub rdb_set_latex_deps {
# Analyze fls file first. It tells us the working directory as seen by (pdf)latex
# But we'll use the results later, so that they take priority over the findings
# from the log file.
- my $fls_name = "$aux_dir1$root_filename.fls";
local $fls_file_analyzed = 0;
if ($recorder && test_gen_file($fls_name) ) {
- $fls_file_analyzed =
- (0== parse_fls( $fls_name, \%source_fls, \%generated_fls, \%first_read_after_write, \$pwd_latex ));
- if (! $fls_file_analyzed ) {
- warn "$My_name: fls file '$fls_name' appears to have been made but it couldn't be opened.\n";
- }
+ $fls_file_analyzed =
+ (0== parse_fls( $fls_name, \%source_fls, \%generated_fls, \%first_read_after_write, \$pwd_latex ));
+ if (! $fls_file_analyzed ) {
+ warn "$My_name: fls file '$fls_name' appears to have been made but it couldn't be opened.\n";
+ }
}
&parse_log;
@@ -5822,24 +6084,24 @@ sub rdb_set_latex_deps {
# used.
foreach (keys %source_fls) {
if (! -e ) {
- # File is listed in .fls file as read, but doesn't exist now.
- # Therefore it is not a true source file, surely.
- # Sometimes this is caused by a bug (e.g., lualatex in TeXLive 2016,
- # 2017) when there is an incorrect line in .fls file. (This
- # would deserve a warning.)
+ # File is listed in .fls file as read, but doesn't exist now.
+ # Therefore it is not a true source file, surely.
+ # Sometimes this is caused by a bug (e.g., lualatex in TeXLive 2016,
+ # 2017) when there is an incorrect line in .fls file. (This
+ # would deserve a warning.)
# But sometimes (e.g., with minted package), the file could be
- # created during a run, read, and then deleted.
+ # created during a run, read, and then deleted.
next;
}
$dependents{$_} = 4;
- if ( /\.bbl$/ ) { push @bbl_files, $_; }
+ if ( /\.bbl$/ ) { push @bbl_files, $_; }
}
foreach (keys %generated_fls) {
if (! -e ) {
- # File is listed in .fls file as written, but doesn't exist now.
- # Therefore it is not a true externally visible generated file.
- # (Typically, e.g., with the minted package, it is a temporary
- # file created during a run and then deleted during the run.)
+ # File is listed in .fls file as written, but doesn't exist now.
+ # Therefore it is not a true externally visible generated file.
+ # (Typically, e.g., with the minted package, it is a temporary
+ # file created during a run and then deleted during the run.)
next;
}
rdb_add_generated( $_ );
@@ -5848,7 +6110,6 @@ sub rdb_set_latex_deps {
}
}
-
for my $conv (sort keys %conversions) {
my $conv_source = $conversions{$conv};
if ( $conv =~ /^(.*)-eps-converted-to\.pdf$/ ) {
@@ -5861,10 +6122,10 @@ sub rdb_set_latex_deps {
rdb_remove_files( $rule, $conv );
delete $dependents{$conv};
if ($epspdf_cusdep) {
- $dependents{"$base.pdf"} = ((-e "$base.pdf") ? 4 : 0 );
+ $dependents{"$base.pdf"} = ((-e "$base.pdf") ? 4 : 0 );
}
- }
- }
+ }
+ }
}
@@ -5892,27 +6153,28 @@ sub rdb_set_latex_deps {
elsif ($primary_out ne normalize_filename($$Pdest) ) {
my ($actual_base, $actual_path, $actual_ext) = fileparseA( $primary_out );
my ($intended_base, $intended_path, $intended_ext) = fileparseA( $$Pdest );
- if ( $actual_ext ne $intended_ext ) {
+ if ( $actual_ext ne $intended_ext ) {
warn "$My_name: ===For rule '$rule', the extensions differ between the\n",
" actual output file '$primary_out',\n",
" and the expected output '$$Pdest'.\n";
- if ( ! exists $allowed_output_ext{$actual_ext} ) {
- warn " Actual output file has an extension '$actual_ext' that\n",
- " is not one I know about\n";
- }
- if ( (($actual_ext eq '.pdf') && ($intended_ext eq '.dvi'))
- || (($actual_ext eq '.dvi') && ($intended_ext eq '.pdf'))
- )
- {
- warn " This could arise from use of \\pdfoutput in the source file,\n",
- " or from a configuration error\n";
- }
- else {
- warn " This indicates a probable configuration error\n";
- }
- warn " A future version of $my_name should be able to make dynamically\n",
- " adjustments to deal with this problem\n";
- }
+ if ( ! exists $allowed_output_ext{$actual_ext} ) {
+ warn " Actual output file has an extension '$actual_ext' that\n",
+ " is not one I know about. I cannot handle this\n";
+ }
+ else {
+ my $switch_error = switch_output( $actual_ext, $intended_ext );
+ if ( $switch_error ) {
+ warn " I could not accommodate the changed output extension\n",
+ " (either because the configuration does not allow it\n",
+ " or because there is a conflict with requested filetypes).\n";
+ $failure = 1;
+ $failure_msg = 'Could not handle change of output extension';
+ }
+ else {
+ warn " Rule structure will be changed suitably.\n";
+ }
+ }
+ }
}
IDX_FILE:
@@ -5939,6 +6201,7 @@ sub rdb_set_latex_deps {
# Leave failure issue to other rules.
$failure = 0;
}
+ $created_rules{$ind_file} = $from_rule;
}
local %processed_aux_files = ();
@@ -5956,6 +6219,11 @@ sub rdb_set_latex_deps {
}
my $from_rule = "$bib_program $bbl_base";
print "======= Dealing with '$from_rule'\n" if ($diagnostics);
+ # Don't change to use activation and deactivation here, rather than
+ # creation and removal of rules. This is because rules are to be
+ # created on the fly here with details corresponding to current. So
+ # activating a previously inactive rule, which is out-of-date, may
+ # cause trouble.
if ($bib_program eq 'biber') {
check_biber_log( $bbl_base, \@biber_source );
# Remove OPPOSITE kind of bbl generation:
@@ -5971,17 +6239,18 @@ sub rdb_set_latex_deps {
if ( $bib_program eq 'biber' ) {
rdb_create_rule( $from_rule, 'external', $biber, '', 1,
"$bbl_base.bcf", $bbl_file, $bbl_base, 1, 0, 0, 1, [ "$bbl_base.blg" ] );
- }
- else {
- rdb_create_rule( $from_rule, 'external', $bibtex, 'run_bibtex', 1,
+ }
+ else {
+ rdb_create_rule( $from_rule, 'external', $bibtex, 'run_bibtex', 1,
"$bbl_base.aux", $bbl_file, $bbl_base, 1, 0, 0, 1, [ "$bbl_base.blg" ] );
- }
+ }
}
+ $created_rules{$bbl_file} = $from_rule;
local %old_sources = ();
rdb_one_rule( $from_rule, sub { %old_sources = %$PHsource; } );
- my @new_sources = ( @new_bib_files, @new_aux_files, @new_bst_files );
+ my @new_sources = ( @new_bib_files, @new_aux_files, @new_bst_files );
if ( $bib_program eq 'biber' ) {
- push @new_sources, @biber_source;
+ push @new_sources, @biber_source;
}
foreach my $source ( @new_sources ) {
print " ===Source file '$source' for '$from_rule'\n"
@@ -6022,19 +6291,19 @@ NEW_SOURCE:
foreach my $new_source (keys %dependents) {
print " ===Source file for rule '$rule': '$new_source'\n"
if ($diagnostics);
- if ( exists $first_read_after_write{$new_source} ) {
- if ( dep_at_start($new_source) ) {
- #warn "--- READ ONLY AFTER WRITE OF '$new_source'\n";
- $dependents{$new_source} = 7;
- }
- else {
- #warn "--- READ ONLY AFTER CREATE OF '$new_source'\n";
- $dependents{$new_source} = 6;
- }
+ if ( exists $first_read_after_write{$new_source} ) {
+ if ( dep_at_start($new_source) ) {
+ #warn "--- READ ONLY AFTER WRITE OF '$new_source'\n";
+ $dependents{$new_source} = 7;
+ }
+ else {
+ #warn "--- READ ONLY AFTER CREATE OF '$new_source'\n";
+ $dependents{$new_source} = 6;
+ }
}
if ( ($dependents{$new_source} == 5)
|| ($dependents{$new_source} == 6)
- ) {
+ ) {
# (a) File was detected in "No file..." line in log file.
# Typically file was searched for early in run of
# latex/pdflatex, was not found, and then was written
@@ -6069,11 +6338,20 @@ NEW_SOURCE:
}
if ( ($dependents{$new_source} == 6)
|| ($dependents{$new_source} == 7)
- ) {
+ ) {
rdb_add_generated($new_source);
}
}
+ # Some packages (e.g., bibtopic) generate a dummy error-message-providing
+ # bbl file when a bbl file does not exist. Then the fls and log files
+ # show the bbl file as created by the primary run and hence as a
+ # generated file. Since we now have a rule to create a real bbl file,
+ # the information in the fls and log files no longer represents a
+ # correct dependency, so the bbl file is to be removed from the
+ # generated files.
+ foreach (keys %created_rules) { rdb_remove_generated( $_ ); }
+
my @more_sources = &rdb_set_dependents( $rule );
my $num_new = $#more_sources + 1;
foreach (@more_sources) {
@@ -6115,6 +6393,56 @@ NEW_SOURCE:
#************************************************************
+sub switch_output {
+ # Assume rule context for primary rule
+ # Return 0 on success, non-zero error code on failure
+
+ my ( $actual_ext, $intended_ext ) = @_;
+ if ( $actual_ext eq $intended_ext) { return 0; }
+ if ( ! $can_switch ) { return 1; }
+
+ if ( $intended_ext eq '.dvi' ) {
+ rdb_deactivate_derequest( 'dvipdf', 'pspdf' );
+ }
+ elsif ( $intended_ext eq '.xdv' ) {
+ rdb_deactivate_derequest( 'xdvipdfmx' );
+ }
+ else { }
+
+ if ( $actual_ext eq '.dvi' ) {
+ rdb_activate_request( 'dvipdf' );
+ $input_extensions{$rule} = $standard_input_extensions{latex};
+ }
+ elsif ( $actual_ext eq '.xdv' ) {
+ rdb_activate_request( 'xdvipdfmx' );
+ $input_extensions{$rule} = $standard_input_extensions{xelatex};
+ }
+ else {
+ $input_extensions{$rule} = $standard_input_extensions{pdflatex};
+ }
+
+ my $old_dest = $$Pdest;
+ my $new_dest = $$Pdest;
+ $new_dest =~ s/$intended_ext$/$actual_ext/;
+ # Compensate for MiKTeX's behavior: dvi and pdf are put in out_dir, but xdv is put in aux_dir:
+ if ( ($actual_ext eq '.xdv') && ($out_dir ne $aux_dir) ){ $new_dest =~ s/^$out_dir1/$aux_dir1/; }
+ if ( ($intended_ext eq '.xdv') && ($out_dir ne $aux_dir) ){ $new_dest =~ s/^$aux_dir1/$out_dir1/; }
+
+ rdb_change_dest( $new_dest );
+
+ # Some fixes to avoid spurious error conditions:
+ $switched_primary_output = 1;
+ if (-e $$Pdest) {
+ $missing_dvi_pdf = '';
+ if ($$Plast_result == 1 ) { $$Plast_result = 0; }
+ }
+ else { $missing_dvi_pdf = $$Pdest; }
+
+ return 0;
+} #END switch_output
+
+#************************************************************
+
sub test_gen_file {
# Usage: test_gen_file( filename )
# Tests whether the file was generated during a run of (pdf)latex.
@@ -6223,7 +6551,7 @@ MISSING_FILE:
my $found = 0;
foreach my $file (keys %new_includes) {
-# if ( $file =~ /\"/ ) {next; }
+# if ( $file =~ /\"/ ) {next; }
my $stripped = $file;
$stripped =~ s{^\./}{};
if ( exists $PHsource{$file} ) {
@@ -6273,13 +6601,13 @@ sub rdb_find_source_file {
return $_[0];
}
if ( exists $ENV{TEXINPUTS} ) {
- foreach my $searchpath (split $search_path_separator, $ENV{TEXINPUTS}) {
- my $file = File::Spec->catfile($searchpath,$_[0]);
- my $test = "$file.$_[1]";
- if ( -e $test ) {
- return $file;
- }
- }
+ foreach my $searchpath (split $search_path_separator, $ENV{TEXINPUTS}) {
+ my $file = File::Spec->catfile($searchpath,$_[0]);
+ my $test = "$file.$_[1]";
+ if ( -e $test ) {
+ return $file;
+ }
+ }
}
return "$_[0]";
}
@@ -6313,11 +6641,11 @@ DEP:
}
if ( -e $source ) {
$$Pfrom_rule = "cusdep $fromext $toext $base_name";
- my $new_new_dest = "$base_name.$toext";
- if ($new_new_dest ne $new_dest) {
- rdb_ensure_file( $rule, $new_new_dest );
- $new_dest = $new_new_dest;
- }
+ my $new_new_dest = "$base_name.$toext";
+ if ($new_new_dest ne $new_dest) {
+ rdb_ensure_file( $rule, $new_new_dest );
+ $new_dest = $new_new_dest;
+ }
local @PAnew_cmd = ( 'do_cusdep', $func_name );
if ( !-e $new_dest ) {
push @new_sources, $new_dest;
@@ -6421,7 +6749,7 @@ sub rdb_list {
# List rules and their source files
print "===Rules:\n";
local $count_rules = 0;
- my @accessible_all = rdb_accessible( keys %requested_filerules );
+ my @accessible_all = &rdb_accessible;
rdb_for_some(
\@accessible_all,
sub{ $count_rules++;
@@ -6431,7 +6759,7 @@ sub rdb_list {
sub{ print " and generates:\n";
foreach (keys %$PHdest) { print " '$_'\n"; }
# print " default_extra_generated:\n";
-# foreach (@$PA_extra_generated) { print " '$_'\n"; }
+# foreach (@$PA_extra_gen) { print " '$_'\n"; }
},
);
if ($count_rules <= 0) {
@@ -6452,13 +6780,10 @@ sub deps_list {
if ($postscript_mode) {push @dest_exts, '.ps';}
my %source = ( $texfile_name => 1 );
my @generated = ();
- my @accessible_all = rdb_accessible( keys %requested_filerules );
+ my @accessible_all = &rdb_accessible;
rdb_for_some(
\@accessible_all,
- sub{
-# foreach (keys %$PHdest) { print "----- $_\n"; }
- push @generated, keys %$PHdest;
- },
+ sub{ push @generated, keys %$PHdest; },
sub{ $source{$file} = 1; }
);
foreach (keys %generated_exts_all) {
@@ -6507,7 +6832,7 @@ sub rdb_show {
# Side effect: Exercises access routines!
print "===Rules:\n";
local $count_rules = 0;
- rdb_for_all(
+ rdb_for_actives(
sub{ $count_rules++;
my @int_cmd = @$PAint_cmd;
foreach (@int_cmd) {
@@ -6524,12 +6849,31 @@ sub rdb_show {
#************************************************************
+sub rdb_target_array {
+ # Returns array of all rules implicated by %target_rules and %target_files
+ my %rules = &rdb_target_hash;
+ return keys %rules;
+} # End rdb_target_array
+
+#************************************************************
+
+sub rdb_target_hash {
+ # Returns hash mapping to 1 all rules implicated by %target_rules and %target_files
+ my %rules = %target_rules;
+ foreach (keys %target_files) {
+ if (exists $from_rules{$_}) { $rules{$from_rules{$_}} = 1; }
+ }
+ return %rules;
+} # End rdb_target_hash
+
+#************************************************************
+
sub rdb_accessible {
- # Call: rdb_accessible( rule, ...)
- # Returns array of rules accessible from the given rules
- local @accessible = ();
- rdb_recurse( [@_], sub{ push @accessible, $rule; } );
- return @accessible;
+ # Call: &rdb_accessible
+ # Returns array of rules accessible from target rules and rules to make target files
+ local %accessible_rules = &rdb_target_hash;
+ rdb_recurse( [keys %accessible_rules], sub{ $accessible_rules{$rule} = 1; } );
+ return keys %accessible_rules;
} #END rdb_accessible
#************************************************************
@@ -6537,7 +6881,7 @@ sub rdb_accessible {
#************************************************************
sub rdb_make {
- # Call: rdb_make( target, ... )
+ # Call: &rdb_make
# Makes the targets and prerequisites.
# Leaves one-time rules to last.
# Does appropriate repeated makes to resolve dependency loops
@@ -6675,23 +7019,8 @@ sub rdb_make {
# source files.
#
- local @requested_targets = @_;
- local %current_primaries = (); # Hash whose keys are primary rules
- # needed, i.e., known latex-like rules which trigger
- # circular dependencies
- local @pre_primary = (); # Array of rules
- local @post_primary = (); # Array of rules
- local @unusual_one_time = (); # Array of rules
-
-
- # For diagnostics on changed files, etc:
- local @changed = ();
- local @disappeared = ();
- local @no_dest = (); # Non-existent destination files
- local @rules_never_run = ();
- local @rules_to_apply = ();
- &rdb_classify_rules( \%possible_primaries, @requested_targets );
+ &rdb_set_rule_net;
local %pass = ();
local $failure = 0; # General accumulated error flag
@@ -6699,87 +7028,92 @@ sub rdb_make {
local $runs = 0;
local $too_many_passes = 0;
local %rules_applied = ();
+ local $switched_primary_output = 0;
my $retry_msg = 0; # Did I earlier say I was going to attempt
# another pass after a failure?
- PRIMARY:
- foreach my $primary (keys %current_primaries ) {
- foreach my $rule (keys %rule_db) {
- $pass{$rule} = 0;
- }
- PASS:
- while (1==1) {
- # Exit condition at end of body of loop.
- $runs = 0;
- my $previous_failure = $failure;
- $failure = 0;
- local $newrule_nofile = 0; # Flags whether rule created for
+ foreach my $rule (keys %rule_db) {
+ $pass{$rule} = 0;
+ }
+ PASS:
+ while (1==1) {
+ # Exit condition at end of body of loop.
+ $runs = 0;
+ $switched_primary_output = 0;
+ my $previous_failure = $failure;
+ $failure = 0;
+ local $newrule_nofile = 0; # Flags whether rule created for
# making currently non-existent file, which
# could become a needed source file for a run
# and therefore undo an error condition
- if ($diagnostics) {
- print "Make: doing pre_primary and primary...\n";
- }
- # Do the primary run if it is needed. On return $runs == 0
- # signals that nothing was run (and hence no output
- # files changed), either because no input files
- # changed and no run was needed, or because the
- # number of passes through the rule exceeded the
- # limit. In the second case $too_many_runs is set.
- rdb_for_some( [@pre_primary, $primary], \&rdb_make1 );
- if ( ($runs > 0) && ! $too_many_passes ) {
- $retry_msg = 0;
- if ( $force_mode || (! $failure) ) {
- next PASS;
- }
- # Get here on failure, without being in force_mode
- if ( $newrule_nofile ) {
- $retry_msg = 1;
- print "$My_name: Error on run, but found possibility to ",
- "make new source files\n";
- next PASS;
- }
- else { last PASS; }
- }
- if ($runs == 0) {
- # $failure not set on this pass, so use value from previous pass:
- $failure = $previous_failure;
- if ($retry_msg) {
- print "But in fact no new files made\n";
- }
- if ($failure && !$force_mode ) { last PASS; }
- }
- if ( $missing_dvi_pdf ) {
- # No output from primary, after completing circular dependence
- warn "Failure to make '$missing_dvi_pdf'\n";
- $failure = 1;
- last PASS;
- }
- if ($diagnostics) {
- print "Make: doing post_primary...\n";
+ foreach my $rule (keys %rule_db) {
+ # Update %pass in case new rules have been created
+ if (! exists $pass{$rule} ) { $pass{$rule} = 0; }
+ }
+ if ($diagnostics) {
+ print "Make: doing pre_primary and primary...\n";
+ }
+ # Do the primary run if it is needed. On return $runs == 0
+ # signals that nothing was run (and hence no output
+ # files changed), either because no input files
+ # changed and no run was needed, or because the
+ # number of passes through the rule exceeded the
+ # limit. In the second case $too_many_runs is set.
+ rdb_for_some( [@pre_primary, $current_primary], \&rdb_make1 );
+ if ($switched_primary_output) {
+ print "=========SWITCH OF OUTPUT WAS DONE.\n";
+ next PASS;
+ }
+ if ( ($runs > 0) && ! $too_many_passes ) {
+ $retry_msg = 0;
+ if ( $force_mode || (! $failure) || $switched_primary_output ) {
+ next PASS;
}
- rdb_for_some( [@post_primary], \&rdb_make1 );
- if ( ($runs == 0) || $too_many_passes ) {
- # If $too_many_passes is set, it should also be that
- # $runs == 0; but for safety, I also checked
- # $too_many_passes.
- last PASS;
+ # Get here on failure, without being in force_mode
+ if ( $newrule_nofile ) {
+ $retry_msg = 1;
+ print "$My_name: Error on run, but found possibility to ",
+ "make new source files\n";
+ next PASS;
}
+ else { last PASS; }
}
- continue {
- # Re-evaluate rule classification and accessibility,
- # but do not change primaries.
- # Problem is that %current_primaries gets altered
- my %old_curr_prim = %current_primaries;
- &rdb_classify_rules( \%possible_primaries, @requested_targets );
- %current_primaries = %old_curr_prim;
- &rdb_make_links;
+ if ($runs == 0) {
+ # $failure not set on this pass, so use value from previous pass:
+ $failure = $previous_failure;
+ if ($retry_msg) {
+ print "But in fact no new files made\n";
+ }
+ if ($failure && !$force_mode ) { last PASS; }
+ }
+ if ( $missing_dvi_pdf ) {
+ # No output from primary, after completing circular dependence
+ warn "Failure to make '$missing_dvi_pdf'\n";
+ $failure = 1;
+ last PASS;
+ }
+ if ($diagnostics) {
+ print "Make: doing post_primary...\n";
}
- }
+ rdb_for_some( [@post_primary], \&rdb_make1 );
+ if ( ($runs == 0) || $too_many_passes ) {
+ # If $too_many_passes is set, it should also be that
+ # $runs == 0; but for safety, I also checked
+ # $too_many_passes.
+ last PASS;
+ }
+ }
+ continue {
+ # Re-evaluate rule classification and accessibility,
+ # but do not change primaries.
+ # Problem is that %current_primaries gets altered
+ &rdb_set_rule_net;
+ } #End PASS
+
rdb_for_some( [@unusual_one_time], \&rdb_make1 );
rdb_write( $fdb_name );
if ($#primary_warning_summary > -1) {
- # N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
+ # N.B. $mult_defined, $bad_reference, $bad_character, $bad_citation also available here.
show_array( "$My_name: Summary of warnings from last run of (pdf)latex:",
@primary_warning_summary );
}
@@ -6804,7 +7138,7 @@ sub rdb_make {
sub rdb_show_rule_errors {
local @errors = ();
local @warnings = ();
- rdb_for_all(
+ rdb_for_actives(
sub{
if ($$Plast_message ne '') {
if ($$Plast_result == 200) {
@@ -6852,7 +7186,6 @@ sub rdb_make1 {
if ($diagnostics) { print " Make1 $rule\n"; }
if ($failure & ! $force_mode) {return;}
if ( ! defined $pass{$rule} ) {$pass{$rule} = 0; }
- &rdb_clear_change_record;
# Special fix up for bibtex:
my $bibtex_not_run = -1; # Flags status as to whether this is a
@@ -6904,8 +7237,6 @@ sub rdb_make1 {
# Any error will arise at the (pdf)latex level due to a
# missing source file at that level.
if ( $$Psource && (! -e $$Psource)
-# OLD && ( ( $$Pcmd_type eq 'cusdep') )
-# NEW
&& ( ( $$Pcmd_type ne 'primary') )
) {
# Main source file doesn't exist, and rule is NOT primary.
@@ -6926,12 +7257,10 @@ sub rdb_make1 {
}
}
+ &rdb_clear_change_record;
&rdb_flag_changes_here(0);
if (!$$Pout_of_date) {
-#?? if ( ($$Pcmd_type eq 'primary') && (! $silent) ) {
-# print "Rule '$rule' up to date\n";
-# }
return;
}
if ($diagnostics) { print " remake\n"; }
@@ -7039,24 +7368,13 @@ sub rdb_make1 {
#************************************************************
-#??sub rdb_submake {
-#?? # Call: rdb_submake
-#?? # Makes all the source files for a given rule.
-#?? # Assumes contexts for recursion, for make, and rule.
-#?? %visited = %visited_at_rule_start;
-#?? local $failure = 0; # Error flag
-#?? my @v = keys %visited;
-#?? rdb_do_files( sub{ rdb_recurse_rule( $$Pfrom_rule, 0,0,0, \&rdb_make1 ) } );
-#?? return $failure;
-#??} #END rdb_submake
-
-#************************************************************
-
sub rdb_classify_rules {
- # Usage: rdb_classify_rules( \%allowed_primaries, requested targets )
+ # Usage: &rdb_classify_rules
# Assume the following variables are available (global or local):
# Input:
- # @requested_targets # Set to target rules
+ # %target_rules # Set to target rules
+ # %target_files # Set to target files
+ # %possible_primaries
# Output:
# %current_primaries # Keys are actual primaries
@@ -7065,8 +7383,7 @@ sub rdb_classify_rules {
# @unusual_one_time # Array of rules
# @pre_primary and @post_primary are in natural order of application.
- local $P_allowed_primaries = shift;
- local @requested_targets = @_;
+ local @requested_targets = &rdb_target_array;
local $state = 0; # Post-primary
local @classify_stack = ();
@@ -7081,6 +7398,16 @@ sub rdb_classify_rules {
@pre_primary = reverse @pre_primary;
@post_primary = reverse @post_primary;
+ my @current_primaries = keys %current_primaries;
+ if ($#current_primaries < 0) {
+ die "$My_name: No active primary rules found. I have to stop.\n";
+ }
+ elsif ($#current_primaries > 0) {
+ die "$My_name: More than one active primary rule found. I have to stop.\n",
+ " Primary rules: @current_primaries\n";
+ }
+ $current_primary = $current_primaries[0];
+
if ($diagnostics) {
print "Rule classification: \n";
if ($#requested_targets < 0) {
@@ -7142,7 +7469,7 @@ sub rdb_classify1 {
push @unusual_one_time, $rule;
}
elsif ($state == 0) {
- if ( exists ${$P_allowed_primaries}{$rule} ) {
+ if ( exists $possible_primaries{$rule} ) {
$state = 1; # In primary rule
$current_primaries{ $rule } = 1;
}
@@ -7213,7 +7540,7 @@ sub rdb_run1 {
my @biber_source = ( );
my $retcode = check_biber_log( $$Pbase, \@biber_source );
foreach my $source ( @biber_source ) {
-# if ( $source =~ /\"/ ) {next; }
+# if ( $source =~ /\"/ ) {next; }
print " ===Source file '$source' for '$rule'\n"
if ($diagnostics);
rdb_ensure_file( $rule, $source );
@@ -7258,30 +7585,30 @@ sub rdb_run1 {
}
elsif ($retcode == 11) {
push @warnings, "Biber: malformed bcf file for '$$Pbase'. IGNORE";
- if (!$silent) {
+ if (!$silent) {
warn "$My_name: biber found malformed bcf file for '$$Pbase'.\n",
- " I'll ignore error, and delete any bbl file.\n";
- }
- # Malformed bcf file is a downstream consequence, normally,
+ " I'll ignore error, and delete any bbl file.\n";
+ }
+ # Malformed bcf file is a downstream consequence, normally,
# of an error in (pdf)latex run. So this is not an error
- # condition in biber itself.
- # Current version of biber deletes bbl file.
- # Older versions (pre-2016) made an incorrect bbl file, which
+ # condition in biber itself.
+ # Current version of biber deletes bbl file.
+ # Older versions (pre-2016) made an incorrect bbl file, which
# tended to cause latex errors, and give a self-perpetuating error.
- # To be safe, ensure the bbl file doesn't exist.
- unlink $$Pdest;
- # The missing bbl file is now not an error:
+ # To be safe, ensure the bbl file doesn't exist.
+ unlink $$Pdest;
+ # The missing bbl file is now not an error:
$return = -2;
# ??????? BCF
# Following is intended to work, but creates infinite loop
# in malformed bcf file situation under -pvc.
-# since on each check for change in ANY file, pvc finds changed file
+# since on each check for change in ANY file, pvc finds changed file
# Need to restrict pvc reruns to case of changed USER files
-# # To give good properties for (pdf)latex rule, it is best
-# # to have a valid bbl file that exists:
-# create_empty_file( $$Pdest );
+# # To give good properties for (pdf)latex rule, it is best
+# # to have a valid bbl file that exists:
+# create_empty_file( $$Pdest );
# $return = 0;
-
+
}
}
if ( $rule =~ /^bibtex/ ) {
@@ -7329,12 +7656,12 @@ sub rdb_run1 {
$$Plast_result = 2;
if ($$Plast_message eq '') {
$$Plast_message = "Command for '$rule' gave return code $return";
- if ($rule =~ /^(pdf|lua|xe|)latex/) {
- $$Plast_message .= "\n Refer to '$log_name' for details";
- }
+ if ($rule =~ /^(pdf|lua|xe|)latex/) {
+ $$Plast_message .= "\n Refer to '$log_name' for details";
+ }
elsif ($rule =~ /^makeindex/) {
- $$Plast_message .= "\n Refer to '${aux_dir1}${root_filename}.ilg' for details";
- }
+ $$Plast_message .= "\n Refer to '${aux_dir1}${root_filename}.ilg' for details";
+ }
}
}
elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) {
@@ -7409,6 +7736,7 @@ sub Run_subst {
my $q = $quote_filenames ? '"' : '';
my %subst = (
+ '%A' => $q.$tex_basename.$q,
'%B' => $q.$base.$q,
'%D' => $q.$dest.$q,
'%O' => $options,
@@ -7419,14 +7747,14 @@ sub Run_subst {
'%Y' => $q.$aux_dir1.$q,
'%Z' => $q.$out_dir1.$q,
'%%' => '%' # To allow literal %B, %R, etc, by %%B.
- );
+ );
if ($pre_tex_code) {
- $subst{'%U'} = $q.$pre_tex_code.$q;
- $subst{'%P'} = "$q$pre_tex_code\\input{$source}$q";
+ $subst{'%U'} = $q.$pre_tex_code.$q;
+ $subst{'%P'} = "$q$pre_tex_code\\input{$source}$q";
}
else {
- $subst{'%U'} = '';
- $subst{'%P'} = $subst{'%S'};
+ $subst{'%U'} = '';
+ $subst{'%P'} = $subst{'%S'};
}
if ( ($^O eq "MSWin32" ) && $MSWin_back_slash ) {
foreach ( '%R', '%B', '%T', '%S', '%D', '%Y', '%Z' ) {
@@ -7461,16 +7789,20 @@ sub rdb_primary_run {
my $return = 0;
if ( ! $filetime_offset_measured ) {
- $filetime_offset = get_filetime_offset( $aux_dir1."tmp" );
- if ( (abs($filetime_offset) > $filetime_offset_report_threshold)
+ $filetime_offset = get_filetime_offset( $aux_dir1."tmp" );
+ if ( (abs($filetime_offset) > $filetime_offset_report_threshold)
&& ($diagnostics || ! $silent) )
{
- warn "$My_name: I am working around an offset relative to my system time by\n",
+ warn "$My_name: I am working around an offset relative to my system time by\n",
" $filetime_offset secs for file times in directory '$aux_dir1'.\n";
- }
- $filetime_offset_measured = 1;
+ }
+ $filetime_offset_measured = 1;
}
+ # Need to reset the list of generated files. If we don't it can contain
+ # out-of-date items from previous run. (Think bibtopic, which writes
+ # bbl files!)
+ &rdb_initialize_generated;
my $return_latex = &rdb_run1;
# Need to worry about changed directory, changed output extension
@@ -7486,7 +7818,7 @@ sub rdb_primary_run {
# of name latex.fls or pdflatex.fls instead of $root_filename.fls.
# Also that setting of -output-directory -aux-directory is not
# respected by (pdf)latex, at least in some versions.
- my $std_fls_file = "$aux_dir1$root_filename.fls";
+ my $std_fls_file = $fls_name;
my @other_fls_names = ( );
if ( $rule =~ /^pdflatex/ ) {
push @other_fls_names, "pdflatex.fls";
@@ -7495,17 +7827,24 @@ sub rdb_primary_run {
push @other_fls_names, "latex.fls";
}
if ( $aux_dir1 ne '' ) {
- push @other_fls_names, "$root_filename.fls";
+ push @other_fls_names, "$root_filename.fls";
+ # MiKTeX uses out_dir for .fls. However, it seems logical to
+ # me for .fls to be in aux_dir. So I'll allow for this
+ # Possibility, although I don't know if it has been used.
+ push @other_fls_names, "$aux_dir1$root_filename.fls";
}
# Find the first non-standard fls file and copy it to the standard
# place. But only do this if the file time is compatible with being
- # generated in the current run, as tested by the use of
+ # generated in the current run, and if the standard fls file hasn't
+ # been made in the current run, as tested by the use of
# test_gen_file; that avoids problems with fls files leftover from
# earlier runs with other versions of latex.
- foreach my $cand (@other_fls_names) {
- if ( test_gen_file( $cand ) ) {
- copy $cand, $std_fls_file;
- last;
+ if ( ! test_gen_file( $std_fls_file ) ) {
+ foreach my $cand (@other_fls_names) {
+ if ( test_gen_file( $cand ) ) {
+ copy $cand, $std_fls_file;
+ last;
+ }
}
}
if ( ! test_gen_file( $std_fls_file ) ) {
@@ -7524,17 +7863,6 @@ sub rdb_primary_run {
# up-to-date:
rdb_do_files( sub { if ($$Pcorrect_after_primary) {&rdb_update1;} } );
-#?? # There may be new source files, and the run may have caused
-#?? # circular-dependency files to be changed. And the regular
-#?? # source files may have been updated during a lengthy run of
-#?? # latex. So redo the makes for sources of the current rule:
-#?? my $submake_return = &rdb_submake;
-#?? &rdb_clear_change_record;
-#?? &rdb_flag_changes_here(0);
-#?? if ($$Pout_of_date && !$silent) {
-#?? &rdb_diagnose_changes( "Rule '$rule': " );
-#?? }
-
$updated = 1; # Flag that some dependent file has been remade
#?? # Fix the state of the files as of now: this will solve the
@@ -7569,8 +7897,8 @@ sub rdb_primary_run {
}
if ($bad_character) {
push @primary_warning_summary,
- "=====Latex reported missing or unavailable character(s).\n".
- "=====See log file for details.";
+ "=====Latex reported missing or unavailable character(s).\n".
+ "=====See log file for details.";
}
if ($bad_citation) {
push @primary_warning_summary,
@@ -7587,6 +7915,7 @@ sub rdb_primary_run {
sub rdb_clear_change_record {
# Initialize diagnostics for reasons for running rule.
@changed = ();
+ @changed_user = ();
@disappeared = ();
@no_dest = (); # We are not now using this
@rules_never_run = ();
@@ -7603,7 +7932,6 @@ sub rdb_flag_changes_here {
# Usage: rdb_flag_changes_here( ignore_run_time )
# Argument: if true then fdb_get shouldn't do runtime test
# for recalculation of md5
-
local $ignore_run_time = $_[0];
if ( ! defined $ignore_run_time ) { $ignore_run_time = 0; }
@@ -7632,6 +7960,7 @@ sub rdb_file_change1 {
}
my ($new_time, $new_size, $new_md5) = fdb_get($file, $check_time_argument );
my $ext_no_period = ext_no_period( $file );
+ my $generated = exists $from_rules{$file};
if ( ($new_size < 0) && ($$Psize >= 0) ) {
# print "Disappeared '$file' in '$rule'\n";
push @disappeared, $file;
@@ -7661,10 +7990,10 @@ sub rdb_file_change1 {
&& ($new_size != $$Psize)
)
) {
-#print "========= CHANGED: '$file' from '$$Pfrom_rule'\n";
push @changed, $file;
$$Pout_of_date = 1;
- if ( ! exists $generated_exts_all{$ext_no_period} ) {
+ if ( ! $generated ) {
+ push @changed_user, $file;
$$Pout_of_date_user = 1;
}
}
@@ -7672,7 +8001,7 @@ sub rdb_file_change1 {
$$Ptime = $new_time;
}
if ( ( ($$Ptest_kind == 2) || ($$Ptest_kind == 3) )
- && (! exists $generated_exts_all{$ext_no_period} )
+ && (! $generated)
&& ( $new_time > $dest_mtime )
) {
push @changed, $file;
@@ -7682,11 +8011,15 @@ sub rdb_file_change1 {
#************************************************************
-sub rdb_new_changes {
+sub rdb_user_changes {
+ # Argument(s): a set of top level rules.
+ # Aim: Find any changed user files for those rules and all ancestors.
+ # Assumption: List of from_rules for files is up-to-date.
&rdb_clear_change_record;
rdb_recurse( [@_], sub{ &rdb_flag_changes_here(1); } );
- return ($#changed >= 0) || ($#no_dest >= 0) || ($#rules_to_apply >= 0);
-} #END rdb_new_changes
+ if ($#changed_user >=0) { show_array( 'User changed files', @changed_user ); }
+ return ($#changed_user >= 0);
+} #END rdb_user_changes
#************************************************************
@@ -7837,20 +8170,23 @@ sub rdb_recurse {
local %visited = ();
local $depth = 0;
- foreach $rule ( @heads ) { rdb_recurse_rule( $rule, @_ ); }
+ foreach $rule ( @heads ) {
+ if ( rdb_is_active($rule) ) { rdb_recurse_rule( $rule, @_ ); }
+ }
} #END rdb_recurse
#************************************************************
-sub rdb_for_all {
- # Call: rdb_for_all( \&rule_act1, \&file_act, \&rule_act2 )
+sub rdb_for_actives {
+ # Call: rdb_for_actives( \&rule_act1, \&file_act, \&rule_act2 )
# Loops through all rules and their source files, using the
# specified set of actions, which are pointers to subroutines.
# Sorts rules alphabetically.
# See rdb_for_some for details.
- rdb_for_some( [ sort keys %rule_db ], @_);
-} #END rdb_for_all
+# rdb_for_some( [ sort keys %rule_db ], @_);
+ rdb_for_some( [ sort &rdb_actives ], @_);
+} #END rdb_for_actives
#************************************************************
@@ -7911,6 +8247,7 @@ sub rdb_recurse_rule {
# We are overriding actions:
my ($rule, $rule_act1, $new_file_act1, $new_file_act2, $rule_act2)
= @_;
+ if (! rdb_is_active($rule)) { return; }
# and must propagate the file actions:
local $file_act1 = $new_file_act1;
local $file_act2 = $new_file_act2;
@@ -7975,7 +8312,7 @@ sub rdb_one_rule {
$Psource, $Pdest, $Pbase,
$Pout_of_date, $Pout_of_date_user, $Prun_time, $Pcheck_time,
$Pchanged,
- $Plast_result, $Plast_message, $PA_extra_generated )
+ $Plast_result, $Plast_message, $PA_extra_gen )
= Parray( $PArule_data );
&$rule_act1 if $rule_act1;
@@ -7986,6 +8323,58 @@ sub rdb_one_rule {
#************************************************************
+sub rdb_activate {
+ # Usage rdb_activate( rule_names )
+ # Turns on active flag for the rules
+ foreach ( @_ ) {
+ if ( rdb_rule_exists($_) ) { $actives{$_} = 1; }
+ }
+}
+
+#--------------------------------------------------
+
+sub rdb_deactivate {
+ # Usage rdb_deactivate( rule_names )
+ # Turns off active flag for the rules
+ foreach ( @_ ) { delete $actives{$_}; }
+}
+
+#--------------------------------------------------
+
+sub rdb_activate_request {
+ # Usage rdb_activate_request( rule_names )
+ # Turns on active flag for the rules.
+ # Adds rules to target_rules list
+ foreach ( @_ ) {
+ if ( rdb_rule_exists($_) ) { $actives{$_} = 1; $target_rules{$_} = 1; }
+ }
+}
+
+#--------------------------------------------------
+
+sub rdb_deactivate_derequest {
+ # Usage rdb_deactivate_derequest( rule_names )
+ # Turns off active flag for the rules
+ # Removes rules from target_rules list
+ foreach ( @_ ) { delete $actives{$_}; delete $target_rules{$_}; }
+}
+
+#--------------------------------------------------
+sub rdb_is_active {
+ # Usage rdb_is_active( rule_name )
+ if ( (exists $actives{$_[0]}) && rdb_rule_exists($_[0]) ) { return 1; }
+ else { return 0; }
+}
+
+#--------------------------------------------------
+
+sub rdb_actives {
+ # Returns array of active rules
+ return keys %actives;
+}
+
+#************************************************************
+
sub rdb_one_file {
# Call: rdb_one_file($file, $file_act)
# Sets context for file and carries out the action.
@@ -8015,6 +8404,7 @@ sub rdb_remove_rule {
# rdb_remove_rule( rule, ... )
foreach my $key (@_) {
delete $rule_db{$key};
+ delete $actives{$key};
}
}
@@ -8028,12 +8418,14 @@ sub rdb_create_rule {
# int_cmd is either a string naming a perl subroutine or it is a
# reference to an array containing the subroutine name and its
# arguments.
- # Makes rule. Error if it already exists.
- # Omitted arguments: replaced by 0 or '' as needed.
+ # Makes rule. Update rule if it already exists.
+ # Omitted arguments: replaced by 0 or '' as needed.
+ # Rule is made active
# ==== Sets rule data ====
my ( $rule, $cmd_type, $ext_cmd, $PAint_cmd, $test_kind,
$source, $dest, $base,
$needs_making, $run_time, $check_time, $set_file_not_exists, $extra_gen ) = @_;
+ my $active = 1;
my $changed = 0;
# Set defaults, and normalize parameters:
@@ -8042,10 +8434,10 @@ sub rdb_create_rule {
if (! defined $_) { $_ = ''; }
}
if ( ($source =~ /\"/) || ($dest =~ /\"/) || ($base =~ /\"/) ) {
- die "$My_name: Error. In rdb_create_rule there is a double quote in one of\n",
- " source, destination or base parameters:\n",
- " '$source', '$dest', '$base'\n",
- " I cannot handle this.\n";
+ die "$My_name: Error. In rdb_create_rule there is a double quote in one of\n",
+ " source, destination or base parameters:\n",
+ " '$source', '$dest', '$base'\n",
+ " I cannot handle this.\n";
}
foreach ( $needs_making, $run_time, $check_time, $test_kind ) {
if (! defined $_) { $_ = 0; }
@@ -8078,6 +8470,8 @@ sub rdb_create_rule {
rdb_ensure_file( $rule, $source, undef, $set_file_not_exists );
}
rdb_one_rule( $rule, \&rdb_initialize_generated );
+ if ($active) { rdb_activate($rule); }
+ else { rdb_deactivate($rule); }
} #END rdb_create_rule
#************************************************************
@@ -8087,18 +8481,17 @@ sub rdb_initialize_generated {
# Initialize hash of generated files
%$PHdest = ();
if ($$Pdest) { rdb_add_generated($$Pdest); }
- foreach (@$PA_extra_generated) {
- rdb_add_generated($_);
- }
+ rdb_add_generated(@$PA_extra_gen);
} #END rdb_initialize_generated
#************************************************************
sub rdb_add_generated {
# Assume rule context.
-# Add arguments to hash of generated files
+# Add arguments to hash of generated files, and to global cache
foreach (@_) {
$$PHdest{$_} = 1;
+ $from_rules{$_} = $rule;
}
} #END rdb_add_generated
@@ -8107,9 +8500,7 @@ sub rdb_add_generated {
sub rdb_remove_generated {
# Assume rule context.
# Remove arguments from hash of generated files
- foreach (@_) {
- delete $$PHdest{$_};
- }
+ foreach (@_) { delete $$PHdest{$_}; }
} #END rdb_remove_generated
#************************************************************
@@ -8135,17 +8526,17 @@ sub rdb_ensure_file {
die_trace( "$My_name: BUG in call to rdb_ensure_file: undefined file for '$rule'" );
}
if ( $new_file =~ /\"/ ) {
- warn "$My_name: in rdb_ensure_file for rule '$rule', there is a double quote in\n",
- " the filename: '$new_file'.\n",
- " I cannot handle this, will ignore this file.\n";
- return;
+ warn "$My_name: in rdb_ensure_file for rule '$rule', there is a double quote in\n",
+ " the filename: '$new_file'.\n",
+ " I cannot handle this, will ignore this file.\n";
+ return;
}
if ( ! defined $set_not_exists ) { $set_not_exists = 0; }
rdb_one_rule( $rule,
sub{
if (! exists ${$PHsource}{$new_file} ) {
if ( $set_not_exists ) {
- ${$PHsource}{$new_file} = [0, -1, 0, '', 0];
+ ${$PHsource}{$new_file} = [@nofile, '', 0];
}
else {
${$PHsource}{$new_file}
@@ -8193,9 +8584,9 @@ sub rdb_set_source {
if (!$rule) { return; }
my %files = ();
foreach (@_) {
-# if ( /\"/ ) {next; }
- rdb_ensure_file( $rule, $_ );
- $files{$_} = 1;
+# if ( /\"/ ) {next; }
+ rdb_ensure_file( $rule, $_ );
+ $files{$_} = 1;
}
foreach ( rdb_list_source($rule) ) {
if ( ! exists $files{$_} ) { rdb_remove_files( $rule, $_ ); }
@@ -8220,12 +8611,12 @@ sub rdb_change_dest {
rdb_add_generated( $new_dest );
if ($flag) {
print "rdb_change_dest: fixing dependencies\n";
- rdb_for_all( sub{ if ( rdb_file_exists( $rule, $old_dest ) ) {
- rdb_ensure_file( $rule, $new_dest );
- rdb_remove_files( $rule, $old_dest );
+ rdb_for_actives( sub{ if ( rdb_file_exists( $rule, $old_dest ) ) {
+ rdb_ensure_file( $rule, $new_dest );
+ rdb_remove_files( $rule, $old_dest );
}
}
- );
+ );
}
$$Pdest = $new_dest;
# ??? Do I need to fix from_rule setting?
@@ -8261,7 +8652,11 @@ sub rdb_update_gen_files {
# Assumes rule context. Update source files of rule to current state.
rdb_do_files(
sub{
- if ( exists $generated_exts_all{ ext_no_period($file) } ) {&rdb_update1;}
+ if ( exists $generated_exts_all{ ext_no_period($file) }
+ || exists $$PHdest{$file}
+ ) {
+ &rdb_update1;
+ }
}
);
} #END rdb_update_gen_files
@@ -8340,7 +8735,7 @@ sub cus_dep_require_primary_run {
local $cus_dep_target = $$Pdest;
# Loop over all rules and source files:
- rdb_for_all( 0,
+ rdb_for_actives( 0,
sub { if ($file eq $cus_dep_target) {
$$Pout_of_date = 1;
$$Pcorrect_after_primary = 1;
@@ -8372,6 +8767,17 @@ sub show_array {
else { warn " NONE\n"; }
}
+
+#************************************************************
+
+sub array_to_hash {
+ # Call: array_to_hash( items )
+ # Returns: hash mapping items to 1
+ my %hash = ();
+ foreach (@_) {$hash{$_} = 1; }
+ return %hash;
+}
+
#************************************************************
sub Parray {
@@ -8620,7 +9026,7 @@ sub get_checksum_md5 {
sub create_empty_file {
my $name = shift;
my $h = new FileHandle ">$name"
- or return 1;
+ or return 1;
close ($h);
return 0;
}
@@ -8724,12 +9130,24 @@ sub find_file_list1 {
sub unlink_or_move {
if ( $del_dir eq '' ) {
- unlink @_;
+ foreach (@_) {
+ if (!-e) {next;}
+ if (-d) {
+ if (!rmdir) {
+ warn "$My_name: Cannot remove directory '$_'\n";
+ }
+ }
+ else {
+ if (!unlink) {
+ warn "$My_name: Cannot remove file '$_'\n";
+ }
+ }
+ }
}
else {
foreach (@_) {
- if (-e $_ && ! rename $_, "$del_dir/$_" ) {
- warn "$My_name:Cannot move '$_' to '$del_dir/$_'\n";
+ if (-e $_ && ! move $_, "$del_dir/$_" ) {
+ warn "$My_name: Cannot move '$_' to '$del_dir/$_'\n";
}
}
}
@@ -8748,9 +9166,9 @@ sub kpsewhich {
my $cmd = $kpsewhich;
my @args = @_;
if ( ($cmd eq '') || ( $cmd =~ /^NONE($| )/ ) ) {
- # Kpsewhich not set up.
- warn "$My_name: Kpsewhich command needed but not set up\n";
- return ();
+ # Kpsewhich not set up.
+ warn "$My_name: Kpsewhich command needed but not set up\n";
+ return ();
}
foreach (@args) {
if ( ! /^-/ ) {
@@ -8772,7 +9190,7 @@ sub kpsewhich {
}
close $fh;
if ( $kpsewhich_show || $diagnostics ) {
- show_array( "$My_name.kpsewhich: '$cmd' ==>", @found );
+ show_array( "$My_name.kpsewhich: '$cmd' ==>", @found );
}
return @found;
}
@@ -8829,38 +9247,23 @@ sub add_aux_hook {
####################################################
-sub add_input_ext {
- # Usage: add_input_ext( rule, ext, ... )
- # Add extension(s) (specified without a leading period) to the
- # list of input extensions for the given rule. The rule should be
- # 'latex' or 'pdflatex'. These extensions are used when an input
+sub set_input_ext {
+ # Usage: set_input_ext( rule, ext, ... )
+ # Set list of extension(s) (specified without a leading period)
+ # for the given rule ('latex', 'pdflatex', etc).
+ # These extensions are used when an input
# file without an extension is found by (pdf)latex, as in
# \input{file} or \includegraphics{figure}. When latexmk searches
# custom dependencies to make the missing file, it will assume that
# the file has one of the specified extensions.
my $rule = shift;
- if ( ! exists $input_extensions{$rule} ) {
- $input_extensions{$rule} = {};
- }
+ $input_extensions{$rule} = {};
my $Prule = $input_extensions{$rule};
foreach (@_) { $$Prule{$_} = 1; }
}
####################################################
-sub remove_input_ext {
- # Usage: remove_input_ext( rule, ext, ... )
- # Remove extension(s) (specified without a leading period) to the
- # list of input extensions for the given rule. The rule should be
- # 'latex' or 'pdflatex'. See sub add_input_ext for the use.
- my $rule = shift;
- if ( ! exists $input_extensions{$rule} ) { return; }
- my $Prule = $input_extensions{$rule};
- foreach (@_) { delete $$Prule{$_}; }
-}
-
-####################################################
-
sub show_input_ext {
# Usage: show_input_ext( rule )
my $rule = shift;
@@ -9051,12 +9454,12 @@ sub get_filetime_offset {
my $tmp_file = "${prefix}${tmp_file_count}${suffix}";
if ( ! -e $tmp_file ) {
open( TMP, ">$tmp_file" )
- or die "$My_name.get_filetime_offset: In measuring filetime offset, couldn't write to\n",
- " temporary file '$tmp_file'\n";
- my $time = time();
+ or die "$My_name.get_filetime_offset: In measuring filetime offset, couldn't write to\n",
+ " temporary file '$tmp_file'\n";
+ my $time = time();
close(TMP);
- my $offset = get_mtime($tmp_file) - $time;
- unlink $tmp_file;
+ my $offset = get_mtime($tmp_file) - $time;
+ unlink $tmp_file;
return $offset;
}
}
@@ -9187,12 +9590,14 @@ sub Run_no_time {
if ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s+(.*)$/ ) {
my $routine = $1;
my @args = parse_quotes( $2 );
- warn "$My_name: calling $routine( $2 )\n";
+ warn "$My_name: calling $routine( $2 )\n"
+ if (! $silent);
return ( 0, &$routine( @args ) );
}
elsif ( $cmd_line =~ /^internal\s+([a-zA-Z_]\w*)\s*$/ ) {
my $routine = $1;
- warn "$My_name: calling $routine()\n";
+ warn "$My_name: calling $routine()\n"
+ if (! $silent);
return ( 0, &$routine() );
}
elsif ( $cmd_line =~ /^NONE/ ) {
@@ -9306,7 +9711,7 @@ sub find_process_id {
shift(@ps_output); # Discard the header line from ps
foreach (@ps_output) {
next unless ( /$looking_for/ ) ;
- s/^\s*//;
+ s/^\s*//;
my @ps_line = split ('\s+');
push @found, $ps_line[$pid_position];
push @ps_lines, $_;
@@ -9357,7 +9762,7 @@ sub cache_good_cwd {
}
}
elsif ( $^O eq "msys" ) {
- $cwd =~ s[^/([a-z])/][\u$1:/];
+ $cwd =~ s[^/([a-z])/][\u$1:/];
}
$cache{cwd} = $cwd;
} # END cache_good_cwd
@@ -9397,7 +9802,8 @@ sub popd {
sub ifcd_popd {
if ( $do_cd ) {
- warn "$My_name: Undoing directory change\n";
+ warn "$My_name: Undoing directory change\n"
+ if !$silent;
&popd;
}
}