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
在整个文档中寻找。