\hbox消息过多

\hbox消息过多

我正在尝试使用 Opmac 在 TeX 中创建幻灯片。

我需要一个这样的页面布局: 在此处输入图片描述

我尝试了这个代码:

\input opmac
\chyph

\margins/1 a5l (1,1,1,1.2)cm        % page format
\input ctimes  \typosize[17/22]      % font

\def\pg{\vfil\break}                % new page
\begitems                           % start items

% set font
\letfont\titfont=\tenbf at18pt 
\letfont\subfont=\tenbf at16pt 

% set header
\headline={\ifnum\folio=1\hfill\else{\hbox to\hsize{\hfil \subfont \firstmark \hfil}}\fi}

% set footer
\newtoks\leftfoot \leftfoot={\hfill Footer text}
\newtoks\rightfoot \rightfoot={\hfill \subfont\folio} 
\footline={\ifnum\folio=1\hfill\else\the\leftfoot\the\rightfoot\fi}

\def\tocline#1#2#3#4#5{{\leftskip=#1\iindent \rightskip=2\iindent
   \ifischap\advance\leftskip by\iindent\fi
   \ifnum#1>1 \advance\leftskip by\iindent\fi
   \toclinehook \noindent\llap{#2\toclink{#3}\enspace}%
         {#2#4\unskip}\nobreak\nobreak\hskip-2\iindent\null\par}}

% slideshow with \kuk     
\let\kuk=\relax 
\def\kukdata{}
\long\def\kukstart#1\kuk{\addto\kukdata{#1}%
   \tmpnum=0 \def\endkukdata{}\expandafter\sumkuk \kukdata\sumkuk
   \kukdata\endkukdata \vfil\break \kukstart
}
\long\def\sumkuk#1{\ifx#1\sumkuk
   \loop \ifnum\tmpnum>0 \addto\endkukdata{\enditems}\advance\tmpnum by-1 \repeat
   \else 
     \ifx#1\begitems \global\advance\tmpnum by1 \fi 
     \ifx#1\enditems \global\advance\tmpnum by-1 \fi
     \expandafter\sumkuk \fi
}
\count1=1  
\def\advancepageno{\ifx\kukdata\empty \global\advance\pageno by1 \global\count1=1
                   \else \global\advance\count1 by1 \fi}
\def\pg{\def\kukdata{}\vfil\break}

\newif\iffirstslide

\def\sec#1\par{\ifnonum\else \global\advance\secnum by1 \fi
  \sechook {\globaldefs=1 \seccnum=0 \tnum=0 \fnum=0 \dnum=0}\relax
  \edef\thesecnum{\othe\chapnum.\the\secnum}\let\thetocnum=\thesecnum
  \iffirstslide
    \def\dotocnumafter{\wtotoc1\rm{#1}}%
  \else
    \def\dotocnumafter{}%
  \fi
  \firstslidefalse 
  \printsec{#1\unskip}\resetnonumnotoc
}

\def\pg{\def\kukdata{}\firstslidetrue\vfil\break}



\kukstart                           % if \kukstart in comment, it prints document normal

\tit Slideshow in \TeX

\pg

\hbox{\hbox to0cm{\vtop{\hsize=6cm \subfont \noindent TOC:

\maketoc}} \hskip6cm \hbox to0cm{\vtop{\hsize=10cm {\nonum\sec First slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item
}}}}

\pg\kuk

\nonum\sec Second slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\nonum\sec Third slide

\kuk
* First item 
\kuk
* Second item 
\kuk
* Third item

\enditems
\end
\kuk

但结果是:

在此处输入图片描述

没有标题(\firstmark不起作用),宏\kuk也不起作用。后面还有难看的黑色划痕\hbox。我该如何修复?

请仅使用纯文本解决方案。

非常感谢!

答案1

\hbox消息过多

箱子过满是由于

\hbox to 0cm{\vtop{\hsize=6cm ...}}

宽度为 6 厘米的材料大于 0 厘米。可以通过\hss在末尾添加以下内容来修复此问题\hbox

\hbox to 0cm{...\hss}

在这个特殊的情况下,6厘米在框后面重新出现\hskip6cm

因此,\hskip可以删除并添加到第一个\hbox 规范中:

\hbox to 6cm{\vtop{\hsize=6cm ...}}

\hbox to 0cm{...}可以用同样的方法修复第二个溢出的箱子。

\firstmark不适用于幻灯片“第一张幻灯片”。

\sec命令调用\insertmark,设置\mark。但“第一张幻灯片”部分位于垂直框 内\vtop。标记从段落或从内部移动\hbox到封闭的垂直框。但这\vtop不是主垂直列表,\mark其余部分被捕获并因此丢失。

作为解决方法,可以手动设置标记:

\pg
\mark{First slide}
\hbox{\hbox ...\vtop{...\sec First slide ...

\kuk不工作

\tracingmacros=1揭示了:

\kukstart #1\kuk ->\addto \kukdata {#1} [...]
#1<-\par \tit Slideshow in \TeX \par \pg \par \hbox {\hbox to0cm{\vtop {\hsize =6cm \subfont \noindent TOC: \par \maketoc }\hss
 } \hskip 6cm \hbox to0cm{\vtop {\hsize =10cm {\nonum \sec First slide \par \kuk * First item \kuk * Second item \kuk * Third item }}\hss }} \par \pg 

当 TeX 查找分隔参数时,它会读取分隔符之前的所有内容。但之前的参数必须符合规则,即花括号必须正确嵌套。在找不到右括号之前,它不会查找分隔符。因此,\kuk第一张幻灯片上的 隐藏在\hbox和的几个括号对中\vtop。(这里花括号可以用 和 替换\bgroup\egroup但麻烦随后出现,当块在没有丢失\egroup标记的情况下执行时。

作为解决方法,LaTeX 包atbegshi也可以在纯 TeX 中使用。然后可以通过覆盖输出页面来设置目录,并且正常设置幻灯片内容,而无需周围的框命令。

例子:

\input opmac
%\chyph

\input atbegshi.sty
\AtBeginShipoutInit
\def\abshook{}
\AtBeginShipout{\abshook{}}

\margins/1 a5l (1,1,1,1.2)cm        % page format
\input ctimes  \typosize[17/22]      % font

\def\pg{\vfil\break}                % new page
\begitems                           % start items

% set font
\letfont\titfont=\tenbf at18pt 
\letfont\subfont=\tenbf at16pt 

% set header
\headline={\ifnum\folio=1\hfill\else{\hbox to\hsize{\hfil \subfont \firstmark \hfil}}\fi}

% set footer
\newtoks\leftfoot \leftfoot={\hfill Footer text}
\newtoks\rightfoot \rightfoot={\hfill \subfont\folio} 
\footline={\ifnum\folio=1\hfill\else\the\leftfoot\the\rightfoot\fi}

\def\tocline#1#2#3#4#5{{\leftskip=#1\iindent \rightskip=2\iindent
   \ifischap\advance\leftskip by\iindent\fi
   \ifnum#1>1 \advance\leftskip by\iindent\fi
   \toclinehook \noindent\llap{#2\toclink{#3}\enspace}%
         {#2#4\unskip}\nobreak\nobreak\hskip-2\iindent\null\par}}

% slideshow with \kuk     
\let\kuk=\relax 
\def\kukdata{}
\long\def\kukstart#1\kuk{\addto\kukdata{#1}%
   \tmpnum=0 \def\endkukdata{}\expandafter\sumkuk \kukdata\sumkuk
   \kukdata\endkukdata \vfil\break \kukstart
}
\long\def\sumkuk#1{\ifx#1\sumkuk
   \loop \ifnum\tmpnum>0 \addto\endkukdata{\enditems}\advance\tmpnum by-1 \repeat
   \else 
     \ifx#1\begitems \global\advance\tmpnum by1 \fi 
     \ifx#1\enditems \global\advance\tmpnum by-1 \fi
     \expandafter\sumkuk \fi
}
\count1=1  
\def\advancepageno{\ifx\kukdata\empty \global\advance\pageno by1 \global\count1=1
                   \else \global\advance\count1 by1 \fi}
\def\pg{\def\kukdata{}\vfil\break}

\newif\iffirstslide

\def\sec#1\par{\ifnonum\else \global\advance\secnum by1 \fi
  \sechook {\globaldefs=1 \seccnum=0 \tnum=0 \fnum=0 \dnum=0}\relax
  \edef\thesecnum{\othe\chapnum.\the\secnum}\let\thetocnum=\thesecnum
  \iffirstslide
    \def\dotocnumafter{\wtotoc1\rm{#1}}%
  \else
    \def\dotocnumafter{}%
  \fi
  \firstslidefalse 
  \printsec{#1\unskip}\resetnonumnotoc
}

\def\pg{\def\kukdata{}\firstslidetrue\vfil\break}


\kukstart                           % if \kukstart in comment, it prints document normal

\tit Slideshow in \TeX

\pg
\kuk

\def\abshook{%
  \immediate\write16{* ABS, page: \the\count0}%
  \setbox\AtBeginShipoutBox=\hbox{%
    \setbox0=\hbox to 0pt{%
      \dimen0=\vsize
      \advance\dimen0 by 1.2cm
      \raise\dimen0\vtop to 0pt{%
        \kern0pt
        \bigskip
        \hsize=6cm
        \leftskip=\iindent
        \subfont
        \noindent TOC:

        \maketoc
        \par
        \vss
      }%
      \hss
    }%
    \ht0=0pt
    \dp0=0pt
    \wd0=0pt
    \copy0
    \copy\AtBeginShipoutBox
  }%
}

\leftskip=6cm

\nonum\sec First slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\leftskip=0pt
\def\abshook{}

\nonum\sec Second slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\nonum\sec Third slide

\kuk
* First item 
\kuk
* Second item 
\kuk
* Third item

\enditems
\end
\kuk

变体\prepghook

\input opmac
%\chyph

\def\prepghook{%
  \vbox to0pt{%
    \kern-\voffset
    \kern-1in
    \hbox to0pt{%
      \kern-\hoffset
      \kern-1in
      \background
      \hss
    }%
    \vss
  }%
  \nointerlineskip
  \vbox to 0pt{%
    \kern 0pt
    \hbox to 0pt{%
      \kern-\iindent
      \tochook
      \hss
    }%
    \vss
  }%
  \nointerlineskip
}
\pdfximage width\pdfpagewidth height\pdfpageheight {tiger.pdf}
\mathchardef\picbackground=\pdflastximage
\def\background{\pdfrefximage\picbackground}
\let\pgfhook\prepghook
\def\tochook{}

\margins/1 a5l (1,1,1,1.2)cm        % page format
\input ctimes  \typosize[17/22]      % font

\def\pg{\vfil\break}                % new page
\begitems                           % start items

% set font
\letfont\titfont=\tenbf at18pt
\letfont\subfont=\tenbf at16pt

% set header
\headline={\ifnum\folio=1\hfill\else{\hbox to\hsize{\hfil \subfont \firstmark \hfil}}\fi}

% set footer
\newtoks\leftfoot \leftfoot={\hfill Footer text}
\newtoks\rightfoot \rightfoot={\hfill \subfont\folio}
\footline={\ifnum\folio=1\hfill\else\the\leftfoot\the\rightfoot\fi}

\def\tocline#1#2#3#4#5{{\leftskip=#1\iindent \rightskip=2\iindent
   \ifischap\advance\leftskip by\iindent\fi
   \ifnum#1>1 \advance\leftskip by\iindent\fi
   \toclinehook \noindent\llap{#2\toclink{#3}\enspace}%
         {#2#4\unskip}\nobreak\nobreak\hskip-2\iindent\null\par}}

% slideshow with \kuk
\let\kuk=\relax
\def\kukdata{}
\long\def\kukstart#1\kuk{\addto\kukdata{#1}%
   \tmpnum=0 \def\endkukdata{}\expandafter\sumkuk \kukdata\sumkuk
   \kukdata\endkukdata \vfil\break \kukstart
}
\long\def\sumkuk#1{\ifx#1\sumkuk
   \loop \ifnum\tmpnum>0 \addto\endkukdata{\enditems}\advance\tmpnum by-1 \repeat
   \else
     \ifx#1\begitems \global\advance\tmpnum by1 \fi
     \ifx#1\enditems \global\advance\tmpnum by-1 \fi
     \expandafter\sumkuk \fi
}
\count1=1
\def\advancepageno{\ifx\kukdata\empty \global\advance\pageno by1 \global\count1=1
                   \else \global\advance\count1 by1 \fi}
\def\pg{\def\kukdata{}\vfil\break}

\newif\iffirstslide

\def\sec#1\par{\ifnonum\else \global\advance\secnum by1 \fi
  \sechook {\globaldefs=1 \seccnum=0 \tnum=0 \fnum=0 \dnum=0}\relax
  \edef\thesecnum{\othe\chapnum.\the\secnum}\let\thetocnum=\thesecnum
  \iffirstslide
    \def\dotocnumafter{\wtotoc1\rm{#1}}%
  \else
    \def\dotocnumafter{}%
  \fi
  \firstslidefalse
  \printsec{#1\unskip}\resetnonumnotoc
}

\def\pg{\def\kukdata{}\firstslidetrue\vfil\break}


\kukstart                           % if \kukstart in comment, it prints document normal

\tit Slideshow in \TeX

\pg
\kuk

\def\tochook{%
  \immediate\write16{* ABS, page: \the\count0}%
  \setbox0=\vtop to 0pt{%
    \kern0pt
    \bigskip
    \hsize=6cm
    \leftskip=\iindent
    \subfont
    \noindent TOC:

    \maketoc
    \par
    \vss
  }%
  \ht0=0pt
  \dp0=0pt
  \wd0=0pt
  \copy0
}

\leftskip=6cm

\nonum\sec First slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\leftskip=0pt
\def\tochook{}

\nonum\sec Second slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\pg\kuk

\nonum\sec Third slide

\kuk
* First item
\kuk
* Second item
\kuk
* Third item

\enditems
\end
\kuk

相关内容