我需要向一些文本示例中添加\caption
。例如:
Lorem Ipsum 只是印刷排版行业的虚拟文本。自 1500 年代以来,Lorem Ipsum 一直是该行业的标准虚拟文本,当时一位不知名的印刷师从印刷品中取出一页并将其打乱,制作成一本字体样本书。它不仅在五个世纪中存留下来,而且在电子排版时代也基本保持不变
例 1.乱数
但是,在这种情况下,标题类型是什么?显然没有\captionof{example}{Lorem Ipsum}
。我只能找到\captionof{figure}
和,\captionof{table}
但这非常有限。
答案1
如果您希望使用非默认的标题类型,则必须创建自己的标题类型\caption
。caption
提供此功能,float
:
\documentclass{article}
\usepackage{newfloat,caption,float}
\DeclareFloatingEnvironment[
fileext = loe,
listname = Examples,
name = Example,
placement = H,
within = none,
]{example}
\captionsetup[example]{labelfont=bf}
\begin{document}
Some text before.
\begin{example}
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the~1500s,
when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into
electronic typesetting, remaining essentially unchanged.
\caption{Lorem Ipsum}
\end{example}
Some text after.
\end{document}
虽然example
被认为是漂浮,定位默认设置为[H]
ere,因此不会浮动。构造不应该跨越页面边界,这似乎是合理的,否则就没有意义了。