\tabto 与 nextline \\ 导致行重叠

\tabto 与 nextline \\ 导致行重叠

使用\tabto{...}强制换行\\似乎会引起一种冲突,即在 之前和之后的文本位置出现明显异常\tabto

以下来源:

\documentclass{article}
\usepackage{tabto}

\usepackage{tikz}
\newcommand{\grule}{%
    \tikz[overlay, gray!20]
      \node[right]{\rule{\linewidth}{0.2pt}};%
                   }

\setlength{\parindent}{0pt}

\begin{document}

    \grule%
    In normal size \tabto{1.6in} text appears on one line

    \small\grule%
    In small size \tabto{1.6in} text also appears on one line

    \footnotesize\grule%
    In footnote size \tabto{1.6in} text appears on one line too

    \huge\grule%
    In huge size \tabto{1.6in} text appears on one line too
    \bigskip

    \normalsize\grule%
    But \emph{why} does text fall off the lines here\,--- \\[1ex]
    %
    {\tiny\grule          Text \tabto{1in}   in tiny size}\\
    {\scriptsize\grule    Text \tabto{1in}   in script size}\\
    {\footnotesize\grule  Text \tabto{1in}   in footnote size}\\
    {\small\grule         Text \tabto{1in}   in small size}\\
    {\normalsize\grule    Text \tabto{1in}   in normal size}\\
    {\large\grule         Text \tabto{1in}   in large size}\\
    {\Large\grule         Text \tabto{1in}   in Large size}\\
    {\LARGE\grule         Text \tabto{1in}   in LARGE size}\\
    {\huge\grule          Text \tabto{1in}   in huge size}\\
    {\Huge\grule          Text \tabto{1in}   in Huge size}

    or prefer to stay above in case of the last line\,?
    \bigskip


    Why do the last two lines of text overlap with the previous ones either\,??


\end{document}

生成此文件:

在此处输入图片描述

想知道是什么导致了这个冲突。这是tabto软件包的一个错误吗?

答案1

主要问题是您对大小命令的放置位置不寻常,因为您没有在大小命令的范围内包含段落结尾,所以您在正常基线上设置了小(或更糟,大)文本。

对于小文本,这只会产生较大的行间空间,但对于大文本,无法实现基线,并且 tex 将回到不均匀的\lineskip间距。

无论哪种情况,\tabto都无法知道将使用什么段落基线空间,因此\baselineskip在调整文本时假定当前(未使用)的值。

在这里我定义了\xtabto本地使用\normalsize

在此处输入图片描述

\documentclass{article}
\usepackage{tabto}

\usepackage{tikz}
\newcommand{\grule}{%
    \tikz[overlay, gray!20]
      \node[right]{\rule{\linewidth}{0.2pt}};%
                   }

\setlength{\parindent}{0pt}

\begin{document}

    \grule%
    In normal size \tabto{1.6in} text appears on one line

    \small\grule%
    In small size \tabto{1.6in} text also appears on one line

    \footnotesize\grule%
    In footnote size \tabto{1.6in} text appears on one line too

    \huge\grule%
    In huge size \tabto{1.6in} text appears on one line too
    \bigskip

\newcommand\xtabto[1]{{\normalsize\tabto{#1}}\ignorespaces}

    \normalsize\grule%
    But \emph{why} does text fall off the lines here\,--- \\[1ex]
    %
    {\tiny\grule          Text \xtabto{1in}   in tiny size}\\
    {\scriptsize\grule    Text \xtabto{1in}   in script size}\\
    {\footnotesize\grule  Text \xtabto{1in}   in footnote size}\\
    {\small\grule         Text \xtabto{1in}   in small size}\\
    {\normalsize\grule    Text \xtabto{1in}   in normal size}\\
    {\large\grule         Text \xtabto{1in}   in large size}\\
    {\Large\grule         Text \xtabto{1in}   in Large size}\\
    {\LARGE\grule         Text \xtabto{1in}   in LARGE size}\\
    {\huge\grule          Text \xtabto{1in}   in huge size}\\
    {\Huge\grule          Text \xtabto{1in}   in Huge size}

    or prefer to stay above in case of the last line\,?
    \bigskip


    Why do the last two lines of text overlap with the previous ones either\,??


\end{document}

相关内容