General ⇒ Batch compilation with incremented files
Batch compilation with incremented files
I'm a physics teacher and I'm using LaTeX for years, with Kile. Because of COVID, I'm having my students to do their exams from home. I have prepared 45 different graphs (graph1.pdf, graph2.pdf, graph3. pdf, etc) to be included in the exams. So exam1 will include graph1, exam2 will include graph2, etc. Questions are the same, and several questions with eventually other pictures (all pdf for quality) How can I bath-compile without doing everything manually? I searched google, but I didn't find a tip. Can anybody give me clue? Very appreciated!
I'm on Linux and Windows. Doesn't have to be with Kile, but I only know Kile and, a long time ago, TexNicCenter.
Thanks!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Batch compilation with incremented files
% master.tex \providecommand*{\RNo}{01} \documentclass{article} \usepackage{mwe} \begin{document} \section{Test image no. \RNo} \includegraphics[width=\textwidth,height=\textheight,page=\RNo]{example-image-letter-numbered} \end{document}
#! /bin/sh for n in {1..10} do printf -v RNo "%02d" $n pdflatex --jobname exam$RNo '\def\RNo{'$RNo'}\input master.tex' # add additional runs of pdflatex, makeindex, biber etc. here done
The
\providecommand*{\RNo}{01}
is used to make it possible to test the master file directly with No. 01.Something like the bash script can be implemented fpr each other script engine and even using texlua or tex itself. And you can use
\RNo
several times in you master, i. e., in filenames like graph\RNo.png
.
Batch compilation with incremented files
Sorry, I'm only an end user, but eager to learn!
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
Batch compilation with incremented files
chmod u+x doall.sh
. Then you can start a script like other applications from the file explorer. Personally I always use a terminal for running scripts, because then I can see the terminal output of the script. Note, depending on your system you have to run scripts from the local directory with
./doall.sh
instead of doall.sh
.And personally I would recommend to either delegate such a problem to someone with more experience in script programming or to read an instruction in bash programming / linux terminals. Better understanding of the command line is always useful (not only for linux users).

Batch compilation with incremented files
And with the [page=] option that I didn't know, I have no need to burst my figures file into different files. I'm saving hundreds of files...
Many thanks, and have a great day!