summaryrefslogtreecommitdiff
path: root/support/latexmk/example_rcfiles
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-03-18 03:01:39 +0000
committerNorbert Preining <norbert@preining.info>2022-03-18 03:01:39 +0000
commita892f739b50b6ddc5321c834017cdcbc42a3f056 (patch)
treeea36345421ed45471d9ec79ff9288cbc9437a718 /support/latexmk/example_rcfiles
parent8208f204439f3a899e43187857e3f9c86d4ebb7c (diff)
CTAN sync 202203180301
Diffstat (limited to 'support/latexmk/example_rcfiles')
-rw-r--r--support/latexmk/example_rcfiles/asymptote_latexmkrc3
-rw-r--r--support/latexmk/example_rcfiles/chapterbib-latexmkrc10
-rw-r--r--support/latexmk/example_rcfiles/clean_pattern_latexmkrc2
-rw-r--r--support/latexmk/example_rcfiles/dot2tex-latexmkrc175
-rw-r--r--support/latexmk/example_rcfiles/exceltex_latexmkrc2
-rw-r--r--support/latexmk/example_rcfiles/fix-aux.latexmkrc4
-rw-r--r--support/latexmk/example_rcfiles/glossaries_latexmkrc39
-rw-r--r--support/latexmk/example_rcfiles/glossary_latexmkrc44
-rw-r--r--support/latexmk/example_rcfiles/minted_latexmkrc38
-rw-r--r--support/latexmk/example_rcfiles/pythontex-latexmkrc2
10 files changed, 268 insertions, 51 deletions
diff --git a/support/latexmk/example_rcfiles/asymptote_latexmkrc b/support/latexmk/example_rcfiles/asymptote_latexmkrc
index 45f32979d0..7a7425ff47 100644
--- a/support/latexmk/example_rcfiles/asymptote_latexmkrc
+++ b/support/latexmk/example_rcfiles/asymptote_latexmkrc
@@ -48,8 +48,7 @@ sub asy2tex { return asy2x( $_[0], 'tex' ); }
sub asy2x {
my $ret = system("asy -vv -f '$_[1]' '$_[0]' >& '$_[0].log'");
- my $FH = new FileHandle;
- open $FH, "$_[0].log";
+ open( my $FH, "<", "$_[0].log" );
%imp = ();
while (<$FH>) {
diff --git a/support/latexmk/example_rcfiles/chapterbib-latexmkrc b/support/latexmk/example_rcfiles/chapterbib-latexmkrc
index e5c2cb6250..5a613382d1 100644
--- a/support/latexmk/example_rcfiles/chapterbib-latexmkrc
+++ b/support/latexmk/example_rcfiles/chapterbib-latexmkrc
@@ -26,11 +26,17 @@ sub bibtex_fix {
if ( $base_bare eq $root ) {
print "--- Will run bibtex on modified '$root.aux' file\n";
my $aux_mod_base = $base."-mod";
- local $out_fh = new FileHandle "> $aux_mod_base$ext";
+
+ # Open output (modified aux file) here rather than in fix_aux, and
+ # make the relevant variables local. This is instead opening both
+ # files in fix_aux itself. The reason: fix_aux calls itself
+ # recursively, but must always write to the same file.
+ open( local $out_fh, ">", $aux_mod_base$ext );
if (!$out_fh) { die "Cannot write to '$aux_mod_base$ext'\n"; }
local $level = 0;
fix_aux( $source );
close $out_fh;
+
# Override source, dest, and basenames, since they are to have the path given
# in the arguments to this subroutine, instead of the path given in the
# corresponding names in the rule. Latexmk may change directory before
@@ -51,7 +57,7 @@ sub fix_aux {
# removing \bibdata and \bibstyle lines that were in included .aux files.
my $aux_file = $_[0];
print "Processing '$aux_file'\n";
- my $aux_fh = new FileHandle $aux_file;
+ open( my $aux_fh, "<", $aux_file );
if (!$aux_fh) { die "$My_name: Couldn't read aux file '$aux_file'\n"; }
$level++;
while (<$aux_fh>) {
diff --git a/support/latexmk/example_rcfiles/clean_pattern_latexmkrc b/support/latexmk/example_rcfiles/clean_pattern_latexmkrc
index b15507c623..9a5fa3ac52 100644
--- a/support/latexmk/example_rcfiles/clean_pattern_latexmkrc
+++ b/support/latexmk/example_rcfiles/clean_pattern_latexmkrc
@@ -2,7 +2,7 @@
# extension or something containing %R.
# This is done by overriding latexmk's cleanup1 subroutine.
-# Here is an example of a usefule application:
+# Here is an example of a useful application:
$clean_ext = "*-eps-converted-to.pdf";
sub cleanup1 {
diff --git a/support/latexmk/example_rcfiles/dot2tex-latexmkrc b/support/latexmk/example_rcfiles/dot2tex-latexmkrc
new file mode 100644
index 0000000000..64693cab33
--- /dev/null
+++ b/support/latexmk/example_rcfiles/dot2tex-latexmkrc
@@ -0,0 +1,175 @@
+# ================ Customization for dot2tex: ================================
+
+push @generated_exts, '%R-dot2tex-fig*.tex', '%R-dot2tex-fig*.dot',
+ '%R-dot2tex-fig*.dot2texopts';
+add_cus_dep( 'dot', 'tex', 0, 'dot2tex' );
+
+# Fancy: prefix string for each *latex by "internal" mylatex and basename of tex file
+#foreach my $name ( 'latex', 'pdflatex', 'lualatex', 'xelatex' ) {
+# ${$name} = "internal mylatex %B ". ${$name};
+#}
+
+$latex = 'internal mylatex %B latex %O %S';
+$lualatex = 'internal mylatex %B lualatex %O %S';
+$pdflatex = 'internal mylatex %B pdflatex %O %S';
+$xelatex = 'internal mylatex %B xelatex %O %S';
+
+
+#---------------------------------
+
+sub dot2tex {
+ # Context for a dot2tex custom dependency assumed.
+
+ # Default options:
+ my $opts = '--figonly -fpgf -tmath';
+
+ # File that contains the option string. (Written after analysis of the
+ # log file for the previous *latex run.)
+ my $opt_file = "$_[0].dot2texopts";
+
+ # Ensure that it is known as a source file of this rule, since some
+ # changes in the main .tex could affect the options only, but not the
+ # contents of the .dot file
+ rdb_ensure_file( $rule, $opt_file );
+
+ if ( -e $opt_file && open( my $fh, '<', $opt_file ) ) {
+ $opts = <$fh>;
+ close $opt_file;
+ }
+ else { warn "dot2tex: Cannot open '$opt_file'\n"; }
+
+ my @cmd = ( 'dot2tex', split(/\s+/, $opts), '-o', $$Pdest, $$Psource );
+ print "dot2tex command line to execute:\n ", join( ' ', @cmd), "\n";
+ return system @cmd;
+}
+
+#---------------------------------
+
+sub mylatex {
+ # Context for a *latex rule assumed.
+ # Run *latex as specified in my arguments, and then process the log file
+ # to deal with dot2tex conversions needed by the dot2texi package.
+
+ my ($base, @cmd) = @_;
+ my $log_name = "$aux_dir1$base.log";
+
+ my $return = system @cmd;
+ &examine_log_for_dot2tex( $log_name );
+ return $return;
+}
+
+#---------------------------------
+
+sub examine_log_for_dot2tex {
+ # Context for a *latex rule assumed.
+ # From the log file given in the argument to this subroutine,
+ # find places where dot2tex would be invoked if *latex were used with
+ # the -shell-escape option. This invocation is on .dot files created
+ # by the dot2texi package.
+ # Find the basename of the .dot and .tex files (all assumed to be
+ # relative to the aux dir). (Basename includes a possible path
+ # component.)
+ # Ensure that for each .dot file the .tex file is in the source file of
+ # the current rule, so that latexmk will know to make a corresponding
+ # custom dependency.
+ # Put the option string in a file where the custom dependency for the
+ # dot-to-tex conversion can find it.
+
+ my $log_name = $_[0];
+
+ # Map of basenames_with_relative_path of dot/tex file to option string
+ my %found = ();
+
+ open( my $log_fh, '<', $log_name )
+ or ( warn( "examine_log_for_dot2tex: Can't read '$log_name'\n" ),
+ return
+ );
+LINE:
+ while (my $line = <$log_fh> ) {
+ # Aim: find lines of form runsystem\(dot2tex followed by options
+ # followed by "-o file.tex file.dot)", for some value of file.
+ # Allow for continuation lines.
+ # Often use /.../x with x option to regex, to get space in pattern
+ # ignored, for readability
+
+ # Ignore lines with wrong start:
+ if ( $line !~ /^runsystem\(dot2tex \s+ (.*)$/x ) { next; }
+
+ # Rest of command line (after dot2tex) is in $1.
+ my $args = $1;
+
+ # Only keep going if arguments begin with options and have -o (for
+ # output file):
+ if ( $args !~ /(-.*) \s+ -o \s+ (.*) $/x ) {
+ next LINE;
+ }
+
+ # Putative options for command, then source and dest file:
+ my ($opts, $file_part) = ($1, $2);
+ # Remove superfluous space:
+ $opts =~ s/\s+/ /g;
+ $opts =~ s/\s*$//;
+ if ( $opts !~ /^(-\S+\s*)*$/x ) {
+ warn "Putative options for dot2tex in '$opts' aren't options\n";
+ next LINE;
+ }
+ my $attempts = 0;
+
+CONT_LINE:
+ while ($attempts < 2) {
+ $attempts++;
+ if ($file_part =~ /^(.+) \.tex \s+ \1 \.dot\)/x ) {
+ ($found{$1} = $opts) =~ s/\s+/ /g;
+ last CONT_LINE;
+ }
+ if (length($line) >= 80) {
+ if (eof($log_fh)) { last LINE; }
+ $file_part .= <$log_fh>;
+ # Remove trailing new line characters:
+ $file_part =~ s/[\n\r]$//;
+ }
+ else { last CONT_LINE; }
+ }
+ }
+ close $log_fh;
+
+ my @missing_files = ();
+ while (my ($base, $opts) = each %found) {
+ my $dot = "$aux_dir1$base.dot";
+ my $tex = "$aux_dir1$base.tex";
+ # File to save options for dot2tex command, so cusdep can read them:
+ my $opt_file = "$aux_dir1$base.dot2texopts";
+
+ write_to_file( $opt_file, "$opts\n" );
+ if (! -e $tex) { push @missing_files, $tex; }
+ }
+ if (@missing_files) {
+ # No-file lines for missing .tex files will tell latexmk to try
+ # to find a cusdep to make them:
+ append_to_file( $log_name, map("No file $_.\n", @missing_files) );
+ }
+}
+
+#---------------------------------
+
+sub write_to_file {
+ # Usage: write_to_file( name, items to write )
+ my $file = shift;
+ open( my $fh, ">", $file )
+ or (warn "Cannot write to '$file'\n", return 0 );
+ print $fh @_;
+ close( $fh );
+}
+
+#---------------------------------
+
+sub append_to_file {
+ # Usage: append_to_file( name, items to write )
+ my $file = shift;
+ open( my $fh, ">>", $file )
+ or (warn "Cannot append to '$file'\n", return 0 );
+ print $fh @_;
+ close( $fh );
+}
+
+#---------------------------------
diff --git a/support/latexmk/example_rcfiles/exceltex_latexmkrc b/support/latexmk/example_rcfiles/exceltex_latexmkrc
index e1cf68424f..df265bdd1e 100644
--- a/support/latexmk/example_rcfiles/exceltex_latexmkrc
+++ b/support/latexmk/example_rcfiles/exceltex_latexmkrc
@@ -44,7 +44,7 @@ sub excel2tex {
# changes, and to do this before running latex/pdflatex again.
# First find dependency/ies on .xls files, by parsing the .excltx file,
- my $Hsource = new FileHandle;
+ my $Hsource;
my %xls = ();
my $source = "$_[0].excltx";
if (! open $Hsource, "<$source") {
diff --git a/support/latexmk/example_rcfiles/fix-aux.latexmkrc b/support/latexmk/example_rcfiles/fix-aux.latexmkrc
index aefa206d5a..abcee8e9f2 100644
--- a/support/latexmk/example_rcfiles/fix-aux.latexmkrc
+++ b/support/latexmk/example_rcfiles/fix-aux.latexmkrc
@@ -3,6 +3,10 @@
# option. (Of the standard distributions, MiKTeX supports -aux-directory,
# but TeXLive does not.)
+# !!!IMPORTANT: THIS CONFIGURATION IS NO LONGER NECESSARY. From V. 4.74b onwards,
+# latexmk can handle the aux_dir isssue itself --- see the documentation on the
+# $emulate_aux variable.
+
foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) {
${$cmd} = "internal latex_fix_aux $cmd %O %S";
diff --git a/support/latexmk/example_rcfiles/glossaries_latexmkrc b/support/latexmk/example_rcfiles/glossaries_latexmkrc
new file mode 100644
index 0000000000..7e8dfab3ac
--- /dev/null
+++ b/support/latexmk/example_rcfiles/glossaries_latexmkrc
@@ -0,0 +1,39 @@
+# This shows how to use the glossaries package
+# (http://www.ctan.org/pkg/glossaries) and 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 item 2.
+
+# 1. If you use the glossaries or the glossaries-extra package, then you can use:
+
+ 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 ($base_name, $path) = fileparse( $_[0] );
+ my @args = ( "-q", "-d", $path, $base_name );
+ if ($silent) { unshift @args, "-q"; }
+ return system "makeglossaries", "-d", $path, $base_name;
+ }
+
+# 2. The above will tend to run makeglossaries more often than needed, since
+# each out of date file will trigger the use of makeglossaries, even
+# though makeglossaries makes all the glossaries. The following solution
+# solves this, but at the expense of not having the convenience that
+# makeglossaries can change how it makes the glossaries depending on the
+# settings of the glossaries package.
+# A better solution will need more advanced work.
+#
+# 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 @args = ( "-s", "$_[0].ist", "-t", "$$Psource.ilg",
+# "-o", $$Pdest, $$Psource );
+# if ($silent) { unshift @args, "-q"; }
+# return system "makeindex", @args;
+# }
+
diff --git a/support/latexmk/example_rcfiles/glossary_latexmkrc b/support/latexmk/example_rcfiles/glossary_latexmkrc
deleted file mode 100644
index cd75f2d2d0..0000000000
--- a/support/latexmk/example_rcfiles/glossary_latexmkrc
+++ /dev/null
@@ -1,44 +0,0 @@
-# This shows how to use the glossaries package
-# (http://www.ctan.org/pkg/glossaries) and 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 item 2.
-
-# 1. If you use the glossaries or the glossaries-extra package, then you use:
-
- 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 ($base_name, $path) = fileparse( $_[0] );
- pushd $path;
- my $return = system "makeglossaries", $base_name;
- popd;
- return $return;
- }
-
-
-# 2. If you use the OBSOLETE glossary package, then you can do the following:
-# (Note that the code lines are commented out to avoid trouble when this
-# file is simply copied into a latexmkrc or this file is arranged to be
-# read by latexmk, and one of the modern packages glossaries and
-# glossaries-extra is used.)
-
- ## For the main glossary:
- #add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' );
- #sub makeglo2gls {
- # system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" );
- #}
-
- ## For acronyms:
- ##
- ## ===> WARNING: The code below is ONLY FOR PACKAGE glossary, NOT FOR
- ## glossaries and glossaries-extra. In the current glossaries and
- ## glossaries-extra packages the roles of the .acr and .acn files are
- ## exchanged compared with the old glossary package. Hence the the
- ## code below will fail with the more modern packages.
- #add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' );
- #sub makeacr2acn {
- # system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" );
- #}
diff --git a/support/latexmk/example_rcfiles/minted_latexmkrc b/support/latexmk/example_rcfiles/minted_latexmkrc
new file mode 100644
index 0000000000..076c7fc15b
--- /dev/null
+++ b/support/latexmk/example_rcfiles/minted_latexmkrc
@@ -0,0 +1,38 @@
+# For the minted package (which does nice formatting of source code):
+#
+# 1. Need to use -shell-escape on *latex command.
+# 2. Need to arrange passing of the output dir (actually aux dir if it
+# differs from out dir) to minted. Then this directory information does
+# not have to be specified in the .tex file itself.
+# 3. In some cases, latexmk does an extra run of *latex than is
+# needed. This is solved by getting latexmk to ignore certain lines in
+# the aux file when latexmk looks for changes. These lines are written
+# by minted and are irrelevant to the output file from *latex.
+#
+# The reason for the extra run of *latex that may happen is because
+# after minted runs pygmentize to make the nicely formatted source code,
+# minted saves cached information about the run(s) of pygmentize. This
+# information is put in the aux file. So latexmk sees the changed aux
+# file, and knows that may affect the output of *latex, which it
+# therefore reruns. However the minted-written lines do not affect the
+# output of *latex.
+#
+# The method works if the aux dir's name contains a string of MORE than one
+# space That's a problem in minted's calls to pygmentize.
+# Single spaces in the name are OK.
+# Generally it helps to use only aux_dir and out_dir names without spaces,
+# to avoid trouble.
+
+&set_tex_cmds( '-shell-escape %O '
+ . '\'\PassOptionsToPackage{outputdir={%Y}}{minted}\input{%S}\''
+ );
+# (Here the outer level of single quotes is for Perl. The dot is for
+# Perl's string concatenation. The \' tell Perl to put actual single
+# quotes in the string (given to the shell). In Unix, the shell is sh (or
+# equivalent), so the string inside the single quotes is a single argument
+# to the command is not changed at all.)
+#
+$hash_calc_ignore_pattern{aux} = '^\\\\gdef\\\\minted@oldcachelist\{,'.
+ '|^\s*default\.pygstyle,'.
+ '|^\s*[[:xdigit:]]+\.pygtex';
+
diff --git a/support/latexmk/example_rcfiles/pythontex-latexmkrc b/support/latexmk/example_rcfiles/pythontex-latexmkrc
index ba02de3ee7..825706a630 100644
--- a/support/latexmk/example_rcfiles/pythontex-latexmkrc
+++ b/support/latexmk/example_rcfiles/pythontex-latexmkrc
@@ -21,7 +21,7 @@ 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";
+ open( my $fh, "<", $$Pdest );
if ($fh) {
while (<$fh>) {
if ( /^%PythonTeX dependency:\s+'([^']+)';/ ) {