# Multiple Exams in One File

I need to create an exam which consists of two parts A and B. From these two parts, I need to create three versions: one which contains part A and B, one which only contains part A and one which only contains part B. Each version needs to have a custom title page, its own page and question numbering, and a point table.

What I would like to have in the end is a single PDF file of the following structure:

• title page for A + B (page no. 1)
• questions from A numbered 1 to n
• questions from B numbered n + 1 to m
• title page for A (restart page and question numbering, set point sum back to 0)
• questions from A numbered 1 to n
• title page for B (restart page and question numbering, set point sum back to 0)
• questions from B numbered 1 to m

Currently, I use the following approach: one file contains the questions from A; one file contains those from B. A master file includes these files and uses custom counters to restart the page/question numbering when appropriate. This works okay but it would be nice if I could use some of the features in the exam class (e.g. optionally show solutions, boxes for the answers relative to the page height). I am aware that these features can be implemented manually but this is time consuming and the result is probably less user-friendly than using a well-maintained, well-documented external package/class.

This, finally, brings me to my question: can this be achieved using the exam class (especially, having multiple point sums in one file) or a different package?

Edit: Using the answers from the question which is linked in the comments I was able to get pretty close to what I need. I now have three file:

a.tex:

\question A's first question
\begin{parts}
\part[1] part 1
\part[2] part 2
\part
\begin{subparts}
\subpart[1] 3a
\subpart[2] 3b
\end{subparts}
\end{parts}

\question[2] A's second question


b.tex:

\question B's first question
\begin{parts}
\part[2] part b1
\part[2] part b2
\end{parts}

\question[1] B's second question
\question[2] B's third question


main.tex:

    \documentclass[a5paper, addpoints]{exam}

\pointsinrightmargin

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}

\begin{document}
\begin{questions}
\uplevel{
% Title page for A + B
}

\input{a.tex}
\input{b.tex}
\clearpage
\setcounter{page}{1}

\uplevel{
% Title page for A
}
\input{a.tex}
\clearpage
\setcounter{page}{1}

\uplevel{
% Title page for B
}
\input{b.tex}
\clearpage
\end{questions}
\end{document}


Compiling main.tex creates three pages:

The first page is exactly how I want it to be. The question numbering - especially, in the grade table - on the second and third page, however, has to start with question 1 again.

I hope that this clarifies my question.

• A lot of requests for not providing a MWE to start with ;-) – user31729 Mar 6 '15 at 9:32
• Since A and B are completely independant, wouldn't it be much easier to simply merge the resulting pdfs? – Johannes_B Mar 6 '15 at 9:33
• @Johannes_B I don't tink so since he needs a sum of points – touhami Mar 6 '15 at 9:35
• see here it maybe helpful tex.stackexchange.com/questions/209504/… – touhami Mar 6 '15 at 9:37
• @JPW the second answer there doesn't do this? if not you shoud give a minimal code of what you have and what youneed. – touhami Mar 6 '15 at 12:20

Here is a solution

\documentclass[a5paper, addpoints]{exam}

\pointsinrightmargin

\usepackage[T1]{fontenc}
\usepackage[utf8x]{inputenc}
\usepackage[english]{babel}
%---------------------------------------------------
\newcounter{mtexo}
\newcommand{\setpart}{%
\setcounter{page}{1}\setcounter{mtexo}{0}%
\renewcommand{\thequestion}{\themtexo}}
%---------------------------------------------------
\begin{document}
\begin{questions}
%---------------------------------------------------
\let\mtquestion\question
\def\question{\refstepcounter{mtexo}\mtquestion}
%---------------------------------------------------
\uplevel{
% Title page for A + B
}

\input{a.tex}
\input{b.tex}
\clearpage
\setpart%\setcounter{page}{1}

\uplevel{
% Title page for A
}
\input{a.tex}
\clearpage
\setpart%\setcounter{page}{1}

\uplevel{
% Title page for B

• Redefining \thequestion indeed seems to do the trick. Thank you very much! – JPW Mar 9 '15 at 16:32
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.3753824532032013, "perplexity": 1425.55858526065}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-39/segments/1568514570740.10/warc/CC-MAIN-20190915052433-20190915074433-00099.warc.gz"}