summaryrefslogtreecommitdiff
path: root/support/latexmk/example_rcfiles
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2024-04-04 03:02:05 +0000
committerNorbert Preining <norbert@preining.info>2024-04-04 03:02:05 +0000
commit00e667637a3a526b577b05c4d9fead45d65c4c57 (patch)
treec5488d29362ed4d6c10b2271fdf0b54676f18a1e /support/latexmk/example_rcfiles
parente0bd7da7a67c4cd2c53d232fb0f5cfccc4c37743 (diff)
CTAN sync 202404040301
Diffstat (limited to 'support/latexmk/example_rcfiles')
-rw-r--r--support/latexmk/example_rcfiles/asymptote_latexmkrc62
-rw-r--r--support/latexmk/example_rcfiles/bib2gls_latexmkrc51
-rw-r--r--support/latexmk/example_rcfiles/memoize_latexmkrc258
-rw-r--r--support/latexmk/example_rcfiles/splitindex.latexmkrc (renamed from support/latexmk/example_rcfiles/splitindex_latexmkrc)15
4 files changed, 56 insertions, 330 deletions
diff --git a/support/latexmk/example_rcfiles/asymptote_latexmkrc b/support/latexmk/example_rcfiles/asymptote_latexmkrc
index a936b4127f..7a7425ff47 100644
--- a/support/latexmk/example_rcfiles/asymptote_latexmkrc
+++ b/support/latexmk/example_rcfiles/asymptote_latexmkrc
@@ -2,13 +2,32 @@
# or http://www.ctan.org/pkg/asymptote/)
# with latexmk. Asymptote is a vector graphics language with a
# processing program that generates graphics files that can be used in
-# a LaTex file.
+# a LaTex file.
#
-# The definitions in this file enable automatic compilation of .asy files
-# containing asymptote code to be compiled to graphics files. The .asy files
-# may be created as stand-alone files or may be created during a *latex
-# run by the use of the asymptote package with a document that contains
-# sections of asymptote code.
+# A standard method of using it is with the asymptote LaTeX style file
+# (http://mirror.ctan.org/graphics/asymptote/doc/asymptote.sty)
+# The graphics drawing code is in the tex file, and applying pdflatex to
+# the tex file produces one or more files with a base name the same as
+# or related to the main tex file, but with the extension 'asy'. The
+# .asy is processed by the program asy (part of the asymptote
+# software) to produce graphics files (which may be eps, tex, or pdf
+# files) that are used the next time pdflatex is run on the main tex
+# file.
+#
+# Latexmk can be arranged to run asymptote (i.e., the program asy)
+# when needed, by defining the following custom dependency. (The code
+# is to be put in one of latexmk's rc files, e.g., ~/.latexmkrc.)
+#
+
+## OLD simple method (taken from the documentation for V. 2.03 of
+## asymptote). These definitions are simple, but they may not always
+## give the desired type of output file, and they do not ensure that
+## latexmk has dependency information about files imported from the
+## asy file.
+#OLD sub asy {return system("asy \"$_[0]\"");}
+#OLD add_cus_dep("asy","eps",0,"asy");
+#OLD add_cus_dep("asy","pdf",0,"asy");
+#OLD add_cus_dep("asy","tex",0,"asy");
# The following definitions arrange to run asy with the correct output
@@ -28,28 +47,17 @@ sub asy2pdf { return asy2x( $_[0], 'pdf' ); }
sub asy2tex { return asy2x( $_[0], 'tex' ); }
sub asy2x {
- my ($base, $fmt ) = @_;
- my $log_file = "$base.log";
- my $cmd = "asy -vv -noV -f \"$fmt\" -o \"$base.$fmt\" \"$base\" > '$log_file' 2>&1";
- print "asy2x: Running '$cmd'\n";
- my $ret = system($cmd);
- my $FH = undef;
- if (! open( $FH, "<", $log_file ) ) {
- warn "asy2x: Couldn't read log file '$log_file':\n $!";
- return $ret;
- }
-
- my %imports = ("$base.asy" => 1);
+ my $ret = system("asy -vv -f '$_[1]' '$_[0]' >& '$_[0].log'");
+ open( my $FH, "<", "$_[0].log" );
+ %imp = ();
+
while (<$FH>) {
- s/\s*$//;
- if (/^(Including|Loading) .* from (.*)$/) {
+ if (/^(Including|Loading) .* from (.*)\s*$/) {
my $import = $2;
- # Convert MSWin directory separator to /
- $import =~ s(\\)(/)g;
- $imports{$import} = 1;
+ $imp{$import} = 1;
}
elsif ( /^error/ || /^.*\.asy: \d/ ) {
- warn "==Message from asy: $_\n";
+ warn "==Message from asy: $_";
$ret = 1;
}
elsif ( /^kpsewhich / || /^Processing / || /^Using /
@@ -57,11 +65,11 @@ sub asy2x {
) {
}
else {
-# warn "==Message from asy: $_\n";
+ warn "==Message from asy: $_";
}
}
close $FH;
- show_hash( '', \%imports );
- rdb_set_source( $rule, keys %imports );
+# For latexmk 4.48
+ rdb_set_source( $rule, keys %imp );
return $ret;
}
diff --git a/support/latexmk/example_rcfiles/bib2gls_latexmkrc b/support/latexmk/example_rcfiles/bib2gls_latexmkrc
index fccca2109f..53f13ff30a 100644
--- a/support/latexmk/example_rcfiles/bib2gls_latexmkrc
+++ b/support/latexmk/example_rcfiles/bib2gls_latexmkrc
@@ -1,56 +1,35 @@
-# Implements use of bib2gls with glossaries-extra.
-# Version of 4 Feb 2024.
-# Thanks to Marcel Ilg for a suggestion.
+# Implementing glossary with bib2gls and glossaries-extra, with the
+# log file (.glg) analyzed to get dependence on a .bib file.
# !!! ONLY WORKS WITH VERSION 4.54 or higher of latexmk
push @generated_exts, 'glstex', 'glg';
-# For case that \GlsXtrLoadResources is used and so glstex file (first one)
-# has same name as .aux file.
add_cus_dep('aux', 'glstex', 0, 'run_bib2gls');
-# For case that \glsxtrresourcefile is used and so glstex file (first one)
-# has same name as .bib file.
-add_cus_dep('bib', 'glstex', 0, 'run_bib2gls_alt');
-
sub run_bib2gls {
- my $ret = 0;
if ( $silent ) {
- $ret = system "bib2gls --silent --group '$_[0]'";
+ my $ret = system "bib2gls --silent --group '$_[0]'";
} else {
- $ret = system "bib2gls --group '$_[0]'";
+ my $ret = system "bib2gls --group '$_[0]'";
};
-
- # bib2gls puts output files in current directory.
- # At least put main glstex in same directory as aux file to satisfy
- # definition of custom dependency.
+
my ($base, $path) = fileparse( $_[0] );
if ($path && -e "$base.glstex") {
rename "$base.glstex", "$path$base.glstex";
}
- if ($ret) {
- warn "Run_bib2gls: Error, so I won't analyze .glg file\n";
- return $ret;
- }
# Analyze log file.
- my $log = "$_[0].glg";
- if ( open( my $log_fh, '<', $log) ) {
- while (<$log_fh>) {
- s/\s*$//;
- if (/^Reading\s+(.+)$/) { rdb_ensure_file( $rule, $1 ); }
- if (/^Writing\s+(.+)$/) { rdb_add_generated( $1 ); }
- }
- close $log_fh;
- }
- else {
- warn "Run_bib2gls: Cannot read log file '$log': $!\n";
+ local *LOG;
+ $LOG = "$_[0].glg";
+ if (!$ret && -e $LOG) {
+ open LOG, "<$LOG";
+ while (<LOG>) {
+ if (/^Reading (.*\.bib)\s$/) {
+ rdb_ensure_file( $rule, $1 );
+ }
+ }
+ close LOG;
}
return $ret;
}
-
-sub run_bib2gls_alt {
- return Run_subst( 'internal run_bib2gls %Y%R' );
-}
-
diff --git a/support/latexmk/example_rcfiles/memoize_latexmkrc b/support/latexmk/example_rcfiles/memoize_latexmkrc
deleted file mode 100644
index 6a3b61c208..0000000000
--- a/support/latexmk/example_rcfiles/memoize_latexmkrc
+++ /dev/null
@@ -1,258 +0,0 @@
-print "============= I am memoize's latexmkrc. John Collins 2024-03-29\n";
-
-# This rc file shows how to use latexmk with the memoize package.
-#
-# The memoize package (https://www.ctan.org/pkg/memoize) implements
-# externalization and memoization of sections of code in a TeX document.
-# It allows the compilation of the document to reuse results of
-# compilation-intensive code, with a consequent speeding up of runs of
-# *latex. Such compilation intensive code is commonly encountered, for
-# example, in making pictures by TikZ.
-#
-# When a section of code to be memoized is encountered, an extra page is
-# inserted in the document's pdf file containing the results of the
-# compilation of the section of code. Then a script, memoize-extract.pl or
-# memoize-extract.py, is run to extract the extra parts of the the
-# document's pdf file to individual pdf files (called externs). On the
-# next compilation by *latex, those generated pdf files are used in place
-# of actually compiling the corresponding code (unless the section of code
-# has changed).
-#
-# This latexmkrc file supports this process by configuring latexmk so that
-# when a compilation by *latex is done, a memoize-extract script is run
-# immediately afterwards. If any new externs are generated, latexmk
-# notices that and triggers a new compilation, as part of its normal mode
-# of operation.
-#
-# The memoize package itself also runs memoize-extract at the start of each
-# compilation. If latexmk has already run memoize-extract, that extra run
-# of memoize-extract finds that it has nothing to do. The solution here is
-# more general: (a) It handles the case where the memoize package is
-# invoked in the .tex file with the external=no option. (b) It handles the
-# situation where the aux and out directories are different, which is not
-# the case for the built-in invocation. (c) It nicely matches with
-# latexmk's general methods of determining how many runs of *latex are
-# needed.
-#
-# Needs latexmk v. >= 4.84, memoize >= 1.2.0 (2024/03/15).
-# TeX Live 2024 (or later, presumably).
-# Tested on TeX Live 2024 on macOS, Ubuntu, Windows,
-# with pdflatex, lualatex, and xelatex.
-# Needs perl module PDF::API2 to be installed.
-# On TeXLive on Windows, also put
-# TEXLIVE_WINDOWS_TRY_EXTERNAL_PERL = 1
-# in the texmf.cnf file in the root directory of the TeX Live installation.
-
-# ==> However, there are some anomalies on Windows, which haven't been sorted out
-# yet. These notably concern memoize-clean
-#
-# ==> Fails on MiKTeX on Windows: memoize-extract refuses to create pdf file????
-# I haven't yet figured out the problem.
-# ==> Also trouble on MiKTeX on macOS: the memoize-extract.pl.exe won't run.
-
-# You can have separate build and output directories, e.g., by
- #$out_dir = 'output';
- #$aux_dir = 'build';
-# or they can be the same, e.g., by
- # $out_dir = $aux_dir = 'output';
-
-
-# Which program and extra options to use for memoize-extract and memoize-clean.
-# Note that these are arrays, not simple strings.
-our @memoize_extract = ( 'memoize-extract.pl' );
-our @memoize_clean = ( 'memoize-clean.pl' );
-
-# Specification of the basic memoize files to delete in a clean-up
-# operation. The generated .memo and .pdf files have more specifications,
-# and we use memoize-clean to delete those, invoked by a cleanup hook.
-push @generated_exts, 'mmz', 'mmz.log';
-
-# Subroutine mmz_analyzes analyzes .mmz file, if it exists **and** was
-# generated in current compilation, to determine whether there are new
-# extern pdfs to be generated from memo files and pdf file. Communicate
-# to subtroutine mmz_extract_new a need to make new externs by setting the
-# variable to a non-zero value for $mmz_has_new. Let the value be the
-# name of the mmz file; this is perhaps being too elaborate, since the
-# standard name of the mmz file can be determined
-
-add_hook( 'after_xlatex_analysis', \&mmz_analyze );
-add_hook( 'after_main_pdf', \&mmz_extract_new );
-
-# !!!!!!!!!!!!!!!!!!!! Uncomment the following line **only** if you really
-# want latexmk's cleanup operations to delete Memoize's memoization
-# files. In a document where these files are time-consuming to make, i.e.,
-# in the main use case for the memoize package, the files are precious and
-# should only need deleted when that is really needed.
-#
-# add_hook( 'cleanup', \&mmz_cleanup );
-
-# Whether there are new externs to be made:
-my $mmz_has_new = '';
-# Scope of this variable: private, from here to end of file.
-
-
-#-----------------------------------------------------
-
-sub mmz_analyze {
- use strict;
- print "============= I am mmz_analyze \n";
- print " Still to deal with provoking of rerun if directory made\n";
-
- # Analyzes mmz file if generated on this run.
- # Then 1. Arranges to trigger making of missing extern pdfs, if needed.
- # 2. Sets dependencies on the extern pdfs. This ensures that, in
- # the case that one or more extern pdfs does not currently
- # exist, a rerun of *latex will triggered after it/they get
- # made.
- # Return zero on success (or nothing to do), and non-zero otherwise.
-
- # N.B. Current (2024-03-11) hook implementation doesn't use return
- # values from hook subroutines. Future implementation might.
- # So I'll provide a return value.
-
- my $base = $$Pbase;
- my $mmz_file = "$aux_dir1$base.mmz";
-
- # Communicate to subroutine mmz_extract_new about whether new extern
- # pdf(s) are to be made. Default to assuming no externs are to be
- # made:
- $mmz_has_new = '';
-
- if (! -e $mmz_file) {
- print "mmz_analyze: No mmz file '$mmz_file', so memoize is not being used.\n";
- return 0;
- }
-
- # Use (not-currently-documented) latexmk subroutine to detemine
- # whether mmz file was generated in current run:
- if ( ! test_gen_file_time( $mmz_file) ) {
- warn "mmz_analyze: Mmz file '$mmz_file' exists, but wasn't generated\n",
- " on this run so memoize is not **currently** being used.\n";
- return 0;
- }
-
- # Get dependency information.
- # We need to cause not-yet-made extern pdfs to be trated as source
- # files for *latex.
- my $mmz_fh = undef;
- if (! open( $mmz_fh, '<', $mmz_file ) ) {
- warn "mmz_analyze: Mmz file '$mmz_file' exists, but I can't read it:\n",
- " $!\n";
- return 1;
- }
- my @externs = ();
- my @dirs = ();
- while ( <$mmz_fh> ) {
- s/\s*$//; # Remove trailing space, including new lines
- if ( /^\\mmzNewExtern\s+{([^}]+)}/ ) {
- # We have a new memo item without a corresponding pdf file.
- # It will be put in the aux directory.
- my $file = "$aux_dir1$1";
- print "mmz_analyze: new extern for memoize: '$file'\n";
- push @externs, $file;
- }
- elsif ( /^\\mmzPrefix\s+{([^}]+)}/ ) {
- # Prefix.
- my $prefix = $1;
- if ( $prefix =~ m{^(.*)/[^/]*} ) {
- my $dir = $1;
- push @dirs, "$aux_dir1$1";
-
- }
- }
- }
- close $mmz_fh;
- foreach (@dirs) {
- if ( ! -e ) {
- my @cmd = ( @memoize_extract, '--mkdir', $_ );
- print "mmz_analyze: Making directory '$_' safely by running\n",
- " @cmd\n";
- mkdir $_;
- }
- }
-
- rdb_ensure_files_here( @externs );
-
- # .mmz.log is read by Memoize package after it does an internal
- # extract, so it appears as an INPUT file in .fls. But it was created
- # earlier in the same run by memoize-extract, so it's not a true
- # dependency, and should be removed from the list of source files:
- rdb_remove_files( $rule, "$mmz_file.log" );
-
- if (@externs ) {
- $mmz_has_new = $mmz_file;
- }
- return 0;
-}
-
-#-----------------------------------------------------
-
-sub mmz_extract_new {
- use strict;
- print "============= I am mmz_extract_new \n";
-
- # If there are new extern pdf files to be made, run memoize-extract to
- # make them.
- # Situation on entry:
- # 1. I'm in the context of a rule for making the document's pdf file.
- # When new extern pdf files are to be made, the document's pdf
- # file contains the pages to be extracted by memoize-extract.
- # Given the rule context, the name of the document's pdf file is
- # $$Pdest.
- # 2. $mmz_has_new was earlier set to the name of the mmz file with
- # the information on the files used for memoization, but only if
- # there are new extern pdf(s) to be made.
- # 3. If it is empty, then no extern pdfs are to be made. This covers
- # the case that the memoize package isn't being used.
- # Return zero on success (or nothing to do), and non-zero otherwise.
-
- if ( $mmz_has_new eq '' ) { return 0; }
-
- my $mmz_file = $mmz_has_new;
- my ($mmz_file_no_path, $path) = fileparse( $mmz_file );
- my $pdf_file = $$Pdest;
-
- # The directory used by memoize-extract for putting the generated
- # extern pdfs is passed in the TEXMF_OUTPUT_DIRECTORY environment
- # variable. (The need for this way of passing information is
- # associated with some security restrictions that apply when
- # memoize-extract is called directly from the memoize package in a
- # *latex compilation.)
- local $ENV{TEXMF_OUTPUT_DIRECTORY} = $aux_dir;
- for ('TEXMF_OUTPUT_DIRECTORY') {
- print "mmz_extract_new : ENV{$_} = '$ENV{$_}'\n";
- }
- # So we should give the name of the mmz_file to memoize-extract without
- # the directory part.
- my @cmd = (@memoize_extract, '--format', 'latex',
- '--pdf', $pdf_file, $mmz_file_no_path );
-
- if ( ! -e $pdf_file ) {
- warn "mmz_extract_new: Cannot generate externs here, since no pdf file generated\n";
- return 1;
- }
- elsif ( ! test_gen_file($pdf_file) ) {
- warn "mmz_extract_new: Pdf file '$pdf_file' exists, but wasn't\n",
- " generated on this run. I'll run memoize-extract. Pdf file may contain\n",
- " extra pages generated by the memoize package.\n";
- return 1;
- }
- print "make_extract_new: Running\n @cmd\n";
- return system @cmd;
-}
-
-#-----------------------------------------------------
-
-sub mmz_cleanup {
- use strict;
- print "============= I am mmz_cleanup \n";
- my @cmd = ( @memoize_clean, '--all', '--yes',
- '--prefix', $aux_dir,
- "$aux_dir1$$Pbase.mmz" );
- print "mmz_cleanup: Running\n @cmd\n";
- my $ret = system @cmd;
- say "Return code $ret";
- return $ret;
-}
-
-#-----------------------------------------------------
diff --git a/support/latexmk/example_rcfiles/splitindex_latexmkrc b/support/latexmk/example_rcfiles/splitindex.latexmkrc
index 5ee2273062..4509538dd7 100644
--- a/support/latexmk/example_rcfiles/splitindex_latexmkrc
+++ b/support/latexmk/example_rcfiles/splitindex.latexmkrc
@@ -1,7 +1,8 @@
-$makeindex = 'internal splitindex2 %S %D %R %B %O';
$clean_ext .= " %R-*.ind %R-*.idx %R-*.ilg %R-*.ind";
-sub splitindex2 {
+$makeindex = 'internal splitindex';
+
+sub splitindex {
# Use splitindex instead of makeindex.
# The splitindex programe starts from an .idx file, makes a set of
# other .idx files for separate indexes, and then runs makeindex to
@@ -13,7 +14,7 @@ sub splitindex2 {
# Then we need to invoke makeindex.
# In addition, latexmk assumes that makeindex or its replacement makes
# an .ind file from an .idx file, and latexmk gives an error if it
- # doesn't exist, so we need to make an .ind file.
+ # doesn't exist, we need to make an .ind file.
# Both problems are solved by running makeindex and then splitindex.
# Note: errors are returned by makeindex and splitindex for things
# like a missing input file. No error is returned for lines in an
@@ -21,12 +22,8 @@ sub splitindex2 {
# ignored. So no problem is caused by lines in the .idx file
# that are generated by splitindex in a format incompatible with
# makeindex.
- my ($source, $dest, $root, $base, @opts) = @_;
-
- my $ret1 = system( "makeindex", $source );
- my $ret2 = system( "splitindex", $source );
+ my $ret1 = system( "makeindex", $$Psource );
+ my $ret2 = system( "splitindex", $$Psource );
return $ret1 || $ret2;
}
-
-print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; \ No newline at end of file