summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/support/latexmk/example_rcfiles
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-03-19 21:28:43 +0000
committerKarl Berry <karl@freefriends.org>2019-03-19 21:28:43 +0000
commitcaa11ce41041a8197fb5bef003de1a5dd0ecf277 (patch)
treeeb9d8940c7147be142d65f0f8d67c4e269498d02 /Master/texmf-dist/doc/support/latexmk/example_rcfiles
parentef1f2fe2f48a08a89cc523d65ea2f29e5b26f058 (diff)
latexmk (19mar19)
git-svn-id: svn://tug.org/texlive/trunk@50472 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/support/latexmk/example_rcfiles')
-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
3 files changed, 120 insertions, 107 deletions
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;
}
-
-