为什么拆箱会丢失 pdfTeX 中的边距字距调整?

为什么拆箱会丢失 pdfTeX 中的边距字距调整?

考虑以下代码:

\showboxdepth=20
\showboxbreadth=200
\hsize=5.33333in
\pdfoutput=0

\pdfprotrudechars=1 
\input protcode.tex
\setprotcode\tenrm


\vbox{\noindent  Test. Test. Test. Test. Test. Test. Test. Test.
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.\par
\global\setbox3=\lastbox }
\showbox3 \setbox3=\hbox{\unhbox3 }%
\showbox3

\bye

现在用 运行它pdftex。日志文件显示左右边距\kern在重新装箱时消失了。为什么?可以预防吗?以下是摘录:

> \box3=
\hbox(6.83331+0.0)x385.43962, glue set 3.85056fil
.\kern-0.36 (left margin)
.\tenrm T
.\kern-0.83334
.\tenrm e
.\tenrm s
.\tenrm t
.\tenrm .
.\glue 4.44444 plus 4.99997 minus 0.37036
[cut]
.\tenrm T
.\kern-0.83334
.\tenrm e
.\tenrm s
.\tenrm t
.\tenrm .
.\penalty 10000
.\kern-1.94 (right margin)
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0


! OK.
l.15 \showbox3 
               \setbox3=\hbox{\unhbox3 }%
? 
> \box3=
\hbox(6.83331+0.0)x383.88907
.\tenrm T
.\kern-0.83334
.\tenrm e
.\tenrm s
.\tenrm t
.\tenrm .
[cut]
.\tenrm T
.\kern-0.83334
.\tenrm e
.\tenrm s
.\tenrm t
.\tenrm .
.\penalty 10000
.\glue(\parfillskip) 0.0 plus 1.0fil
.\glue(\rightskip) 0.0

! OK.
l.16 \showbox3

在普通的 s 中不会发生这种情况\kern,比如我们\setbox3=\hbox{\kern-1pt Test.\kern1pt}

答案1

正如 @egreg 在评论中所说,确实如此,通过设计\unhbox(在ing 或ing之后,边距字距调整会丢失\unhcopy)。但是有两个命令可以补救:\leftmarginkern\rightmarginkern允许访问 的相应字距hbox

因此,为了调整您的示例代码,以下内容将重新插入边距字距调整:

\showboxdepth=20
\showboxbreadth=200
\hsize=5.33333in
%\pdfoutput=0

\pdfprotrudechars=1
\input protcode.tex
\setprotcode\tenrm

\setbox0=\vbox{\noindent  Test. Test. Test. Test. Test. Test. Test. Test.
        Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.
        Test. Test. Test. Test. Test. Test. Test. Test. Test. Test.\par}
\showbox0 

\newbox\splitbox
\setbox3=\vbox{%
  \loop\ifvbox0
    \vbadness=10000
    \splittopskip=0pt
    \setbox\splitbox\vsplit0 to\baselineskip
    \unvbox\splitbox\setbox\splitbox=\lastbox
    \hbox{\kern\leftmarginkern\splitbox
          \expandafter\unhbox\expandafter\splitbox\expandafter
          \kern\rightmarginkern\splitbox}%
  \repeat}

\showbox3
\unvbox3
\bye

(请注意,据报道,\rightmarginkern弹性存在缺陷\parfillskip这里

相关内容