1

Although a completely different question, this is a followup form this one

I am using the exercise package. There is an exercise consisting of multiple questions. I would like each of the questions to not be broken in separate pages. Often I have the beginning of the question at the end of one page, and the subQuestion appear in the next one.

I tried using minipage, but that resets the question numbers and the format does not look good.

\documentclass[14pt]{extarticle}
\usepackage{amsmath,exercise,multicol}

\begin{document}
\begin{Exercise}[label=Ex1]
You have 60 minutes to complete this part

\begin{minipage}[t]{\textwidth}
\Question {\textit{[2 marks]} Simplify the following expressions}
    \begin{multicols}{2}
    \subQuestion {$ 2 \times 3x + 5x \times 2 $}
    \subQuestion {$ 6y^2 \times 2y - 5y +y \times 2 $}
    \EndCurrentsubQuestion
    \end{multicols}
\EndCurrentQuestion
\end{minipage}

\begin{minipage}[t]{\textwidth}
\Question {\textit{[2 marks]} Evaluate the following expressions when $p=5$, $q=1$, $r=2$ and $s=-2$}
    \begin{multicols}{2}
    \subQuestion {$ \dfrac{3p+q}{r} $}
    \subQuestion {$ \dfrac{2q+r^2}{p-s^2} $}
    \EndCurrentsubQuestion
    \end{multicols}
\EndCurrentQuestion
\end{minipage}

\end{Exercise}
\end{document}

enter image description here

5
  • How does this differ from your previous question, which already has an answer?
    – Teepeemm
    Jul 1, 2020 at 17:24
  • @Teepeemm I was told I had to write a new question. They gave me a solution (the one written here), but this does not keep the numbering consistent. Apparently, wanting to keep the numbering consistent makes it a different question.
    – jrglez
    Jul 1, 2020 at 17:31
  • That can be a valid reason for a new question. In your case, it may have been useful for this one to link to the previous one and say what was wrong. As it was, I just saw both questions and thought you'd posted the same thing twice. (The other advantage is that now that there is a link from this one, both show up in the other's "Link" area in the right margin, so that people interested in the prior question can find this one.)
    – Teepeemm
    Jul 1, 2020 at 19:14
  • Maybe I need to stop using this package all together, because I just found this in the documentation: "The commands \Question, \subQuestion, etc. are heavily based on list environment. These lists are hidden (I know it’s bad!) to simplify the syntax of the source file (I think it’s nice!). In fact, every \Question is like the beginning of an environment, which is closed at the next \Question (the exact mechanism is a little bit more complicated). Consequently it’s dangerous to put questions inside environment. Of course, you can put entire exercise inside other environment (like minipage)"
    – jrglez
    Jul 6, 2020 at 8:53
  • It appears the author is thinking in terms of "exercises", not "questions" (although the main purpose of \EndQuestion is to be able to put questions in environments).
    – Teepeemm
    Jul 6, 2020 at 12:33

2 Answers 2

1

Not a complete answer but I think that it does improve the layout.

% questionpageprob.tex  SE 551903

\documentclass[14pt]{extarticle}
\usepackage{amsmath,exercise,multicol}

\begin{document}
\begin{Exercise}[label=Ex1]
You have 60 minutes to complete this part

\begin{minipage}[t]{\textwidth}
\Question {\textit{[2 marks]} Simplify the following expressions}
    \begin{multicols}{2}
    \subQuestion {$ 2 \times 3x + 5x \times 2 $}
    \subQuestion {$ 6y^2 \times 2y - 5y +y \times 2 $}
    \EndCurrentsubQuestion
    \end{multicols}
\EndCurrentQuestion
%\addtocounter{Question}{1}
\end{minipage}
%\addtocounter{Question}{1}
%\setcounter{Question}{2}

\vspace{\baselineskip}  %%% PW added

\begin{minipage}[t]{\textwidth}
%\addtocounter{Question}{1}
\Question {\textit{[2 marks]} Evaluate the following expressions when $p=5$, $q=1$, $r=2$ and $s=-2$}
\addtocounter{Question}{1}
    \begin{multicols}{2}
    \subQuestion {$ \dfrac{3p+q}{r} $}
    \subQuestion {$ \dfrac{2q+r^2}{p-s^2} $}
    \EndCurrentsubQuestion
    \end{multicols}
\EndCurrentQuestion
\end{minipage}

\end{Exercise}
\end{document}

I tried various methods to get the question numbering continuous as you can see from my MWE but none of them worked. Hopefully someone else will be able to help you with this.

1
  • 1
    Something is strange about the package. Even without the minipages, \EndCurrentQuestion causes the question counter to reset.
    – Teepeemm
    Jul 1, 2020 at 21:37
1

I don't entirely understand what the package is doing, so I'm not sure if I'm fixing a bug or just bashing it into pretending to work. But I can get the following to work. I'm also not sure how to get the vertical spacing to actually be correct, so there's a fair bit of manual vspacing. Also, minipage is trying to be indented, so I stopped that. (By the way, \Question only has an optional argument, so the outer braces in \Question {\textit{[2 marks]}} are at best superfluous.)

\documentclass{article}
\usepackage{amsmath,exercise,multicol}

\usepackage{etoolbox}
\makeatletter
\pretocmd{\Question}{\@echapqtrue}{}{}
\makeatother
\pretocmd{\EndCurrentQuestion}{\setcounter{savedQuestion}{\value{Question}}}{}{}

\begin{document}
\begin{Exercise}[label=Ex1]
You have 60 minutes to complete this part

\noindent
\begin{minipage}[t]{\textwidth}
\Question \textit{[2 marks]} Simplify the following expressions
    \begin{multicols}{2}\vspace{-\baselineskip}
    \subQuestion {$ 2 \times 3x + 5x \times 2 $}
    \subQuestion {$ 6y^2 \times 2y - 5y +y \times 2 $}
    \EndCurrentsubQuestion
    \end{multicols}
\EndCurrentQuestion
\end{minipage}

\vspace{\baselineskip}
\noindent
\begin{minipage}[t]{\textwidth}
\Question \textit{[2 marks]} Evaluate the following expressions when $p=5$, $q=1$, $r=2$ and $s=-2$
    \begin{multicols}{2}\vspace{-\baselineskip}
    \subQuestion {$ \dfrac{3p+q}{r} $}
    \subQuestion {$ \dfrac{2q+r^2}{p-s^2} $}
    \EndCurrentsubQuestion
    \end{multicols}
\EndCurrentQuestion
\end{minipage}

\end{Exercise}
\end{document}

You must log in to answer this question.

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