From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- .../latexmk/example_rcfiles/README-latexmk-rcfiles | 66 +++++++++++++++ .../latexmk/example_rcfiles/asymptote_latexmkrc | 76 +++++++++++++++++ support/latexmk/example_rcfiles/bib2gls_latexmkrc | 35 ++++++++ .../example_rcfiles/clean_pattern_latexmkrc | 30 +++++++ support/latexmk/example_rcfiles/exceltex1.sty | 74 +++++++++++++++++ support/latexmk/example_rcfiles/exceltex_latexmkrc | 64 +++++++++++++++ support/latexmk/example_rcfiles/fix-aux.latexmkrc | 96 ++++++++++++++++++++++ support/latexmk/example_rcfiles/glossary_latexmkrc | 39 +++++++++ support/latexmk/example_rcfiles/lualatex_latexmkrc | 11 +++ support/latexmk/example_rcfiles/mpost_latexmkrc | 28 +++++++ .../latexmk/example_rcfiles/nomenclature_latexmkrc | 9 ++ support/latexmk/example_rcfiles/pdflatexmkrc | 77 +++++++++++++++++ .../latexmk/example_rcfiles/pythontex-latexmkrc | 39 +++++++++ support/latexmk/example_rcfiles/sagetex_latexmkrc | 21 +++++ .../latexmk/example_rcfiles/splitindex.latexmkrc | 29 +++++++ support/latexmk/example_rcfiles/sweave_latexmkrc | 57 +++++++++++++ support/latexmk/example_rcfiles/tex4ht-latexmkrc | 33 ++++++++ support/latexmk/example_rcfiles/texinfo-latexmkrc | 76 +++++++++++++++++ .../example_rcfiles/tikz-externalized-latexmkrc | 75 +++++++++++++++++ support/latexmk/example_rcfiles/xelatex_latexmkrc | 13 +++ 20 files changed, 948 insertions(+) create mode 100644 support/latexmk/example_rcfiles/README-latexmk-rcfiles create mode 100644 support/latexmk/example_rcfiles/asymptote_latexmkrc create mode 100644 support/latexmk/example_rcfiles/bib2gls_latexmkrc create mode 100644 support/latexmk/example_rcfiles/clean_pattern_latexmkrc create mode 100644 support/latexmk/example_rcfiles/exceltex1.sty create mode 100644 support/latexmk/example_rcfiles/exceltex_latexmkrc create mode 100644 support/latexmk/example_rcfiles/fix-aux.latexmkrc create mode 100644 support/latexmk/example_rcfiles/glossary_latexmkrc create mode 100644 support/latexmk/example_rcfiles/lualatex_latexmkrc create mode 100644 support/latexmk/example_rcfiles/mpost_latexmkrc create mode 100644 support/latexmk/example_rcfiles/nomenclature_latexmkrc create mode 100644 support/latexmk/example_rcfiles/pdflatexmkrc create mode 100644 support/latexmk/example_rcfiles/pythontex-latexmkrc create mode 100644 support/latexmk/example_rcfiles/sagetex_latexmkrc create mode 100644 support/latexmk/example_rcfiles/splitindex.latexmkrc create mode 100644 support/latexmk/example_rcfiles/sweave_latexmkrc create mode 100644 support/latexmk/example_rcfiles/tex4ht-latexmkrc create mode 100644 support/latexmk/example_rcfiles/texinfo-latexmkrc create mode 100644 support/latexmk/example_rcfiles/tikz-externalized-latexmkrc create mode 100644 support/latexmk/example_rcfiles/xelatex_latexmkrc (limited to 'support/latexmk/example_rcfiles') diff --git a/support/latexmk/example_rcfiles/README-latexmk-rcfiles b/support/latexmk/example_rcfiles/README-latexmk-rcfiles new file mode 100644 index 0000000000..19690cf168 --- /dev/null +++ b/support/latexmk/example_rcfiles/README-latexmk-rcfiles @@ -0,0 +1,66 @@ +The files in this directory provide suggestions for customizing an +initialization file ("rc file") for latexmk. See the latexmk +documentation for general information on its initialization files. + +Not only do these files provide solutions to particular problems, but +they can be also used as inspiration for solutions to other cases. + +NOTES: + +1. The examples are not complete rc files, but contain fragments that + you can copy to one of your .latexmkrc/latexmkrc files. + +2. These examples are developed by particular users to solve + particular problems. You may have to customize them for your own + needs. So read the comments carefully, and understand how the + examples are working. + +3. I have generally arranged for filenames to be quoted on command + lines, e.g., + + system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" ); + + In many cases the quotes may be omitted, as in + + system( "makeindex -o $_[0].lnd $_[0].ldx" ); + + But it is preferable to leave the quotes in, since they provide + safety against special characters in filenames. The double quotes + appear not to cause problems in all situations that I have tried. + +5. Note that the files for exceltex and pythontex illustrate an answer + to an issue that arises in the following generic situation: + a. A LaTeX package wants to use an external program to do some + processing. It does this by writing a control file that is used + by the external program. + b. The user is to run the external program after a first run of + latex/pdflatex (etc). It generates some files that are to be + read by a subsequent compilation of the TeX document. + c. It is desired to do the run of the external program and + to do the extra run of latex/pdflatex only when necessary. + d. Possibly there are further dependencies on files used by the + external program. + The third problem is handled nicely by latexmk's normal mechanisms, + but it is necessary to persuade it to create a suitable rule to run + the external program. A nice trick with custom dependencies, + illustrated by exceltex and pythontex examples, gets the rule set + up. The exceltex shows how dependencies on other files can be + determined. + +6. Further assistance for latexmk can be provided when style files + provide suitable messages about missing files. See the + exceltex1.sty file for an example of what is needed. This file is + a modification of exceltex.sty and pythontex.sty that provide the + necessary assistance. (The version on which the modification is + based is the one current on 30 April 2013.) The necessary support + is in pythontex, in v. 0.16. + +7. Another technique, exemplified in pythontex-latexmkrc, is to append + lines to the .log file to simulate messages about missing files. + This provokes latexmk into deducing that the files are intended + source files. If one of the other rules then can make that file, + correct dependency information is obtained. + + + + diff --git a/support/latexmk/example_rcfiles/asymptote_latexmkrc b/support/latexmk/example_rcfiles/asymptote_latexmkrc new file mode 100644 index 0000000000..45f32979d0 --- /dev/null +++ b/support/latexmk/example_rcfiles/asymptote_latexmkrc @@ -0,0 +1,76 @@ +# This shows how to use Asymptote (http://asymptote.sourceforge.net/, +# 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 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 +# file type. They run asy in a verbose mode so that dependency +# information on imported files can be extracted. To avoid adding a +# lot of extra printout on the screen of unimportant messages, the +# output is sent to a log file. Since this includes error messages, +# which the user should see, latexmk types out error messages and the +# like. These definitions need latexmk 4.48 or later. + +add_cus_dep("asy","eps",0,"asy2eps"); +add_cus_dep("asy","pdf",0,"asy2pdf"); +add_cus_dep("asy","tex",0,"asy2tex"); + +sub asy2eps { return asy2x( $_[0], 'eps' ); } +sub asy2pdf { return asy2x( $_[0], 'pdf' ); } +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"; + %imp = (); + + while (<$FH>) { + if (/^(Including|Loading) .* from (.*)\s*$/) { + my $import = $2; + $imp{$import} = 1; + } + elsif ( /^error/ || /^.*\.asy: \d/ ) { + warn "==Message from asy: $_"; + $ret = 1; + } + elsif ( /^kpsewhich / || /^Processing / || /^Using / + || /^Welcome / || /^Wrote /|| /^cd /|| /^gs / + ) { + } + else { + warn "==Message from asy: $_"; + } + } + close $FH; +# 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 new file mode 100644 index 0000000000..53f13ff30a --- /dev/null +++ b/support/latexmk/example_rcfiles/bib2gls_latexmkrc @@ -0,0 +1,35 @@ +# 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'; + +add_cus_dep('aux', 'glstex', 0, 'run_bib2gls'); + +sub run_bib2gls { + if ( $silent ) { + my $ret = system "bib2gls --silent --group '$_[0]'"; + } else { + my $ret = system "bib2gls --group '$_[0]'"; + }; + + my ($base, $path) = fileparse( $_[0] ); + if ($path && -e "$base.glstex") { + rename "$base.glstex", "$path$base.glstex"; + } + + # Analyze log file. + local *LOG; + $LOG = "$_[0].glg"; + if (!$ret && -e $LOG) { + open LOG, "<$LOG"; + while () { + if (/^Reading (.*\.bib)\s$/) { + rdb_ensure_file( $rule, $1 ); + } + } + close LOG; + } + return $ret; +} diff --git a/support/latexmk/example_rcfiles/clean_pattern_latexmkrc b/support/latexmk/example_rcfiles/clean_pattern_latexmkrc new file mode 100644 index 0000000000..b15507c623 --- /dev/null +++ b/support/latexmk/example_rcfiles/clean_pattern_latexmkrc @@ -0,0 +1,30 @@ +# To allow more general pattern in $clean_ext instead of just an +# extension or something containing %R. +# This is done by overriding latexmk's cleanup1 subroutine. + +# Here is an example of a usefule application: +$clean_ext = "*-eps-converted-to.pdf"; + +sub cleanup1 { + # Usage: cleanup1( directory, pattern_or_ext_without_period, ... ) + # + # The directory is a fixed name, so I must escape any glob metacharacters + # in it: + print "========= MODIFIED cleanup1 cw latexmk v. 4.39 and earlier\n"; + my $dir = fix_pattern( shift ); + + # Change extensions to glob patterns + foreach (@_) { + # If specified pattern is pure extension, without period, + # wildcard character (?, *) or %R, + # then prepend it with directory/root_filename and period to + # make a full file specification + # Else leave the pattern as is, to be used by glob. + # New feature: pattern is unchanged if it contains ., *, ? + (my $name = (/%R/ || /[\*\.\?]/) ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/; + unlink_or_move( glob( "$name" ) ); + } +} #END cleanup1 + + + diff --git a/support/latexmk/example_rcfiles/exceltex1.sty b/support/latexmk/example_rcfiles/exceltex1.sty new file mode 100644 index 0000000000..270f94d818 --- /dev/null +++ b/support/latexmk/example_rcfiles/exceltex1.sty @@ -0,0 +1,74 @@ +%% THIS IS A MODIFICATION BY JOHN COLLINS 30 Apr 2013 OF V. 0.5.1 OF +%% exceltex.sty TO HELP latexmk. +%% The modification consists of changing the calls to the +%% \InputIfFileExists macro to a call to a new macro that provides a +%% warning message when the file to be read does not exist. + +% get data from excel files into LaTeX +% +% (c) 2004-2006 by Hans-Peter Doerr +% 2013 John Collins +% +% exceltex is free software. you can redistribute or modify it under +% the terms of the GNU GENERAL PUBLIC LICENSE Version 2. See COPYING for +% details. +% +\def\exceltexVersion{0.5.1JCC} +% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{exceltex1}[2013/04/30 v.\exceltexVersion] +\DeclareOption{cellrefs}{\def\cellrefs{1}} +\ProcessOptions +% +\typeout{This is exceltex v\exceltexVersion} +% ulem needs option normalem for not breaking \em and \emph +\RequirePackage[normalem]{ulem} +\RequirePackage{color} +%\RequirePackage{eurosym} +% + +%% JCC's addition: +\providecommand\InputFileOrMessage[3]{% + \InputIfFileExists{#1}% + {#2}% + {#3\PackageWarning{exceltex1}{File `#1' not found.}}% +} +%% + +\newcounter{exceltexCounterC}\setcounter{exceltexCounterC}{0} +\newcounter{exceltexCounterT}\setcounter{exceltexCounterT}{0} +% +\immediate\openout 10=\jobname.excltx +% +% +% write index header +\ifx\cellrefs\undefined +% +\else +\immediate\write 10{;cellrefs} +\fi +\immediate\write 10{;created by exceltex v. \exceltexVersion} +% +\newcommand{\inccell}[1]{% + \stepcounter{exceltexCounterC}% + \ifx\cellrefs\undefined% + \immediate\write 10{c:\theexceltexCounterC:#1}% + \InputFileOrMessage{\jobname-excltx/c-\theexceltexCounterC}{}{}% + \else + \immediate\write 10{c:#1}% + \InputFileOrMessage{\jobname-excltx/c-#1}{}{}% + \fi +}% +% +% +\newcommand{\inctab}[1]{% + \stepcounter{exceltexCounterT}% + \ifx\cellrefs\undefined% + \immediate\write 10{t:\theexceltexCounterT:#1}% + \InputFileOrMessage{\jobname-excltx/t-\theexceltexCounterT}{}{\\}% + \else + \immediate\write 10{t:#1}% + \InputFileOrMessage{\jobname-excltx/t-#1}{}{\\}% + \fi +}% +\endinput diff --git a/support/latexmk/example_rcfiles/exceltex_latexmkrc b/support/latexmk/example_rcfiles/exceltex_latexmkrc new file mode 100644 index 0000000000..e1cf68424f --- /dev/null +++ b/support/latexmk/example_rcfiles/exceltex_latexmkrc @@ -0,0 +1,64 @@ +# This shows how to use the exceltex package with latexmk +# +# Exceltex is a package that enables LaTeX documents to use data from +# Excel spreadsheets. It has two parts: a LaTeX package in a file +# named exceltex.sty and a (Perl) script named exceltex. The custom +# dependency given below enables latexmk to call the exceltex script +# whenever appropriate. +# +# The functioning is as follows: The main tex file uses the package +# exceltex to specify the use of the contents of cells in an xls +# spreadsheet. It does this by writing a specification of the cells to +# a file with extension excltx. The script exceltex reads this, +# extracts the data from the spreadsheet(s), and writes them in files +# that are read during the next compilation of the main document. (The +# exceltex package, with its script, is part of the current version of +# TeXLive, as of 2012.) +# +# In addition to running the exceltex script, the subroutine defined +# below also reads the excltx file to find the names of the +# spreadsheet files used. It then uses an internal subroutine of +# latexmk to add these files to the source-file list of the custom +# dependency. Thus if the spreadsheet file (or files) changes, even +# without any other changes, latexmk will know to rerun exceltex and +# then recompile the main tex file if necessary. +# +# Notes: +# 1. See +# http://tex.stackexchange.com/questions/107764/exceltex-dependencies-in-latexmk +# for the motivation, and see the exceltex documentation for an +# example of the use of the exceltex package. +# 2. You may find you need to install certain Perl modules in +# order for the exceltex script to work; these modules are needed +# for parsing excel spreadsheets. You'll need to examine +# documentation for Perl to find out how to do this. + + +add_cus_dep('excltx', 'tex', 0, 'excel2tex'); +sub excel2tex { + # This subroutine is a fudge, because it from latexmk's point of + # view, it makes the main .tex file depend on the .excltx file. + # But it doesn't actually make the .tex file, but is used for its + # side effects in creating other files. The dependence is a way + # of triggering the rule to be run whenever the .excltx file + # 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 %xls = (); + my $source = "$_[0].excltx"; + if (! open $Hsource, "<$source") { + warn "excel2tex subroutine: Could not read '$source'\n"; + return 1; + } + while ( <$Hsource> ) { + if ( /^\s*;/ ) { next; } + if ( /^\s*[ct]:[^:]*\:([^!]*)!/ ) { $xls{$1} = 1; } + } + close $Hsource; + foreach (keys %xls) { + rdb_ensure_file( $rule, $_ ); + } + return system("exceltex \"$_[0]\"") ; +} + diff --git a/support/latexmk/example_rcfiles/fix-aux.latexmkrc b/support/latexmk/example_rcfiles/fix-aux.latexmkrc new file mode 100644 index 0000000000..9b01210a14 --- /dev/null +++ b/support/latexmk/example_rcfiles/fix-aux.latexmkrc @@ -0,0 +1,96 @@ +# This shows how to implement the use of 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. + # This subroutine is called to do a compilation by one of latex, pdflatex, + # etc. It's arguments are the command name, and the command-line arguments, + # including possible uses of the options -aux-directory, -output-directory. + # Functioning: + # 1. Obtain the values of the aux and output directories from the options + # on the command line, with appropriate defaults if one or both options + # is not used. + # 2. Change the command line (a) to avoid the use of the -aux-directory + # option, and (b) to use the -output-directory to get all output + # sent to the intended aux-directory. If neither an -aux-directory + # nor an -output-directory option is used, no change is made to the + # command line. + # 3. Run the command. + # 4. If the aux and output directories are different, move any of the dvi, + # fls, ps and pdf files that are present in the intended aux directory + # to the intended output directory. + # N.B. It might seem more appropriate to keep the fls file in the aux + # directory. But MiKTeX puts it in the output directory, so we must do + # the same to copy its behavior. + # It might also seem appropriate for an xdv file to go in the output + # directory, like a dvi file. But xelatex under MiKTeX puts it in the + # aux directory, so we must copy that behavior. + + # Determine aux and output directories from command line: + my $auxD = ''; + my $outD = ''; + foreach (@_) { + if ( /^-{1,2}aux-directory=(.*)$/ ) { + $auxD = $1; + } + elsif ( /^-{1,2}output-directory=(.*)$/ ) { + $outD = $1; + } + } + if ( $outD eq '' ) { $outD = '.'; } + if ( $auxD eq '' ) { $auxD = $outD; } + +# Construct modified command line, with at most one occurrence of -output-directory + my @args_act = (); + my $set_outD = 0; + foreach (@_) { + if ( /^-{1,2}(aux|output)-directory=.*$/ ) { + if ( ! $set_outD ) { + push @args_act, "-output-directory=$auxD"; + $set_outD = 1; + } + } + else { + push @args_act, $_; + } + } + +# Construct strings for aux and output directories that are suitable +# for prepending to a file name, so that they have any necessary +# directory separators: + my $outD1 = $outD; + my $auxD1 = $auxD; + foreach ( $auxD1, $outD1 ) { + # Append directory separator '/', but only for a non-empty name + # that isn't simple an MSWin drive name. + if ( ($_ ne '') && ! m([\\/\:]$) ) { + $_ .= '/'; + } + # Clean up by removing any sequence of './'. These refer to + # current directory. + 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/support/latexmk/example_rcfiles/glossary_latexmkrc b/support/latexmk/example_rcfiles/glossary_latexmkrc new file mode 100644 index 0000000000..2c15e9aac6 --- /dev/null +++ b/support/latexmk/example_rcfiles/glossary_latexmkrc @@ -0,0 +1,39 @@ +# 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: + + 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'"; + } + + +# 2. If you use the OBSOLETE glossary package, then you can do + + add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' ); + sub makeglo2gls { + system("makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" ); + } + +# 2. If you use the OBSOLETE glossary package, then you can do +# the following for acronyms: + + # 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\"" ); + } + +# ===> 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/support/latexmk/example_rcfiles/lualatex_latexmkrc b/support/latexmk/example_rcfiles/lualatex_latexmkrc new file mode 100644 index 0000000000..dd36ddf002 --- /dev/null +++ b/support/latexmk/example_rcfiles/lualatex_latexmkrc @@ -0,0 +1,11 @@ +# This shows how to use lualatex (http://en.wikipedia.org/wiki/LuaTeX) +# with latexmk. +# +# WARNING: The method shown here is suitable only for ver. 4.51 and +# later of latexmk, not for earlier versions. +# + +$pdf_mode = 4; +$postscript_mode = $dvi_mode = 0; + + diff --git a/support/latexmk/example_rcfiles/mpost_latexmkrc b/support/latexmk/example_rcfiles/mpost_latexmkrc new file mode 100644 index 0000000000..c1b3e13d4f --- /dev/null +++ b/support/latexmk/example_rcfiles/mpost_latexmkrc @@ -0,0 +1,28 @@ +# N.B. ===> (3, 4 Mar 2014) This file contains a correction relative to +# the previous version + +# This shows how to use mpost, as used by the feynmp package. +# The feynmp package writes files with extension .mp, e.g., foo.mp, +# and these are to be converted by mpost to make postscript files, +# e.g., foo.1, which are later read in by dvips. +# +# A more complicated custom dependency is needed than normal, because: +# if the output directory ($out_dir) or the auxiliary directory +# ($aux_dir) is set, mpost doesn't put its output in the correct +# place. + +add_cus_dep( 'mp', '1', 0, 'mpost' ); + + +sub mpost { + my $file = $_[0]; + my ($name, $path) = fileparse( $file ); + my $return = system "mpost \"$file\""; + # Fix the problem that mpost puts its output and log files + # in the current directory, not in the auxiliary directory + # (which is often the same as the output directory): + move "$name.1", $path; + move "$name.log", $aux_dir; + return $return; +} + diff --git a/support/latexmk/example_rcfiles/nomenclature_latexmkrc b/support/latexmk/example_rcfiles/nomenclature_latexmkrc new file mode 100644 index 0000000000..4c6817c9a8 --- /dev/null +++ b/support/latexmk/example_rcfiles/nomenclature_latexmkrc @@ -0,0 +1,9 @@ +# This shows how to use the nomencl package for making a nomenclature +# with latexmk. +# (See http://www.ctan.org/pkg/nomencl for information on the nomencl package.) + + +add_cus_dep("nlo", "nls", 0, "nlo2nls"); +sub nlo2nls { + system("makeindex $_[0].nlo -s nomencl.ist -o $_[0].nls -t $_[0].nlg"); +} diff --git a/support/latexmk/example_rcfiles/pdflatexmkrc b/support/latexmk/example_rcfiles/pdflatexmkrc new file mode 100644 index 0000000000..6f43e982ec --- /dev/null +++ b/support/latexmk/example_rcfiles/pdflatexmkrc @@ -0,0 +1,77 @@ +# Use of glossaries, extra indexes, epstopdf, and other images conversions +# Thanks to Herb Schulz + + +$pdflatex = 'pdflatex --shell-escape %O %S'; + +# Custom dependency for glossary/glossaries package +# if you make custom glossaries you may have to add items to the @cus_dep_list and corresponding sub-routines +add_cus_dep( 'glo', 'gls', 0, 'makeglo2gls' ); +sub makeglo2gls { + system( "makeindex -s \"$_[0].ist\" -t \"$_[0].glg\" -o \"$_[0].gls\" \"$_[0].glo\"" ); +} +# The glossaries package, with the [acronym] option, produces a .acn file when processed with (xe/pdf)latex and +# then makeindex to process the .acn into .acr and finally runs of (xe/pdf)latex to read in the .acr file. Unfortunately +# the glossary package does just the reverse; i.e. (xe/pdf)latex processing produces a .acr files and makeindex then +# is used to convert the .acr file to a .acn file which is then ... . This dependency assumes the glossaries package. +add_cus_dep( 'acn', 'acr', 0, 'makeacn2acr' ); +sub makeacn2acr { + system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acr\" \"$_[0].acn\"" ); +} +# for glossary package (Sigh...) --- they can co-exist! +add_cus_dep( 'acr', 'acn', 0, 'makeacr2acn' ); +sub makeacr2acn { + system( "makeindex -s \"$_[0].ist\" -t \"$_[0].alg\" -o \"$_[0].acn\" \"$_[0].acr\"" ); +} +# example of an added custom glossary type that is used in some of the glossary/glossaries example files: +# this is for the new glossary type command \newglossary[nlg]{notation}{not}{ntn}{Notation} from the glossaries package +# NOTE: the glossary package uses a very different command: the and +# are reversed in the calling sequence :-( +add_cus_dep( 'ntn', 'not', 0, 'makentn2not' ); +sub makentn2not { + system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].not\" \"$_[0].ntn\"" ); +} +# for the glossary package (Sigh...) --- they can co-exist! +add_cus_dep( 'not', 'ntn', 0, 'makenot2ntn' ); +sub makenot2ntn { + system("makeindex -s \"$_[0].ist\" -t \"$_[0].nlg\" -o \"$_[0].ntn\" \"$_[0].not\"" ); +} + +# dependencies for custom indexes using the index package +# examples for sample.tex for index package: + add_cus_dep( 'adx', 'and', 0, 'makeadx2and' ); +sub makeadx2and { + system( "makeindex -o \"$_[0].and\" \"$_[0].adx\"" ); +} +add_cus_dep( 'ndx', 'nnd', 0, 'makendx2nnd' ); +sub makendx2nnd { + system( "makeindex -o \"$_[0].nnd\" \"$_[0].ndx\"" ); +} +add_cus_dep( 'ldx', 'lnd', 0, 'makeldx2lnd' ); +sub makeldx2lnd { + system( "makeindex -o \"$_[0].lnd\" \"$_[0].ldx\"" ); +} + +# Custom dependency and function for nomencl package +add_cus_dep( 'nlo', 'nls', 0, 'makenlo2nls' ); +sub makenlo2nls { + system( "makeindex -s nomencl.ist -o \"$_[0].nls\" \"$_[0].nlo\"" ); +} + +# Custom dependency and function(s) for epstopdf package + +# FOR USERS OF epstopf v1.4 and before: should also work with v1.5 and later +# note: you may get extras runs if you use the .eps extension in the \includgraphics command +# deletes an outdated pdf-image, and triggers a pdflatex-run +add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_delete_dest' ); + +# FOR USERS OF epstopdf v1.5 and later only: +# load it as \usepackage[update,prepend]{epstopdf} +# detects an outdated pdf-image, and triggers a pdflatex-run +#add_cus_dep( 'eps', 'pdf', 0, 'cus_dep_require_primary_run' ); + +# Custom dependecy to convert tif to png +add_cus_dep( 'tif', 'png', 0, 'maketif2png' ); +sub maketif2png { + system( "convert \"$_[0].tif\" \"$_[0].png\"" ); +} diff --git a/support/latexmk/example_rcfiles/pythontex-latexmkrc b/support/latexmk/example_rcfiles/pythontex-latexmkrc new file mode 100644 index 0000000000..ba02de3ee7 --- /dev/null +++ b/support/latexmk/example_rcfiles/pythontex-latexmkrc @@ -0,0 +1,39 @@ +# 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. 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/* 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 ]; + +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/support/latexmk/example_rcfiles/sagetex_latexmkrc b/support/latexmk/example_rcfiles/sagetex_latexmkrc new file mode 100644 index 0000000000..a97702a9c7 --- /dev/null +++ b/support/latexmk/example_rcfiles/sagetex_latexmkrc @@ -0,0 +1,21 @@ +# This is to allow the use of sagetex package +# (http://www.ctan.org/pkg/sagetex) +# with latexmk. Sagetex outputs a file with the extension .sage. +# This file is to be processed by sage software (http://sagemath.org) +# to make a file with extension .sout. This file is then read in by +# sagetex during a later run of (pdf)latex. +# +# This can be done by normal custom dependency. However the .sage +# contains unimportant information about line numbers for error +# reporting. It is useful not to rerun sage if this is the only +# information that has changed in the .sage file. So the +# hash_calc_ignore_pattern variable is used to configure latexmk to +# ignore this lines when computing whether the .sage file has +# changed. + + +add_cus_dep( 'sage', 'sout', 0, 'makesout' ); +$hash_calc_ignore_pattern{'sage'} = '^( _st_.goboom|print .SageT)'; +sub makesout { + system( "sage \"$_[0].sage\"" ); +} diff --git a/support/latexmk/example_rcfiles/splitindex.latexmkrc b/support/latexmk/example_rcfiles/splitindex.latexmkrc new file mode 100644 index 0000000000..4509538dd7 --- /dev/null +++ b/support/latexmk/example_rcfiles/splitindex.latexmkrc @@ -0,0 +1,29 @@ +$clean_ext .= " %R-*.ind %R-*.idx %R-*.ilg %R-*.ind"; + +$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 + # make corresponding .ind files. + # However, it is possible that the document uses the splitindex + # package, but in a way compatible with the standard methods + # compatible with makeindex, i.e., with a single index and with the + # use of the \printindex command. + # 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, 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 + # input file that are in an incorrect format; they are simply + # ignored. So no problem is caused by lines in the .idx file + # that are generated by splitindex in a format incompatible with + # makeindex. + my $ret1 = system( "makeindex", $$Psource ); + my $ret2 = system( "splitindex", $$Psource ); + return $ret1 || $ret2; +} + diff --git a/support/latexmk/example_rcfiles/sweave_latexmkrc b/support/latexmk/example_rcfiles/sweave_latexmkrc new file mode 100644 index 0000000000..19f046be6b --- /dev/null +++ b/support/latexmk/example_rcfiles/sweave_latexmkrc @@ -0,0 +1,57 @@ +# This is to allow the use of Sweave with latexmk, and in addition to +# make synctex work properly with it. +# SEE THE IMPORTANT NOTES below. +# +# Sweave (http://www.stat.uni-muenchen.de/~leisch/Sweave/) is a tool +# that allows to embed the R code for complete data analyses in latex +# documents. The user edits a file with an extension like .Rnw, and +# the .tex file is generated from this. +# +# Four problems are solved by the code below: +# 1. Generate the .tex file automatically. +# 2. Arrange not to re-run unmodified chunks of R code. (A pure +# optimization.) +# 3. Fix the execution environment for (pdf)latex. +# 4. Deal with synctex: If the user wants to use synctex +# (www.tug.org/TUGboat/tb29-3/tb93laurens.pdf) to synchronize the +# pdf file with the source file, by default synctex does the +# synchronization with the generated .tex file, not the original +# source file. Postprocessing of the .synctex.gz file is necessary +# to fix this. +# +# The following version was worked out and tested by a user (thanks +# to Brian Beitzel) on MSWindows. It will need at least one change to +# work on UNIX-like operating systems (which include Linux and OS-X). + +# N.B. ===> IMPORTANT NOTES <=== +# +# 1. The patchDVI package for R needs to be installed from R-Forge, as +# follows: +# +# install.packages("patchDVI", repos="http://R-Forge.R-project.org") +# +# 2. In all Sweave (.Rnw) documents, the following lines must be included: +# +# \usepackage{Sweave} +# \SweaveOpts{concordance=TRUE} + + +# Fix the pdflatex command to run Sweave first, and to postprocess the +# .synctex.gz file: +# !!!!! THIS IS THE VERSION FOR MS-WINDOWS, with && as a command +# separator +$pdflatex = "cmd /c " + . "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); " + . "Sweave('%S', driver=cacheSweaveDriver)\"" + . " && R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex" + . " && Rscript -e " + . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\""; +# +# !!!TO FIX THIS FOR Linux/OS-X/UNIX, try uncommenting the following: +# (this version hasn't been tested). +#$pdflatex = "Rscript -e \"library(cacheSweave); setCacheDir(getwd()); " +# . "Sweave('%S', driver=cacheSweaveDriver)\"" +# . " ; R CMD pdflatex -interaction=nonstopmode -synctex=1 %O %B.tex" +# . " ; Rscript -e " +# . "\"library('patchDVI');patchSynctex('%B.synctex.gz')\""; + diff --git a/support/latexmk/example_rcfiles/tex4ht-latexmkrc b/support/latexmk/example_rcfiles/tex4ht-latexmkrc new file mode 100644 index 0000000000..de486d8d8b --- /dev/null +++ b/support/latexmk/example_rcfiles/tex4ht-latexmkrc @@ -0,0 +1,33 @@ +# Sometime in the future, latexmk will directly support the use of +# TeX4ht to obtain html from tex. Meanwhile, here is how to use +# latexmk with TeX4ht. There is a script htlatex supplied by the +# TeX4ht package: It simply runs latex a fixed number of times and +# then the programs tex4ht and t4ht. To use latexmk to get optimal +# processing use the following instructions (under UNIX-like operating +# systems, e.g., OS-X and linux): +# +# 1. Put the scripts htlatexonly and myhtlatex2 somewhere in the PATH +# for executables (and make sure they have excutable permissions +# set). +# 2. Set up an initialization file for latexmk like this one. +# +# 3. To process file.tex to make file.html, run +# +# myhtlatex2 file +# + +# Since these instructions use scripts that are UNIX shell scripts, +# the instructions work as written for UNIX-like operating +# systems. Users of other operating systems will have to adjust them +# and modify the scripts suitably. + + +warn "latexmkrc for htlatex\n"; + +$dvi_mode = 1; +$pdf_mode = 0; +$quote_filenames = 0; +$latex = 'htlatexonly %S'; + +$clean_ext .= ' 4ct 4tc idv lg tmp xref'; +$clean_full_ext .= ' css html'; diff --git a/support/latexmk/example_rcfiles/texinfo-latexmkrc b/support/latexmk/example_rcfiles/texinfo-latexmkrc new file mode 100644 index 0000000000..3a21a3c15d --- /dev/null +++ b/support/latexmk/example_rcfiles/texinfo-latexmkrc @@ -0,0 +1,76 @@ +# Modifications 2015 Sep 9-10, John Collins +# Copyright 2014 Vincent Belaïche + +# With the settings here, latexmk can be used to process texinfo files +# (typical extension .texi) to pdf files, including the making of +# indices. This version uses a newly documented internal routine +# of latexmk. + +###!!!!!!!!! NOTE THAT THE NAMES OF THE INDEX FILES ARE POSSIBLY +### SUBJECT TO CHANGE IN FUTURE VERSIONS OF texinfo. +### The configuration provided by this file was valid in +### September 2015. (The file texinfo.tex had version +### 2015-07-01.07.) + +$quote_filenames = 1; +$pdflatex = 'internal mylatex %R %Z pdftex %O %S'; +$latex = 'internal mylatex %R %Z etex %O %S'; + +sub mylatex { + my $root = shift; + my $dir_string = shift; + my $ret = system @_; + for my $ext (split " ",$texinfo_indices){ + my $idx = $dir_string.$root.'.'.$ext; + my $ind = $idx.'s'; + if ( (-e $idx) && (-s $idx) ) { + # Only make dependency on the ind-like file + # if the idx-like file both exists and is of + # non-zero length. The test on the length is + # needed because current versions of texindex + # produce no output file if the input file is + # of zero length. + rdb_ensure_file( $rule, $ind ); + } + } + return $ret; +} + +# Please add needed other extensions if there are other user defined indices +$texinfo_indices = 'ky fn cp vr tp pg'; + +$clean_ext .= ' ' . $texinfo_indices; +$clean_full_ext .= ' pdf toc aux'; + +for my $ext (split " ",$texinfo_indices){ + my $index_ext = $ext . 's'; + add_cus_dep( $ext, $index_ext, 1, $ext . '_texindex'); + add_input_ext('pdflatex', $index_ext); + add_input_ext('latex', $index_ext); + $clean_ext .= " $index_ext"; +} + +sub ky_texindex +{ + system( "texindex \"$_[0].ky\"" ); +} +sub fn_texindex +{ + system( "texindex \"$_[0].fn\"" ); +} +sub cp_texindex +{ + system( "texindex \"$_[0].cp\"" ); +} +sub vr_texindex +{ + system( "texindex \"$_[0].vr\"" ); +} +sub tp_texindex +{ + system( "texindex \"$_[0].tp\"" ); +} +sub pg_texindex +{ + system( "texindex \"$_[0].pg\"" ); +} diff --git a/support/latexmk/example_rcfiles/tikz-externalized-latexmkrc b/support/latexmk/example_rcfiles/tikz-externalized-latexmkrc new file mode 100644 index 0000000000..22ed6f7d38 --- /dev/null +++ b/support/latexmk/example_rcfiles/tikz-externalized-latexmkrc @@ -0,0 +1,75 @@ +# This shows how to deal with tikz when it is used in its externalized mode. +# +# Here is an example of a document that uses externalization. +# Externalization results in a .pdf file for each tikzpicture +# environment. +# +# \documentclass{article} +# \usepackage{tikz,pgfplots} +# \usetikzlibrary{external} +# \tikzexternalize[mode=list and make] +# +# \begin{document} +# \begin{tikzpicture} +# \begin{axis} +# \addplot coordinates {(1,1) (2,2) (3,5)}; +# \end{axis} +# \end{tikzpicture}% +# \end{document} + + +$clean_ext .= ' %R.figlist %R-figure* %R.makefile fls.tmp'; + +$latex = 'internal tikzlatex latex %B %O %S'; +$pdflatex = 'internal tikzlatex pdflatex %B %O %S'; +$lualatex = 'internal tikzlatex lualatex %B %O %S'; +$xelatex = 'internal tikzlatex xelatex %B %O %S'; + +$hash_calc_ignore_pattern{'pdf'} = '^(/CreationDate|/ModDate|/ID)'; +$hash_calc_ignore_pattern{'ps'} = '^%%CreationDate'; + +sub tikzlatex { + my ($engine, $base, @args) = @_; + my $ret = 0; + print "Tikzlatex: ===Running '$engine @args'...\n"; + $ret = system( $engine, @args ); + print "Tikzlatex: Fixing .fls file ...\n"; + system "echo INPUT \"$aux_dir1$base.figlist\" > \"$aux_dir1$base.fls.tmp\""; + system "echo INPUT \"$aux_dir1$base.makefile\" >> \"$aux_dir1$base.fls.tmp\""; + system "cat \"$aux_dir1$base.fls\" >> \"$aux_dir1$base.fls.tmp\""; + rename "$aux_dir1$base.fls.tmp", "$aux_dir1$base.fls"; + if ($ret) { return $ret; } + if ( -e "$aux_dir1$base.makefile" ) { + if ($engine eq 'xelatex') { + print "Tikzlatex: ---Correcting '$aux_dir1$base.makefile' made under xelatex\n"; + system( 'perl', '-i', '-p', '-e', 's/^\^\^I/\t/', "$aux_dir1$base.makefile" ); + } + elsif ($engine eq 'latex') { + print "Tikzlatex: ---Correcting '$aux_dir1$base.makefile' made under latex\n"; + system( 'perl', '-i', '-p', '-e', 's/\.epsi/\.ps/', "$aux_dir1$base.makefile" ); + } + print "Tikzlatex: ---Running 'make -f $aux_dir1$base.makefile' ...\n"; + if ($aux_dir) { + # latexmk has set $ENV{TEXINPUTS} in this case. + my $SAVETEXINPUTS = $ENV{TEXINPUTS}; + $ENV{TEXINPUTS} = good_cwd().$search_path_separator.$ENV{TEXINPUTS}; + pushd( $aux_dir ); + $ret = system "make", "-j", "5", "-f", "$base.makefile"; + &popd; + $ENV{TEXINPUTS} = $SAVETEXINPUTS; + } + else { + $ret = system "make", "-j", "5", "-f", "$base.makefile"; + } + if ($ret) { + print "Tikzlatex: !!!!!!!!!!!!!! Error from make !!!!!!!!! \n", + " The log files for making the figures '$aux_dir1$base-figure*.log'\n", + " may have information\n"; + } + } + else { + print "Tikzlatex: No '$aux_dir1$base.makefile', so I won't run make.\n"; + } + return $ret; +} + diff --git a/support/latexmk/example_rcfiles/xelatex_latexmkrc b/support/latexmk/example_rcfiles/xelatex_latexmkrc new file mode 100644 index 0000000000..4c1c8d9644 --- /dev/null +++ b/support/latexmk/example_rcfiles/xelatex_latexmkrc @@ -0,0 +1,13 @@ +# This shows how to use xelatex (http://en.wikipedia.org/wiki/XeTeX) +# with latexmk. Xelatex uses Unicode and "supporting modern font +# technologies such as OpenType or Apple Advanced Typography. +# +# WARNING: The method shown here is suitable only for ver. 4.51 and +# later of latexmk, not for earlier versions. +# +# + +$pdf_mode = 5; +$postscript_mode = $dvi_mode = 0; + + -- cgit v1.2.3