summaryrefslogtreecommitdiff
path: root/support/latexmk/example_rcfiles/fix-aux.latexmkrc
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/latexmk/example_rcfiles/fix-aux.latexmkrc
Initial commit
Diffstat (limited to 'support/latexmk/example_rcfiles/fix-aux.latexmkrc')
-rw-r--r--support/latexmk/example_rcfiles/fix-aux.latexmkrc96
1 files changed, 96 insertions, 0 deletions
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;
+}
+
+#---------------------------