I am trying to write a Makefile for a LaTeX project which uses more than one .tex file. I was wondering, if it is possible to create several pdf's (or any other data format) for each .tex and link them in the end together to the main pdf in order to save time within the compilation process.

Excerpt from the current Makefile:

build/target.pdf: ./content/target.tex
    latexmk ./content/target.tex

In the content file there are several .tex files. Now I would like to do something similar to c-style Makefiles e.g:

BUILD_DIR = build
$(BUILD_DIR)/%.o: %.tex
    latexmk ./content/%.tex 

and then link again all the object files together

  • 2
    I do not understand the problem: if target.tex includes files, latexmk will automatically rebuild it as soon as any dependence (even the system files!) changes. If you are seeking separate compilations to speed up the build, that is generally not possible (there are exceptions, like the externalize library for TikZ) – Rmano Jul 21 at 17:11
  • 6
    concatenating pdf is quite hard (although there are tools that can do that) however in most documents the chapters are not independent so separate compilation is not possible anyway, page numbers or any cross references between chapters mean that a change in one chapter can change the typesetting of all the others – David Carlisle Jul 21 at 17:34
  • If you want to speed up the compilation while you are working on the document, i.e., a full output of all chapters is not required during editing, then you can use conditional compilation, see for example tex.stackexchange.com/questions/87010/…. – Marijn Jul 22 at 14:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.