0

I want to use the exam class for a project and have already learned that using multiple questions environments causes some problems. Therefore, I wanted to include everything inside of one questions environment. Now I got some problems with the resulting margins, which you can see using the following snippet:

\documentclass[]{exam}
\firstpageheadrule
\runningheadrule
\begin{document}
    \begin{questions}
        \section{Name}
        \question What is the value of $x$ in $x^2 = 4$?
        \section{Next Section}
        \question Bob has 2 apples, what is the temperature of the sun?
    \end{questions}
\end{document}

In general, I want the sections to align with the header rule. One solution would be that the number of the questions (main questions, not subquestions) is inside the margin so that the section and the text of the questions align with the rule. Another solution would be to shift the questions so that the number of the questions and the sections align, and both also align with the head rule. Sadly I am not able to create any of those solutions. Can you help me?

So far, I tried solutions with \fullwidth, EnvFullwidth and changing the hoffset/offsidemargin, but none of my attempts led to a satisfying solution.

4
  • \fullwidth{\section{Name}} aligns with the header rule (on the left). What was your problem iwth it? Commented Apr 11, 2023 at 11:45
  • I wanted a global and general solution, which does not need additional hacks, e.g. when using subsection, parts, or some different tex-stuff
    – Titanlord
    Commented Apr 11, 2023 at 11:51
  • Is there a way to globally define \fullwidth{}, because I get an error, if I put everything inside the document environment inside this command?
    – Titanlord
    Commented Apr 12, 2023 at 13:48
  • If you haven't started the questions environment, it isn't needed and would do nothing. You could try \newcommand{\fullwidth}[1]{#1}. Commented Apr 12, 2023 at 19:38

1 Answer 1

0

The exam class is mainly a fancy list. For more information see chapter 4.10 here. Thus, we can set common list length parameters for those list extensions. This resulted in a solution as follows:

\documentclass[]{exam}
\firstpageheadrule
\runningheadrule
% Here is the adaption:
\renewcommand{\questionshook}{%
    \setlength{\leftmargin}{0pt}%
}
\begin{document}
    \begin{questions}
        \section{Name}
        \question What is the value of $x$ in $x^2 = 4$?
        \section{Next Section}
        \question Bob has 2 apples, what is the temperature of the sun?
    \end{questions}
\end{document}

You must log in to answer this question.

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