據我了解,我偶然發現了該expl3
命令的一些意外行為\hbox_overlap_right:n
。我期望下面的所有範例都會產生相同的結果,即框架框與黃色框位於相同的位置。但只有\makebox
範例才能產生預期的結果。這些expl3
範例甚至在黃色框和框架框之間插入換行符。出了什麼問題?
\documentclass{article}
\usepackage{color}
\usepackage{expl3}
\begin{document}
\ExplSyntaxOn
%doesn't work
\hbox_overlap_right:n{\color{yellow}\rule{1in}{0.5in}}\frame{\phantom{\rule{1in}{0.5in}}}
\par
%doesn't work either
\hbox_to_zero:n{\color{yellow}\rule{1in}{0.5in}\hss}\frame{\phantom{\rule{1in}{0.5in}}}
\par
%LaTeX2e working as expected
\makebox[0pt][l]{\color{yellow}\rule{1in}{0.5in}}\frame{\phantom{\rule{1in}{0.5in}}}
\ExplSyntaxOff
\end{document}
答案1
此功能\hbox_overlap_right:n
與 Plain TeX 相同\rlap
(除了\protected
),而\hbox_to_zero:n
與 相同\hbox to 0pt
:
> texdef -t latex -p expl3 'hbox_overlap_right:n'
\hbox_overlap_right:n:
\protected\long macro:#1->\hbox_to_zero:n {#1\tex_hss:D }
> texdef -t latex -p expl3 'hbox_to_zero:n'
\hbox_to_zero:n:
\protected\long macro:#1->\tex_hbox:D to\c_zero_dim {#1}
> texdef -t latex frame
\frame:
\long macro:#1->\leavevmode \hbox {\hskip -\@wholewidth \vbox {\vskip -\@wholewidth \hrule \@height \@wholewidth \hbox {\vrule \@width \@wholewidth #1\vrule \@width \@wholewidth }\hrule \@height \@wholewidth \vskip -\@wholewidth }\hskip -\@wholewidth }
由於圖元\hbox
沒有啟動水平模式,因此 while\frame
和\makebox
do 得到的結果是正常的。
添加\leavevmode
之前\hbox_overlap_right:n
。