如何定义一个不被表格和图形打断的多页环境?

发布于 2024-09-05 06:56:11 字数 587 浏览 4 评论 0原文

我在我正在编写的一本书章节中为游览定义了一个新的 LaTeX 环境。环境是多页的,并且通常包含内嵌图像。此外,我使用阴影环境为环境提供背景颜色,使其更加突出。

然而,如下所示,环境被浮动表格和图像分割,这使得环境的流动在视觉上更难以跟随。例如,现在很难看出浮动图像或表格是否是一部分(缺少背景颜色没有帮助)。因此,我喜欢扩展我的环境以禁止它被浮动元素中断,但不知道如何完成该操作。

\newcounter{bioclipse}
\def\thebioclipse{\thechapter-\arabic{bioclipse}}
\newenvironment{bioclipse}[2][]{\begin{small}\begin{shaded}\refstepcounter{bioclipse} \par\medskip\noindent%
   \textbf{Bioclipse Excursion~\thebioclipse #1: #2
   \vspace{0.1cm} \hrule \vspace{0.1cm}}
   \rmfamily}{\medskip \end{shaded}\end{small}}

任何禁止中断的解决方案都可以,即使背景颜色不同。

I have defined a new LaTeX environment for excursions in a book chapter I am writing. The environment is multipage and often includes inline images. Moreover, I am using the shaded environment to give the environment a background colour to make it stand out a bit.

However, the environment, as shown below, is split up by floating tables and images, which makes the flow of the environment visually more difficult to follow. For example, it is now difficult to see if that floating image or table is part (the missing background colour does not help). So, I like to extend my environment to disallow it to be interrupted by floating elements, but do not know how to get that done.

\newcounter{bioclipse}
\def\thebioclipse{\thechapter-\arabic{bioclipse}}
\newenvironment{bioclipse}[2][]{\begin{small}\begin{shaded}\refstepcounter{bioclipse} \par\medskip\noindent%
   \textbf{Bioclipse Excursion~\thebioclipse #1: #2
   \vspace{0.1cm} \hrule \vspace{0.1cm}}
   \rmfamily}{\medskip \end{shaded}\end{small}}

Any solution to disallow interruption is fine, even if the background colour is done differently.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骄兵必败 2024-09-12 06:56:11

插入的算法相当复杂。基本上,您希望任何挂起的插入都不能放入 env bioclipse 应用的页面中。作为第一个快速解决方案,您可以先刷新所有插入,然后开始新的章节。如果您想将数字或其他内容放入环境中,并且希望它们仅在环境正在工作的最后一页之后“刷新”...第二个快速解决方案是:直接将它们放在环境之后!所以他们根本不会“惹恼”页面(当然,避免使用脚注)。

另一种解决方案(使其自动)有点棘手。在输出例程中构建作为页面(“候选”)的垂直列表时,选择“待处理”材料的插入位置。这意味着您在最坏的情况下必须使用输出例程;但也许它太多了,除非你正在规划自己的 TeX 格式,也许 LaTeX 提供了更容易的选择...

深入研究 LaTeX 代码,我发现有一个条件你可以尝试使用,它是 \@insert*\@insertfalse\@inserttrue。如果你幸运的话,它们“驱动”插入的可能性,这样在你的环境的开头你可以说 \@insertfalse 并在最后说 \@inserttrue尝试,我并不是说它有效。

也许您知道使用 @ 作为字母 catcode,以便它可以成为“命令”名称的一部分,因此完成后您必须使用 \makeatletter\makeatother (可能默认的类/样式序言会为您完成)。

您还可以查看 placeins 样式(它可能已经在您的安装中,否则,参见此处 )这显然可以解决(部分)您的问题。

The algorithm for insertion is rather complex. Basically you want that any pending insertion must not be put into the page where the env bioclipse apply. As first fast solution you could flush all the insertion first, and then start the new chapter. If you want to put figures or whatever into the environment, and you want them to be "flushed" only after the last page where the env is at work... second fast solution is: put them after the environment directly!! So they won't "annoy" the page/s at all (of course, avoid using of footnotes).

The other solution (making it someway automatic) is a little bit tricky. Insertion places for "pending" materials are chosen while constructing the vertical list that is the page ("candidate"), in the output routine. This means you have to play with the output routine at worst; but maybe it is too much, unless you're planning your own TeX format, and maybe LaTeX gives easier choices...

Digging a bit in LaTeX codes, I see there's a conditional you can try to use, it is \@insert* i.e. \@insertfalse and \@inserttrue. If you're lucky they "drive" the possibility of putting insertions, so that at the beginning of your env you can say \@insertfalse and at the end \@inserttrue. Try, I am not saying it works.

As maybe you know to use @ as letter catcode so that it can be part of a "command" name, you have to use \makeatletter and \makeatother when you finished (likely default class/style preamble does it for you).

You could also be iterested in having a look at placeins style (it could be already in your installation, otherwise, see here ) which apparently could solve (part of) your problem.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文