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?
3
  • 2
    For (1), see Repeat command n times?
    – Werner
    Dec 24, 2014 at 0:47
  • 3
    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. Dec 24, 2014 at 1:12
  • If you want to implement (2) yourself, wrap the body of rep in a toggle from the etoolbox package. Dec 24, 2014 at 1:24

1 Answer 1

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}
2
  • 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, 2014 at 21:28
  • 1
    Use Cygwin (cygwin.com). Dec 25, 2014 at 21:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .