0

Is there a way to add a tag to a LaTeX document? Something that allows one to omit it from mass compilation?

Say I have three .tex files, formulas, math-notes, and artwork.

Would there be a way to tag them as follows, for example,

formulas.tex -> math, graphics

math-notes.tex -> math

artwork.tex -> graphics

such that I could ask LaTeX (pdfLatex specifically) to compile only the documents with a certain tag? e.g. pdflatex --tag math .* would compile only the formulas and math-notes in that directory into one pdf.

I know you can do this manually by simply \includeing certain files in a new .tex file, but is there a way to automate this in a way that the command line LaTeX understands, so one could compile many files at once?

  • 1
    You might want to look at the multiaudience package, the audience can be set using \jobname to make it controllable from the command line. – Marcel Krüger Jul 01 '21 at 19:01
  • 1
    which files you latex isn't something you control from latex but from your comandline or IDE. for example if all your math-notes documents have notes as part of their filename then for i in *notes*.tex; do pdflatex "$i"; done would latex them all – David Carlisle Jul 01 '21 at 19:10
  • @DavidCarlisle even easier if latexmk is there latexmk -pdf *notes*.tex – daleif Jul 01 '21 at 19:17
  • @DavidCarlisleSimilar to how I tagged this stackexchange post so people could sort and find it, I'm sure you can tag PDFs. So, if it is at least possible in LaTeX, I would like to know how. Furthermore, understand that I want these to be compiled into one PDF, so LaTeX becomes more relevant. Ideally I would be able to selectively include documents (literally with the \include command), but any documents without the tag would not be included. Like I have some sort of \includetag{math} command. – KNOB Personal Jul 02 '21 at 11:13
  • @MarcelKrüger That looks exactly like what I was looking for. That's so funny how perfectly it matched my expectations. In cases like these, where the de facto answer is in a comment, what should I do? – KNOB Personal Jul 02 '21 at 11:19
  • @KNOBPersonal one way of resolving the question would be to close as a duplicate of a closely related one, such as https://tex.stackexchange.com/questions/359656/different-pdfs-from-one-tex-file/359696 or https://tex.stackexchange.com/questions/266117/1-compilation-several-outputs/266682. Another way would be to ask Marcel Krüger to write an answer here. A third option is to close this question with the custom reason 'solved in comments'. – Marijn Jul 02 '21 at 12:22

0 Answers0