3

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?
cryingshadow
  • 2,350
hachemy
  • 263

1 Answers1

3

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}
cryingshadow
  • 2,350