LaTeX:仅在有足够空间时才显示块
LaTeX 爱好者和 TeX 程序员大家好!
我目前正在为某种应该自动生成的传单开发一个单页文档类。不幸的是,有限的空间无法在页面上显示所有内容,因此我需要完全跳过一些文章(我不希望只在传单上打印文章的一半)。
在伪代码中,这就是我正在寻找的命令:
\if_sufficient_vspace_left
{<big block/minipage with an article>}
{<otherwise do nothing or something else>}
用例是:
- 如果页面上有足够的垂直空间容纳下一篇文章,则完整打印该文章。否则,仅将标题添加到“其他文章”列表中。
- 如果剩余的垂直空间足够,则添加一个大广告,否则添加一个较小的广告或不执行任何操作。
我非常确定会有办法获得这个。例如,TeX 命令 \leaders
在垂直和水平模式下工作,仅在有足够空间时才插入前导符。不幸的是,我不想重复任何事情,而其他操作也可能很棒。
任何有用命令的关键字和提示将不胜感激。您不必发布完整的解决方案(但您当然可以)。
非常感谢,
克里斯托夫
Hi LaTeX enthusiasts and TeX programmers!
I'm currently developing a single-page document class for some kind of flyers which should be generated automatically. Unfortunately the limited amount of space doesn't make it possible to display everything on the page, so I need to skip some articles completely (I don't want only one half of a article printed on the flyer).
In pseudo code, thats the command I am looking for:
\if_sufficient_vspace_left
{<big block/minipage with an article>}
{<otherwise do nothing or something else>}
And the use cases are:
- If there is enough vertical space for the following article left on the page, print the article completely. Otherwise add only the headline to an »Other Articles« list.
- If there is enough vertical space left, add a big advertisement, otherwise add a smaller one or do nothing.
I am quite sure that there will be a way to obtain this. For example, the TeX command \leaders
, which works in vertical and horizontal mode, only inserts the leader if there is enough space left. Unfortunately I don't want to repeat anything, and an else action might be great too.
Any keywords and tips to useful commands will be appreciated. You don't have to post complete solutions (but you can of course).
Many thanks,
Christoph
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
“needspace”包可能会为您提供所需的内容,但如果空间不足,它会插入分页符:
http://ctan.org/pkg/needspace
您可以这样使用它:
如果您不想在空间不足时分页,而是想要更多内容,但保存了小型页面直到下一页,您将需要研究 LaTeX 如何处理“浮动”:
http:// /en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions
The 'needspace' package may give you what you're looking for, although if there is not enough space it inserts a pagebreak:
http://ctan.org/pkg/needspace
You would use it something like this:
If you don't want a page break when there isn't enough space, instead want more content but with the minipage saved until next page, then you will need to investigate how LaTeX handles "floats":
http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions