跨页面打破 LaTeX 环境 - 聪明的方法
我正在使用 exercise 包在书。我重新定义了一些像这样的命令,它基本上在练习之前和之后添加了一些空间、一支铅笔和两个 hrule:
\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
现在这可以工作,但有一个小问题:
在某些情况下,只有 \hrule 最终位于底部一页,练习的其余部分在下一页。还有相反的行为:整个练习都在一页上,除了“endExerciseEnv”中的 \hrule 之外,它被刷新到下一页。
如何强制顶部 hrule 出现?
- 要么与练习的标题(标题,标题,无论什么)一起,并至少说 5em 左右的“练习文本”(这样看起来才不会难看),
- 或者与整个练习一起刷新?
底部 hrule 的类似问题:
如何强制它在 hrule 本身所在的可见页面前面至少有 5 em 的“练习文本”? (或练习环境的开始,以先到者为准 - 因为环境不高于 5em 时就是这种情况)
附录
我过去曾问过这样的 LaTeX 问题,我已经得到了答案这需要我手动做一些事情,比如“在这里和那里插入一个 \vskip”之类的。
让我澄清一下:这是一本书,有很多练习,我需要通过重新声明命令和命令的正确方法“自动”完成它。公司
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?
- either together with the header of the exercise (caption, title, whatever not) and at least say 5em or so of "exercise text" (so it doesn't look ugly),
- OR be flushed altogether, with the entire exercise?
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
TeX 可以在任何粘合之前插入分页符,例如
\vskip 1em
。进行一些更改:
1)您编写
\vskip 1em\hrule\vskip 1em
将其替换为
2) 您编写
\vskip .5em\hrule\vskip 1em
将其替换为
您还可以插入
\goodbreak
以显示打破页面的好点。这个好点可以在练习之前和之后插入。
1)
\goodbreak\vskip 1em\hrule \nobreak \vskip 1em
2)
\nobreak\vskip .5em\hrule \goodbreak \vskip 1em
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
2) You write
\vskip .5em\hrule\vskip 1em
Replace it with
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
向我自己致敬:https://ctan.org/pkg/needspace
Kudos to myself: https://ctan.org/pkg/needspace