5

I want to tab a list of items like in Microsoft Word, where the tab command always tabs by a fixed number of spaces from the beginning of the line.

Here's a sample of what I'm looking for:

Kav       average kinetic energy
N         number of atoms
gamma     a Greek letter

What command might I use to obtain the above output?

5
  • Perhaps this \qquad ?
    – CroCo
    Aug 29, 2015 at 14:33
  • Well, \qquad does not align the second column properly. Aug 29, 2015 at 14:34
  • tab is a fixed space, therefore \qquad does similar thing. For the exact output, of course extra work need to be done.
    – CroCo
    Aug 29, 2015 at 14:37
  • I am looking for something that does 'fixed space' tabbing. Aug 29, 2015 at 14:38
  • Latex doesn't work like Word in the sense that you need to tell the computer what exactly the output should be.
    – CroCo
    Aug 29, 2015 at 14:39

4 Answers 4

11

Environment tabbing

LaTeX also knows a tabbing environment:

\= sets a tabulator, which can be again reached by \>. \kill cancels the line, but keeps the tabulator settings.

\documentclass{article}
\begin{document}
  \begin{tabbing}
    gamma\quad\= a Greek letter\kill
    Kav       \> average kinetic energy\\
    N         \> number of atoms\\
    gamma     \> a Greek letter
  \end{tabbing}
\end{document}

Result tabbing

Environment tabular

A tabular can be used:

\documentclass{article}
\begin{document}
  \begin{tabular}{@{}ll@{}}
    Kav   & average kinetic energy\\
    N     & number of atoms\\
    gamma & a Greek letter\\
  \end{tabular}
\end{document}

Result tabular

Environment description

Such a list can also be set as description list, e.g.:

\documentclass{article}
\usepackage{enumitem}
\usepackage{calc}
\begin{document}
  \begin{description}[labelwidth=\widthof{\bfseries gamma}]
    \item[Kav]   average kinetic energy
    \item[N]     number of atoms
    \item[gamma] a Greek letter
  \end{description}
\end{document}

Result description

3

Use a tabular:

\documentclass{article}
\begin{document}
  \begin{tabular}{@{}p{0.1\linewidth}p{\dimexpr0.9\linewidth-2\tabcolsep\relax}@{}}
    kav & Average kinetic energy \\
    N & Number of atoms \\
    Gamma & A greek letter
  \end{tabular}
\end{document}

enter image description here

Or use a list:

\documentclass{article}
\usepackage{enumitem}
\begin{document}
  \begin{itemize}[align=left,itemindent=2cm,labelwidth=2cm,leftmargin=0pt]
    \item[kav]  Average kinetic energy
    \item[N]  Number of atoms
    \item[Gamma]  A greek letter
  \end{itemize}
\end{document}
3

One more friendly option: use the tabto package:

mwe

\documentclass{article}
\usepackage{tabto}
\TabPositions{5em}
\begin{document}
\noindent
Kav   \tab{average kinetic energy}\\
N     \tab{number of atoms}\\
gamma \tab{a Greek letter}\\
\end{document}
2
  • (+1) @Fran, I believe this is the answer to the question and wonder how can the other answers get that number of up-votes while none of them actually answers the question. BTW, I encourage you to add a more complex example to show how tabto works and perhaps link to the tabto single page documentation.
    – AboAmmar
    Sep 22, 2015 at 0:45
  • @AboAmmar People vote mostly on new questions, so it is normal collect few votes for a long time in late answers. There are no much more except \tabto*{} for overprinting and \NumTabs{} that is the same that \TabPositions{...,....,...} with equal spaces filling the line. I have an example here using \NumTabs{} (as well as a poor's man approach to make the same without knowing tabto).
    – Fran
    Sep 23, 2015 at 9:49
1

This might do the work.

\documentclass{article}

\begin{document}

\noindent Kav \qquad         average kinetic energy \\
N             \qquad  \ \ \  number of atoms \\ 
gamma  \ \                   a Greek letter 

\end{document}

enter image description here

2
  • The alignment is not very accurate (e.g., a Greek letter is moved to much to the right) and very cumbersome unless a fixed-width font is used. Aug 29, 2015 at 15:03
  • @HeikoOberdiek, you are absolutely right. The answer is far away from being perfect. Just to tell the OP that Latex doesn't work like Word, therefore for an accurate spaced distance, he/her should use tabular or what you've stated in your answer.
    – CroCo
    Aug 29, 2015 at 16:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .