# Bad page break with \newenvironment, \refstepcounter and hyperref

I tried to define some environment but came across bad page breaks sometimes. The minimal working example is as follows:

\documentclass[b5paper]{article}
\usepackage{hyperref} % page break is correct when removing this line

\newcounter{question}
\newenvironment{question}{\par\refstepcounter{question}\thequestion. }{}
% page break is correct when changing \refstepcounter to \stepcounter

\begin{document}

\fontsize{40pt}{50pt}\selectfont

\begin{question}111\end{question}
\begin{question}111\end{question}
\begin{question}111\end{question}

\begin{question}
If ... Then ... ( ).\par
(A) 11; (B) 22; (C) 33; (D) 44.
\end{question}

\begin{question}111\end{question}
\begin{question}111\end{question}
\begin{question}111\end{question}
\begin{question}111\end{question}
\begin{question}111\end{question}

\end{document}


The page break is correct when removing hyperref package, or changing \refstepcounter to \stepcounter. What is the problem with this example?

• Thanks for posting a very clear MWE. I can reproduce the problem behavior. Fortunately, it disappears if one loads the geometry package as well. – Mico Oct 3 '13 at 11:49
• @Mico geometry doesn't fix the issue it just changes the size a bit so makes the tipping point happen at a different place so makes the issue go from this example. – David Carlisle Oct 3 '13 at 12:12
• Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – jub0bs May 4 '14 at 12:34

## 1 Answer

Avoid putting specials in vmode

\newenvironment{question}{\par\mbox{}\refstepcounter{question}\thequestion. }{}