防止在章节页面上出现 \topinsert (Plain TeX)

防止在章节页面上出现 \topinsert (Plain TeX)

如何定义章节以防止\topinsert在章节页面上插入浮动图形和表格()。我想在下一页的顶部放置一个对象。

\def\chap#1{\vfil\break \vglue1cm
  {\nobreak\noindent #1\par}
  \nobreak\bigskip\firstnoindent}  

\chap Name of chapter

Some text

\topinsert
some table or figure
\endinsert

答案1

添加一个检查,表明\pagecontents我们不在章节起始页。不过,你需要你的章节有多个页面。

\newif\ifchapterpage

\def\chap#1\par{%
  \vfil\break\vglue1cm
  {\nobreak\noindent #1\par}
  \global\chapterpagetrue
  \global\dimen\topins=0pt % no topinserts in the chapter pages
  \nobreak\bigskip
  %\firstnoindent % commented because definition is missing
}

\catcode`@=11
\def\pagecontents{%
  \ifvoid\topins
  \else
    %\unvbox\topins % this is what Plain TeX does
    \ifchapterpage
      \global\dimen\topins=\maxdimen % restore the default
    \else
      \unvbox\topins
    \fi
  \fi
  \dimen@=\dp\@cclv \unvbox\@cclv % open up \box255
  \ifvoid\footins
  \else % footnote info is present
    \vskip\skip\footins
    \footnoterule
    \unvbox\footins
  \fi
  \ifr@ggedbottom \kern-\dimen@ \vfil \fi
  \global\chapterpagefalse % let's reset the conditional at shipout time
}
\catcode`@=12

\chap Name of chapter

Some text

\topinsert

\leaders\hbox{\strut some table or figure}\vskip6\baselineskip

\endinsert

Some other text

\vfill\eject

Some other text on the next page

\bye

答案2

还有更简单的解决方案:

\def\chap#1\par{%
  \vfil\break\vglue1cm
  {\nobreak\noindent\bf #1\par}
  \global\dimen\topins=0pt
  \nobreak\bigskip
}
\output=\expandafter{\the\output \global\dimen\topins=\vsize}

或者使用 OPmac:

\input opmac

\addto\chaphook{\global\dimen\topins=0pt }
\addto\endoutput{\global\dimen\topins=\vsize}

相关内容