# How to write a Makefile in Windows to compile a Latex document using a loop

I need to write several documents that are fairly close to each other, i.e.same structure of header/footer, call a common set of forms. I wrote a Main.tex document with a set of \if\x 1 { my document content}\fi to control the content of each document. My variable "x" is also used as information in the header.

Minimal example:

\documentclass[a4paper,10pt, ,landscape]{article}
\usepackage{fancyhdr}
\usepackage{lastpage}
%\newcommand\x{1}

\lfoot{\thepage\ ~of~\pageref{LastPage}}
\cfoot{}

\begin{document}
\if\x 1 {
\include{FrontPage}
\include{FormA}
\include{FormB}
\include{FormC}
}\fi

\if\x 2 {
\include{FrontPage}
\include{FormA}
\include{FormB}
\include{FormB}
}\fi

\if\x 3 {
\include{FrontPage}
\include{FromA}
\include{FromC}
\include{FormC}
}\fi
\end{document}


On Linux (Ubuntu), I wrote a makefile:

SHELL   = /bin/sh

all:
make tex
make clean

tex:
for number in 1 2 3; do \
done;\

help:
echo "USAGE: make [all/tex/clean]"

clean:
rm -f *.aux *.dvi *.idx *.ilg *.ind *.log *.nav *.out *.snm *.xdv *.toc *~


Which call my main.tex file 3 times, sending the value of x to my latex document, and also renaming the output. At the end I get 3 pdf. I only have to write "make" in the Konsole of Kile to make it work.

Unfortunately, I now have to transfer this process under Windows - Any idea on how to write the equivalent of my makefile in Windows ? I have TeXnicCenter and Texmaker installed.

• there are of course make implementations for windows, or you could write a loop in dos cmd syntax or use Lua (and the texlua that comes with tex) for a cross-platform alternative. – David Carlisle Nov 2 '17 at 17:42
• Might be useful: stackoverflow.com/questions/17158419/… – Andrew Nov 2 '17 at 18:35

FOR %%i IN (1,2,3) DO (