何时使用制表符

何时使用制表符

我应该何时使用环境tabbing?每当我想要排列东西时,我都会使用tabular,但我隐约担心我有时会错过更简单的解决方案,因为我不会从 的角度思考tabbing

答案1

以下内容或许可以解释何时使用哪种方法:

  • tabular创建一个牢不可破的块,同时tabbing可以跨越页面边界打破。

  • tabular允许使用列规范创建特定的对齐,同时tabbing假定所有选项卡都是l左对齐的。

  • tabular可以插入跨越内容宽度的垂直和水平规则,而使用 则很难做到这一点tabbing

  • tabular可以使内容按照paragraph 列规范换行,而tabbing不允许这样做。

  • tabular提供软件包支持(通过arraycolortbl(例如)进行格式化。

tabular下面是一个小例子,展示了对齐tabbing和分页之间的几个区别(也许是最显着的区别) :

在此处输入图片描述

\documentclass{article}

\usepackage[paperheight=25\baselineskip,margin=1in]{geometry}% Just for this example

\begin{document}

\section{A section}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse fermentum turpis 
sed nunc porttitor posuere. Nunc accumsan rutrum nisi ac varius. Donec nibh dolor, 
dignissim sit amet dictum et, iaculis at nunc. Nunc non gravida nulla. Phasellus et 
risus rutrum, facilisis quam sit amet, fermentum tortor. Nulla vel nisi mattis, tempor 
orci et, luctus tellus. Pellentesque mauris nibh, pretium ac tincidunt non, vulputate 
id lectus. Pellentesque blandit justo nisl, ut rhoncus dui gravida eget. Fusce accumsan 
egestas placerat. Quisque aliquet fermentum ex, in dignissim massa. Mauris scelerisque 
maximus augue eu lacinia. Nam vel porta arcu.

\noindent
\begin{tabular}{ l c r p{10em} }
  \bfseries left & \bfseries center & \bfseries right & \bfseries paragraph \\
  first & second & third & fourth \\
  one & two & three & Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  een & twee & drie & Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  one & two & three & Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  een & twee & drie & Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{tabular}

\clearpage

\section{A section}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse fermentum turpis 
sed nunc porttitor posuere. Nunc accumsan rutrum nisi ac varius. Donec nibh dolor, 
dignissim sit amet dictum et, iaculis at nunc. Nunc non gravida nulla. Phasellus et 
risus rutrum, facilisis quam sit amet, fermentum tortor. Nulla vel nisi mattis, tempor 
orci et, luctus tellus. Pellentesque mauris nibh, pretium ac tincidunt non, vulputate 
id lectus. Pellentesque blandit justo nisl, ut rhoncus dui gravida eget. Fusce accumsan 
egestas placerat. Quisque aliquet fermentum ex, in dignissim massa. Mauris scelerisque 
maximus augue eu lacinia. Nam vel porta arcu.

\begin{tabbing}
  \bfseries left \quad \=\bfseries center \quad \=\bfseries right \quad \=\bfseries paragraph \kill
  \bfseries first \> \bfseries second \> \bfseries third \> \bfseries fourth \\
  one \> two \> three \> Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  een \> twee \> drie \> Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  one \> two \> three \> Lorem ipsum dolor sit amet, consectetur adipiscing elit. \\
  een \> twee \> drie \> Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\end{tabbing}

\end{document}

相关内容