开发者

Avoiding the creation of .aux, .log and .synctex.gz files when using pdflatex [closed]

开发者 https://www.devze.com 2023-01-16 22:51 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

Closed 1 year ago.

Locked. This question and its answers are locked because the question is off-topic but has historica开发者_如何学编程l significance. It is not currently accepting new answers or interactions.

I just want to have a .tex file which I compile with pdflatex and end up with a .pdf file. I don't want all the other .aux, .log and .synctex.gz files. pdflatex doesn't seem to have arguments for this.


latexmk -c will remove the unnecessary files. latexmk is a great way to manage the compile too!


I always build my PDF files like this:

pdflatex -aux-directory=/some/temp/dir <additional options>

That way, I don't have too see all the additional files. Those files should not be removed, as they are important for cross referencing, bibliographies, table of contents etc. To run pdflatex several times and then remove the files takes too much time.

The -aux-directory unfortunately does not exist in the linux version of pdflatex. Tested on Ubuntu Lucid.


For people on Linux the equivalent to -aux-directory appears to be -output-directory, unfortunately it doesn't play nicely with \include{...} (included files' .aux files still get dumped in the current directory).

See also: the man page.


If anyone using TeXnicCenter has the same desire to only get a *.pdf file for the given *.tex file (no *.aux, *.bbl, *.blg and *.log files), here is a quick solution: Choose from the menu: Build | Define Output Profiles, copy the "LaTeX => PDF" profile to a new profile "LaTeX => PDF ONLY", then on the Postprocessor tab create four new postprocessors:

Name: delete *.XXX

Executable: "C:\WINDOWS\system32\cmd.exe"

Arguments: /C del "%bm.XXX"

Replace XXX with aux, bbl, blg, log, respectively.


For MikTeX:

texify -cp  file.tex

It will run pdflatex as many times as necessairy and clean temp files afterwards. Very useful.


A well crafted wrapper script seems to be the best answer. Something along these lines, which I've tested on Ubuntu using texlive-latex (pdftex 1.40.10) :

#!/bin/bash
TMPDIR=$(mktemp -d)
trap "rm -fr $TMPDIR; exit 255;" SIGINT SIGTERM SIGKILL

/usr/bin/latex -interaction=batchmode -output-directory=$TMPDIR $1
cp $TMPDIR/$1.dvi .
rm -fr $TMPDIR


IIRC \nofiles in your file suppresses the .aux output.


Write a shell-script wrapper which removes the files:

#!/bin/sh
pdflatex "$@" && rm -f *.aux *.log *.synctex.gz

Bonus-assignment: modifying the script to only remove the files actually created by pdflatex.


How are you creating/editing your LaTex document? If you are using Sublime Text 2, you can edit the project file to suppress opening the file types of your choosing. They will still be created upon compile but won't be loaded into your project, keeping them invisible.


Use pdflatex with -enable-write18 option and write at the end of your LaTeX file

\write18{del *.aux}
\write18{del *.log}
\write18{del *.gz}

or more pricise

\write18{del \jobname.aux}
\write18{del \jobname.log}
\write18{del \jobname.synctex.gz}
\write18{del \jobname.toc}
\write18{del \jobname.loc}

del is a DOS-function. Use rm for UNIX.

0

精彩评论

暂无评论...
验证码 换一张
取 消