组合制表符和字体更改时的段落分隔符

组合制表符和字体更改时的段落分隔符

tabbing我发现将环境与字体更改相结合时会出现奇怪的行为。当我编写以下代码时

blah blah blah blah
blah blah blah blah
blah blah blah blah
\begin{tabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{tabbing}
more more more more
more more more more
more more more more

环境tabbing不会开始新的段落,因此后续文本(更多...)不会缩进。

另一方面,当我想在环境\sf中进行tabbing如下更改时

blah blah blah blah
blah blah blah blah
blah blah blah blah
\textsf{
\begin{tabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{tabbing}
}
more more more more
more more more more
more more more more

有一个段落中断,因此后续文本以缩进形式书写。

知道为什么会发生这种情况以及如何避免它吗?

答案1

请始终发布完整的文档,这样测试会容易得多。字体变化并不重要,重要的是组,它破坏了 LaTeX 的 trivlist 代码,检测是否开始一个段落。

此外,在垂直模式上下文中最好使用\sffamily而不是\textsf。最简单的解决方法是在制表符之后开始部分段落,然后再结束组,如最后一个例子所示:

在此处输入图片描述

\documentclass{article}

\begin{document}

blah blah blah blah
blah blah blah blah
blah blah blah blah
\begin{tabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{tabbing}
more more more more
more more more more
more more more more


blah blah blah blah
blah blah blah blah
blah blah blah blah
\textsf{
\begin{tabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{tabbing}
}
more more more more
more more more more
more more more more



blah blah blah blah
blah blah blah blah
blah blah blah blah
{\sffamily
\begin{tabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{tabbing}
\mbox{}}more more more more
more more more more
more more more more

\end{document}

答案2

\end{tabbing}当您将tabbing其作为参数括起来时,之后的空白行检查会失败\textsf,因此您会得到段落的结尾。

如果您定义自己的环境,您将获得最好的服务:

\documentclass{article}

\newenvironment{sftabbing}
  {\sffamily\tabbing}
  {\endtabbing}

\begin{document}
blah blah blah blah
blah blah blah blah
blah blah blah blah
\begin{tabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{tabbing}
more more more more
more more more more
more more more more

blah blah blah blah
blah blah blah blah
blah blah blah blah
\begin{sftabbing}
SELECT \= * \\
FROM \> Student S \\
WHERE \> Dept = 1
\end{sftabbing}
more more more more
more more more more
more more more more

\end{document}

这样,如果您改变了对sftabbing环境呈现方式的想法,您只需按照其定义采取行动,而不必tabbing在整个文档中寻找。

在此处输入图片描述

相关内容