SCM

Forum: support

Monitor Forum | Start New Thread Start New Thread
RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Achim Zeileis on 2016-11-22 12:16
[forum:43715]
Yes, exactly!

The exams2pdf() function reads the template and replaces the placeholder

%% \exinput{exercises}

by

\input{exercise01}
\input{exercise02}
...

using the right number of exercises. And then the one resulting template is always recompiled with different exerciseXY.tex files present in the corresponding directory.

If you want to place something in between the \input{} statements you cannot use the placeholder "%% \exinput{exercises}" but you need to supply the \input{exercise...} directly. And thus you need to make sure that you include the correct number of exercises.

RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Sigbert Klinke on 2016-11-21 12:00
[forum:43712]
OK, I think I understand now. Using your "myex" it is equivalent to write in the template file myexam.tex:

%% \exinput{exercises}

or

\input{exercise01}
\input{exercise02}
\input{exercise03}
\input{exercise04}

I was a bit confused since in the temp directory xyz.Rnw and xyz.tex appeared and thought that for each run you generate a new template file which replaces %% \exinput{exercises} by the appropriate \input{xyz.tex}'s. But you just copy for each run the appropriate xyz.tex into exercise01.tex (and so on) and run the same template tex file again and again.

Thanks a lot Sigbert

RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Achim Zeileis on 2016-11-21 08:38
[forum:43711]
I think this can be done with the kind of template that I posted. In "myexam.tex" we have two sections with the questions each - and you would have 16 questions. Thus, you would start with \input{exercise01} and end with \input{exercise16}. My example template just uses different \section*{} in between the exercises but you can place any amount of information there.

To illustrate the random selection, I'm setting up a list of length 4: The first two list elements correspond to the two mathematics questions - the last two list elements correspond to the statistics questions.

myex <- list(
c("deriv2.Rnw", "hessian.Rnw"),
c("cholesky.Rnw", "dist3.Rnw"),
c("tstat2.Rnw", "ttest.Rnw"),
c("boxplots.Rnw", "scatterplot.Rnw")
)

And then I can produce the exam with

exams2pdf(myex, template = "myexam.tex")

The first exercise is then one of the two exercises about derivatives (deriv2 or hessian), the second one is one of cholesky or dist3 etc.

If you want to draw more than one exercise from a given list, you can also set the "nsamp" argument.

If this is also not what you need, send me your concrete example off-list. I'm fairly sure that the solution is not too difficult once I have understood what the issue is :-)

RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Sigbert Klinke on 2016-11-21 08:04
[forum:43710]
What I'am doing is the following: the exam consists of two parts, one part with ten theoretical questions, each selected from a set of questions from one topic. The same holds for the six questions of the applied part of the exam. I generate for each exam participant a separate exam, since they use a computer with internet connection to answer the applied questions. And I want to add a header and some specific instructions for the applied part.

RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Achim Zeileis on 2016-11-19 13:23
[forum:43709]
If the number of questions you select is always the same, then the approach that I posted can be used directly for that. If the number of questions will vary from exam to exam I would recommend to write a function that first generates the .tex template on the fly and then employs it with exams2pdf. (This is how exams2nops is implemented.)

If you want more concrete advice, please post some more information and an example what this should look like. Then I'll put together a short demo.

RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Sigbert Klinke on 2016-11-19 13:12
[forum:43708]
Well, actually I want to select some questions from a first set of questions then have for example a new section (maybe with additional text) and again select from a second set of questions.


RE: Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Achim Zeileis on 2016-11-17 22:58
[forum:43703]

myexam.tex (0) downloads
The easiest solution for this is to define "manually" where in the template the exercises should be included. Thus, instead of the placeholder

%% \exinput{exercises}

you can put explicit

\input{exercise1}, \input{exercise2}, ... statements anywhere you want in the .tex template. These will then contain the \begin{question} ... \end{question} statements etc. You only have to be careful about defining {question}/{solution} suitably or setting the counters appropriately.

The main disadvantage of that approach is that you have to hard-code in the template how many exercises there will be. Note also that if there are 10 or more exericeses, the names should be \input{exercise01}, \input{exercise02}, ...

Attached is an example template "myexam.tex" derived from "exam.tex" shipped in the package. This defines two sections with two questions each:

\section*{Mathematics}
\begin{enumerate}
\input{exercise1}
\input{exercise2}
\end{enumerate}

\newpage
\section*{Statistics}
\begin{enumerate}
\setcounter{enumi}{2}
\input{exercise3}
\input{exercise4}
\end{enumerate}

Note the \setcounter statement in the second {enumerate} environment that is needed for consecutive numbering to match the numbers on the title page.

To generate a PDF exam with this template, simply use:

exams2pdf(c("deriv2", "hessian", "tstat2", "ttest"), template = "myexam.tex")

Embed a plain LaTeX file between exercises is possible? [ reply ]
By: Sigbert Klinke on 2016-11-17 11:01
[forum:43693]
Hi,

since we have a bunch of exercises which we group in topics I need sections. Currently I'am using an "empty" exercises like

\begin{question}
\clearpage
\section{Deskriptive Statistik}
\end{question}

\begin{solution}
\end{solution}

Is there any other solution possible?

Thanks in advance

Sigbert

Thanks to:
Vienna University of Economics and Business University of Wisconsin - Madison Powered By FusionForge