I am using the exercise package to display exercises in a book. I have redefined some commands like this, which basically adds some space, a pencil, and two hrule's before and after the exercise:
\renewcommand{\ExerciseHeader}{\vskip 1em\hrule\vskip 1em\centerline{\textbf{\large\smallpencil
\ExerciseHeaderNB\ExerciseHeaderTitle%
\ExerciseHeaderDifficulty\ExerciseHeaderOrigin\medskip}}}
\makeatletter\def\endExerciseEnv{\termineliste{1}\@EndExeBox\vskip .5em\hrule\vskip 1em}\makeatother
Now this works, but there's a small problem:
There are situations where only the \hrule ends up being at the bottom of a page, and the rest of the exercise goes on the next page. There is also the opposite behavior: the entire exercise is on one page, except the \hrule in "endExerciseEnv", which is flushed to the next page.
How do I force the top hrule come?
A similar question for the bottom hrule:
How do I force it have at least 5 em of "exercise text" in front of it on the visible page where the hrule itself goes to? (or the beginning of the Exercise environment, whichever comes first - as it's the case if the environment is not higher than 5em)
Addendum
I have asked in the past LaTeX questions like this and I've got answers which required me to do stuff manually, like "insert a \vskip here and there" or such.
Let me be clear: This is a book, there are a lot of exercises, and I need it be done "automatically", by going the proper way of redeclaring commands & co.
TeX can insert page break before any glue, for example \vskip 1em
.
Make some changes:
1) You write \vskip 1em\hrule\vskip 1em
Replace it with
\vskip 1em\hrule \nobreak \vskip 1em
2) You write \vskip .5em\hrule\vskip 1em
Replace it with
\nobreak\vskip .5em\hrule\vskip 1em
You also can insert \goodbreak
to show good point to break the page.
This good point can be inserted before and after your excersise.
1) \goodbreak\vskip 1em\hrule \nobreak \vskip 1em
2) \nobreak\vskip .5em\hrule \goodbreak \vskip 1em
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With