13

When should I use the tabbing environment? Whenever I want to line things up I reach for tabular, and I have this vague worry that I sometimes miss a simpler solution because I don't think in terms of tabbing.

14

The following might shed some light on when to use which:

  • tabular creates an unbreakable block, while tabbing can break across the page boundary.

  • tabular allows for creating specific alignments using the column specification, while tabbing assumes all tabs are left aligned.

  • tabular can insert vertical and horizontal rules that span the width of the content, while it is very difficult to do with tabbing.

  • tabular can make content wrap with the paragraph column specification, while tabbing doesn't allow for this.

  • tabular provides package support (through array and colortbl, for example) for formatting.

Here is a small example showing the first couple of differences (perhaps most notable differences) between tabular and tabbing - alignment and page breaking:

enter image description here

\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}
| improve this answer | |
  • 2
    ok, seems that the primary advantage is natural page breaking. – Mark May 19 '16 at 18:46
  • 3
    @Mark and to get the best of both worlds, you might want to use the longtable package: It defines a new environment, longtable, which has most of the features of the tabular environment, but produces tables which may be broken by TEX’s standard page-breaking algorithm. ctan – Gyom May 27 '16 at 7:36
  • Yep, heard of it. Never had tables that long though. – Mark May 27 '16 at 22:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.