diff options
author | Karl Berry <karl@freefriends.org> | 2020-04-18 20:56:25 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-04-18 20:56:25 +0000 |
commit | 9f8c30ed2974bbc9b7661ad6be74ed06d7b58e24 (patch) | |
tree | cabbaa5d18fa1520942068020400bd29a7657498 /Master/texmf-dist/doc/support/latexmk/example_rcfiles | |
parent | 8520e46c50136c5a6160de5f7b8c7fb574821288 (diff) |
latexmk (18apr20)
git-svn-id: svn://tug.org/texlive/trunk@54786 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/support/latexmk/example_rcfiles')
4 files changed, 138 insertions, 27 deletions
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 5c757f5b43c..cd75f2d2d0f 100644 --- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/glossary_latexmkrc @@ -1,11 +1,9 @@ -# 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. +# 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 items -# 2 and 3 +# (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: @@ -21,22 +19,26 @@ } -# 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. +# 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/Master/texmf-dist/doc/support/latexmk/example_rcfiles/knitr-latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/knitr-latexmkrc new file mode 100644 index 00000000000..163d8999405 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/knitr-latexmkrc @@ -0,0 +1,100 @@ +# This code was provided by Michael Stewart, Feb. 2020. +# +# Knitr is a successor to Sweave (see sweave_latexmkrc) which allows the embedding +# of R code (and its output) into LaTeX files. A .Rnw file (including LaTeX code +# and R code) is "knitted" to produce a LaTeX file, which also includes the output +# obtained from running the R code. Knitr also works with other plain-text markup +# languages (e.g. Rmarkdown and brew) but they are not supported here. +# See https://yihui.org/knitr for more information. +# +# This latexmkrc file permits using knitr, allowing SyncTeX to work properly. +# It also works for a multiple-file project under one caveat: the "native" +# knitr child document inclusion method which uses chunks like +# +# <<child='child.Rnw'>>= +# @ +# +# is *not* used. Rather, each .Rnw file is "knitted" in a standalone fashion +# and the "inputting" is done purely at the LaTeX phase. +# +# Thus if we have a main document "main.Rnw" and a child document "child.Rnw" +# the successful workflow is: +# 0. put a line +# +# \input child.tex +# +# at the deisred location in main.Rnw; +# 1. knit('main.Rnw') # to produce main.tex (which inherits the \input line above); +# 2. knit('child.Rnw') # to produce child.tex; +# 3. pdflatex -synctex=1 main.tex; +# 4. patchSynctex('main.Rnw'); +# 5. patchSynctex('child.Rnw',syncfile='main'); +# All steps except 3. are R commands (note that the add-on R package "patchSynctex" +# needs to be installed); 3. is an ordinary shell command. +# +# The configuration below handles both single-file and multiple-file projects (using +# the workflow described above). + +# In the line below replace 'main.tex' with the name of the main *LaTeX* file. +# This line is optional for single-file projects; using it means that latexmk +# may be invoked without a filename, even if the file main.tex doesn't yet exist: +# +# $ latexmk +# +# If the line is not used, and the target LaTeX file does not yet exist, +# its name must be supplied, e.g.: +# +# $ latexmk main +# +# It is compulsory for multiple file projects, so we avoid running pdflatex +# on child documents. +@default_files=('main.tex'); + +$pdf_mode=1; + +# The definition of $pdflatex below runs pdflatex on the main LaTeX file +# and runs patchSynctex(...,syncfile='main') once for each .Rnw file appearing +# in the working directory: +$pdflatex = "pdflatex -interaction=nonstopmode -synctex=1 %O %B ;" + . "Rscript -e \"library(patchSynctex); " + . "Rnw.files=system(\\\"ls *.Rnw\\\",intern=T); " + . "Rnw.stems=unlist(strsplit(Rnw.files,split=\\\".Rnw\\\")); " + . "for (i in 1:length(Rnw.stems)) " + . "patchSynctex(Rnw.stems[i],syncfile=\\\"%B\\\",verbose=T)\" " ; + + +# The remaining code defines a custom dependency to ensure that each LaTeX file +# is updated whenever the corresponding .Rnw file is updated. See below for how +# to adapt this for use with Sweave instead of knitr. +add_cus_dep( 'Rnw', 'tex', 0 , 'knit' ); +sub knit { + system( "Rscript -e \"library(knitr); " + . "opts_knit\\\$set(concordance=T); " + . "knitr::knit(\\\"$_[0].Rnw\\\",output=\\\"$_[0].tex\\\")\" " ); +} + +# For use with Sweave (rather than knitr) make the following adjustments: +# +# 1. Ensure that +# +# \SweaveOpts{concordance=T} +# +# (possibly with other global options e.g. stylepath=T) appears near the top of each +# .Rnw file *after* \begin{document} (at the time of writing there seems to be a bug +# in Sweave() so that this is the only reliable way to pass the global +# concordance=T option; neither Sweave(...,concordance=T) nor # the setting of the +# SWEAVE_OPTIONS environment variable seems to work). +# +# 2. Replace the last 6 lines of code above this comment block with the commented-out +# code below: +# +#add_cus_dep( 'Rnw', 'tex', 0, 'Sweave'); +#sub Sweave { +# system("Rscript -e \"Sweave(\\\"$_[0].Rnw\\\")\" "); +#} + +# You will need to uncomment the two lines below if you are using this with a version +# of latexmk older than version 4.68: +#$force_mode=1; +#push @file_not_found, '^\\! I can\\\'t find file `([^\\\']*)\\\'\\.'; + diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pweave-latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pweave-latexmkrc new file mode 100644 index 00000000000..3e09bf06aa4 --- /dev/null +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pweave-latexmkrc @@ -0,0 +1,6 @@ +# How to use latexmk with pweave to generate tex file + +add_cus_dep('texw', 'tex', 0, 'pweave2tex'); +sub pweave2tex { + system("pweave -f tex \"$_[0].texw\""); +} diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/sweave_latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/sweave_latexmkrc index 19f046be6be..972dcda1003 100644 --- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/sweave_latexmkrc +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/sweave_latexmkrc @@ -25,12 +25,15 @@ # N.B. ===> IMPORTANT NOTES <=== # -# 1. The patchDVI package for R needs to be installed from R-Forge, as +# 1. See the comments in knitr-latexmkrc for an alternative and probably better +# way of using Sweave with latexmk +# +# 2. 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: +# 3. In all Sweave (.Rnw) documents, the following lines must be included: # # \usepackage{Sweave} # \SweaveOpts{concordance=TRUE} |