Well, the title is pretty much self-explanatory but for sake of clarity, I have latex paper with such structure:
.
├── back_matter
│ └── some_tex_files.tex
├── bibliography
│ └── bibliography.bib
├── body_matter
│ ├── a_file.tex
│ └── another_file.tex
├── graphics
│ └── some_images.png
├── styles
│ ├── bib_style.bbl
│ └── paper_style.cls
├── paper.tex
└── Makefile
And a Makefile
like so:
.PHONY: paper.pdf
all: paper.pdf
paper.pdf: paper.tex
latexmk -pdf -pdflatex="pdflatex -interactive=nonstopmode" -use-make paper.tex
clean:
latexmk -CA
make clean
successfully cleans all the auxiliary files in the root
(.
), however, it does not clean the auxiliary files created in the subdirectories. How to define a rule for cleaning all the .aux
files within the subfolders? I should mention that I use \input
to add the files to paper.tex
.
P.S. Is this make file well written?
Best Answer
If all the files in the subdirectories are input using
\input
, then there'll be no.aux
files in the subdirectories. You will only get such.aux
files if the running ofpdflatex
on some other file made them or if you used\include
at some point in the past instead of\input
. In any case, they are not part of the files involved in the current run ofpdflatex
, solatexmk
correctly does not delete them when you dolatexmk -CA
. On the other hand, if a file is brought into the document by\include
, then the corresponding.aux
file is involved in the document, andlatexmk -CA
will delete it.If you find some other behavior, we'll need a MWE to understand the problem.
As regards the
Makefile
, you should look at the section about this in thelatexmk
documentation. The relevant section "USING latexmk WITH make' is near the end of the documentation, and there are some options tolatexmk
that are useful. The important thing is that with a little care,make
can find all the dependency information thatlatexmk
computes.If your description of the project is complete, then a
Makefile
is unnecessary; the commandlatexmk
without any arguments will do what you need, particularly if there is only a single.tex
file in your root directory, and any configuration needed is in alatexmkrc
file. AMakefile
is normally needed only when there are other things you need it to do besides those thatlatexmk
is designed to do.For your case, a suitable
Makefile
isThis uses some special features of GNU make. Dependence information is kept in a subdirectory named
.deps
.