diff options
Diffstat (limited to 'support/latexmk/example_rcfiles/fix-aux.latexmkrc')
-rw-r--r-- | support/latexmk/example_rcfiles/fix-aux.latexmkrc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/support/latexmk/example_rcfiles/fix-aux.latexmkrc b/support/latexmk/example_rcfiles/fix-aux.latexmkrc index 9b01210a14..aefa206d5a 100644 --- a/support/latexmk/example_rcfiles/fix-aux.latexmkrc +++ b/support/latexmk/example_rcfiles/fix-aux.latexmkrc @@ -28,8 +28,8 @@ sub latex_fix_aux { # 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. + # fls, pdf, ps and synctex.gz 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. @@ -37,6 +37,8 @@ sub latex_fix_aux { # directory, like a dvi file. But xelatex under MiKTeX puts it in the # aux directory, so we must copy that behavior. + my @move_exts = ('dvi', 'fls', 'pdf', 'ps', 'synctex.gz' ); + # Determine aux and output directories from command line: my $auxD = ''; my $outD = ''; @@ -85,9 +87,17 @@ sub latex_fix_aux { 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",; + print "Move @move_exts files from '$auxD' to '$outD'\n"; + # Use copy and unlink, not rename, since some viewers appear to keep the + # viewed file open. So if rename were used, such viewers would see the + # old version of the file, rather than the new one. With copy, the + # contents of the old file are normally overwritten by the new contents. + # + # In addition, copy works across file system boundaries, but rename + # doesn't. + foreach my $ext (@move_exts) { + copy "$auxD1$root_filename.$ext", "$outD1$root_filename.$ext"; + unlink "$auxD1$root_filename.$ext"; } } return $ret; |