\hbox_overlap_right:n{} 与 \makebox[0pt][l]{}

\hbox_overlap_right:n{} 与 \makebox[0pt][l]{}

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没有启动水平模式,而\frame和则\makebox启动,因此获得的结果是正常的。

\leavevmode在 之前添加\hbox_overlap_right:n

相关内容