0

The command \newpage does not begin a new page in mcexam. I need the \begin{mcquestioninstruction} to begin on the next page because it is orphaned from the questions that follow.

Update: \newpage is now inserted after the \begin{mcquestioninstruction} line. This does put the instruction on the next page as desired.

\documentclass[a4paper]{article}
\usepackage[output=exam
           ,numberofversions=2
           ,version=1
           ,seed=1
           ,randomizequestions=false
           ,randomizeanswers=true
           ,writeRfile=true
           ]{mcexam}
\usepackage{tikz,framed} 
\usepackage{fancyhdr,lastpage}
\usepackage{tcolorbox}
\tcbuselibrary{skins}
\usepackage{chemformula}
\usepackage{chemmacros}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{array}
\graphicspath{ {./images/} }
\hyphenpenalty=2000
\pagestyle{fancy}
\fancyhf{}
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{1pt}
\lfoot{\mctheversion}
\rfoot{Page \thepage\ of \pageref{LastPage}}
\usepackage{calc}
\renewenvironment{setmcquestion}{\begin{minipage}[t]{\linewidth-\labelwidth}}{\end{minipage}\par}

\begin{document} \mcifoutput{concept,exam}

\section*{} \begin{mcquestions} \question Question 1 \begin{mcanswerslist}[fixlast] \answer [correct] answer 1 \answer answer 2 \answer answer 3 \answer answer 4 \end{mcanswerslist} \begin{mcquestioninstruction} \newpage My instructions that must be at the top of the next page: \end{mcquestioninstruction} \question Question 2 \begin{mcanswerslist}%[fixlast] \answer answer 1 \answer answer 2 \answer answer 3 \answer answer 4 \end{mcanswerslist} \end{mcquestions} \end{document}

larryjb
  • 45
  • 5
  • 1
    Do you want Question 2 to be on the same page as Question 1? Or everything after \newpage is on a new page, hard to understand as you describe it as orphaned from the questions that follow. Moving \newpage within \begin{mcquestioninstruction} creates a new page but Question 2 is on it too, could you clarify please – JamesT Jun 21 '23 at 20:06
  • I am wanting Question 2 on the 2nd page after the \begin{mcquestioninstruction}. Your solution achieved what I needed. – larryjb Jun 21 '23 at 21:46
  • If you want to allow pagebreaks in some locations (between) but not others (inside), use more than one minipage. – John Kormylo Jun 22 '23 at 00:34

1 Answers1

2

you are inserting a minipage the only function of which is to prevent page breaking.

Comment out this line

%\renewenvironment{setmcquestion}{\begin{minipage}[t]{\linewidth-\labelwidth}}{\end{minipage}\par}  

enter image description here

David Carlisle
  • 757,742
  • Commenting out that line would work great except then the multiple choice responses can get split over a page break. – larryjb Jun 21 '23 at 20:27
  • @larryjby yes sure but you phased the question as \newpage not working in mcexam, but the package is not relevant here. it is "\newpage not working in minipage inserted by the document author" and since the only function of minipage here is to prevent page breaking, "don't use minipage " seems the natural answer. – David Carlisle Jun 21 '23 at 20:50
  • The use of minipage is from the original author of mcexam. (I removed the comments acknowledging the author Copyright (c) 2017 Jorre Vannieuwenhuyze to reduce the lines of code in my example.) I will need a way to keep questions/multiple responses together, yet allow page breaks within the lists of questions. – larryjb Jun 21 '23 at 20:56
  • 1
    your first line "The command \newpage does not begin a new page in mcexam. " is simply false. \newpage works in mcexam as I show here. It does not work (by design) in the minipage you do not mention but leave people to find in your code @larryjb – David Carlisle Jun 21 '23 at 21:06
  • try \renewenvironment{setmcquestion}{\samepage}{} @larryjb – David Carlisle Jun 21 '23 at 21:22
  • To clarify, this is not my code, I was not intending to "leave people to find" it. I now understand that the minipage environment is responsible for some of the effects I have been observing. I just need to find a way to work around it. I have left an e-mail with the original author to see if he knows a work-around. – larryjb Jun 21 '23 at 21:31