# How to avoid the compilation of some of my newcommands in latex

I'm writing an exam for my students, and have defined 3 commands to insert spaces with \dotfill permitting them to write their responses: \rep,\replarge, \repLarge for short and large responses:

\newcommand{\rep}{\noindent \dotfill

\noindent\dotfill

\noindent\dotfill

\noindent\dotfill

}
\newcommand{\repshort}\rep \rep

\newcommand{\repLarge}\rep \rep \rep \rep


So, my questions are:

1. is there any way to ameliorate those commands?
2. how can I produce two pdf versions when compiling: One with the spaces produced with the commands, and the other without the spaces?
• For (1), see Repeat command n times? – Werner Dec 24 '14 at 0:47
• Before you implement too much on this, see if the exam class will suffice for any or all of your needs. Section 7 of the documentation shows several ways to leave space for answers, and section 8 covers printing solutions for a grading key or similar. – Mike Renfro Dec 24 '14 at 1:12
• If you want to implement (2) yourself, wrap the body of rep in a toggle from the etoolbox package. – Ethan Bolker Dec 24 '14 at 1:24

Here is one quick and dirty solution to the second question and a link to more advanced solutions (the comments above also contain useful links for both questions):

a) Create two main files where you (1) provide the commands with the spaces and (2) provide the same commands as empty commands (you can also just append something like \renewcommand{\rep}{} and comment this in or out).

OR

b) Use parameters for your document and use a Makefile. Look at the answers to Passing parameters to a document for some inspiration. Here is an example of how such a Makefile could look like and how your .tex file can make use of it:

Makefile:

default: Exercise.pdf Solution.pdf

Exercise.pdf: *.tex
-rm Exercise.pdf
pdflatex -file-line-error --jobname=Exercise '\def\isexercise{1} \input{main.tex}'
pdflatex -file-line-error --jobname=Exercise '\def\isexercise{1} \input{main.tex}'

Solution.pdf: *.tex
-rm Solution.pdf
pdflatex -file-line-error --jobname=Solution '\input{main.tex}'
pdflatex -file-line-error --jobname=Solution '\input{main.tex}'


main.tex:

\documentclass{article}

\newcommand{\rep}{}

\ifdefined\isexercise
\renewcommand{\rep}{
\noindent\dotfill

\noindent\dotfill

\noindent\dotfill

\noindent\dotfill
}
\fi

\begin{document}

Exercise 1: \rep

\end{document}

• Thank you Cryingshadow for the response, but I am a trully poor user of windows$, I think that the Makefile doesn't work with the windows$ system. – hachemy Dec 25 '14 at 21:28
• Use Cygwin (cygwin.com). – cryingshadow Dec 25 '14 at 21:46