diff options
author | Karl Berry <karl@freefriends.org> | 2018-10-25 21:35:08 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-10-25 21:35:08 +0000 |
commit | 2a876425edcfb3e967341ead41ad20733ee43dbc (patch) | |
tree | 44e407b693a5bad739413bcf36be2c7e96f801b9 /Master/texmf-dist/doc/support/latexmk/example_rcfiles | |
parent | 02aa0c181c36eb53c436478eeb878a070972ac16 (diff) |
latexmk (25oct18)
git-svn-id: svn://tug.org/texlive/trunk@48992 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/support/latexmk/example_rcfiles')
3 files changed, 144 insertions, 60 deletions
diff --git a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles index 84a274965f4..19690cf168b 100644 --- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/README-latexmk-rcfiles @@ -49,9 +49,18 @@ NOTES: 6. Further assistance for latexmk can be provided when style files provide suitable messages about missing files. See the - exceltex1.sty and pythontex1.sty files for examples of what is - needed. These files are modifications of exceltex.sty and - pythontex.sty that provide the necessary assistance. (The versions - were the ones current on 30 April 2013.) + 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/Master/texmf-dist/doc/support/latexmk/example_rcfiles/exceltex1.sty b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/exceltex1.sty new file mode 100644 index 00000000000..270f94d8186 --- /dev/null +++ b/Master/texmf-dist/doc/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 <doerr@cip.physik.uni-freiburg.de> +% 2013 John Collins <collins@phys.psu.edu> +% +% 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/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc index b2743c698a7..26d2a19a7aa 100644 --- a/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc +++ b/Master/texmf-dist/doc/support/latexmk/example_rcfiles/pythontex-latexmkrc @@ -1,66 +1,67 @@ -# This shows how to use the pythontex package with latexmk -# This **present** version (1 April 2018) it only works when -# the operating system and the file system support symbolic -# links (e.g., linux, OS-X and other unix implementations with their -# usual file systems). It is **not** tested on MS-Windows, but -# **may** work on recent versions. -# In the future, a version of latexmk may provide better support -# without the restrictions. - -# This version also has a restriction that on initial runs pythontex -# is not invoked. Later runs after a modification of the source -# file in the invoked python code do trigger the invocation of -# pythontex. The planned future enhancements of latexmk should -# remedy this. - -# This latexmkrc is an example of a style of configuration that may be -# useful for other packages. - -# This version has a fudge on the latex and pdflatex commands that -# allows the pythontex custom dependency to work even when $out_dir -# is used to set the output directory. Without the fudge (done by -# trickery with symbolic links) the custom dependency for using -# pythontex will not be detected. +# Support for pythontex in v. 0.16 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 +# pythontex program so that the files are deleted in a clean-up +# operation. +$clean_ext .= " pythontex-files-%R/*"; push @generated_exts, 'pytxcode'; -add_cus_dep('pytxcode', 'tex', 0, 'pythontex'); -$latex = 'internal mylatex %R %Z latex %O %S'; -$pdflatex = 'internal mylatex %R %Z pdflatex %O %S'; -$lualatex = 'internal mylatex %R %Z lualatex %O %S'; -$xelatex = 'internal mylatex %R %Z xelatex -no-pdf %O %S'; +$pythontex = 'pythontex %O %S'; -sub pythontex { - # This subroutine is a fudge, because it from latexmk's point of - # view, it makes the main .tex file depend on the .pytxcode 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 .pytxcode file - # changes, and to do this before running latex/pdflatex again. - return system("pythontex.py \"$_[0]\"") ; +foreach my $cmd ('latex', 'lualatex', 'pdflatex', 'xelatex' ) { + ${$cmd} = "internal latex_python %R %Y $cmd %O %S"; } -sub mylatex { +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 $code = "$root.pytxcode"; - my $result = "pythontex-files-$root"; - if ($dir_string) { - warn "mylatex: Making symlinks to fool cus_dep creation\n"; - unlink $code; - if (-l $result) { - unlink $result; - } - elsif (-d $result) { - unlink glob "$result/*"; - rmdir $result; - } - symlink $dir_string.$code, $code; - if ( ! -e $dir_string.$result ) { mkdir $dir_string.$result; } - symlink $dir_string.$result, $result; + 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\""; + } } - else { - foreach ($code, $result) { if (-l) { unlink; } } - } - return system @_; + return $ret; } + + |