TransWikia.com

Question in a single page (keeping a consistent numbering and a good format)

TeX - LaTeX Asked by jrglez on February 28, 2021

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

2 Answers

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.

Answered by Peter Wilson on February 28, 2021

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}

Answered by Teepeemm on February 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP