纯 TeX 浮动图形

纯 TeX 浮动图形

我想知道是否有人可以告诉我一些影响浮动图形的宏。我想要一些类似于脚注的东西。即自动增加图形编号,然后创建一个带有标题的浮动框。类似于\figure#1#2#3#4参数为宽度、高度、内容、标题的东西。到目前为止,我看过的那些在插入点处中断段落。

我想说:“图中所示的植物\figure{3in}{4in}{\vfill}{Esparto grass}生长在西班牙和阿尔及利亚。”这将引入浮动的 vbox,其底部带有以“图 X”为前缀的标题,在文本中插入“图 X”。

我想我需要更仔细地研究\topinsert\footnote代码...但也许有人已经这样做了?

答案1

在此处输入图片描述


\newcount\figc
\long\def\figure#1#2#3#4{%
\ifhmode\unskip\vadjust\fi{\topinsert
\hrule width #1\relax
\vbox to #2{%
\hsize=#1\relax
\leftskip=\centering
\rightskip=\centering
\parindent=0pt %
\parfillskip=0pt %
\parskip=\baselineskip
#3
\par
\global\advance\figc1 %
{\bf Figure \the\figc}: #4\par
}%
\hrule width #1\relax
\endinsert}}


One two
\figure{2in}{3in}{\vfill XXX\vfill}{Sample one}
three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
Red yellow blue green black white.
One two three four five six seven eight nine ten.
Red yellow blue green black white.
One two three four five six seven eight nine ten.
Red yellow blue green black white.
One two three four five six seven eight nine ten.
Red yellow blue green black white.

One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
\figure{3in}{1in}{\vfill XXX\vfill}{Sample two}
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
One two three four five six seven eight nine ten.
Red yellow blue green black white.

\bye

您可能希望使插入件具有全宽,并且中心内框具有指定的宽度,但这只是一个小改动,在这里我按照要求进行了操作,并使插入件具有规定的宽度。

相关内容