106

I have seen several cases of people using the \tab command to insert a specific amount of space between objects (as opposed to the \hfill command which uses any remaining space). However, I have never been able to get \tab to work. Are there any specific packages or environments that are supposed to accompany \tab?

3
  • 1
    I am not familiar with \tab, but there is a tabto package that can come in quite handy. Aug 29, 2014 at 1:04
  • 1
    I would use \hspace*{<length>} -- without the * the full space may not be inserted.
    – user30471
    Aug 29, 2014 at 4:20
  • May be \let\tab\quad?
    – Manuel
    Aug 29, 2014 at 6:27

7 Answers 7

120

The command \tab exists, but it produces quite a large space. It also requires the use of the package tabto.

Alternative options are \quad and \qquad; the space produced is probably more what you are looking to create. These commands do not require extra packages and can be stacked (e.g. Stuff Over Here \quad \quad \quad More Stuff Over Here) if needed.

You might also want to try using either $\>$ or $\-$. Neither command requires any extra packages, but both must be in math mode. Although neither command by itself gives a large space like \tab does, the space produced is small. However, you can stack the commands in order to get the spacing you want.

Hope this helps.

4
  • @Manuel You are correct; I could define a term like Herbert wanted. But that doesn't really solve the problem or answer the question. The objective is to find a command that will put space between objects and defining a new command doesn't really do that. Besides, it's bad form to define a new command in each document. Oct 23, 2014 at 22:24
  • Oh, I see what you're saying. But, as I mentioned previously, the objective is to FIND a command that will put space between objects and defining a new command doesn't really do that. There is no point in creating a command if one already exists, making it unnecessary (what I term "bad form") to define a new command in each document. Oct 23, 2014 at 23:00
  • This doesn't align the text as far as I can tell. It just inserts a fixed width space. Mar 1, 2021 at 20:05
  • Use \tabto{15mm} to have a tab stop at 15mm (together with package \tabto]. Feb 22, 2022 at 12:01
43

define your own command:

\documentclass{article}
\newcommand\tab[1][1cm]{\hspace*{#1}}
\begin{document}
foo\tab bar\tab[2cm]baz

\tab foo\tab bar\tab[2cm]baz

\rule{1cm}{1pt}foo\rule{1cm}{1pt}bar\rule{2cm}{1pt}baz

\end{document}

enter image description here

1
  • 16
    Which is not what \t does. Tab also aligns the text. Jan 24, 2017 at 19:17
16

If instead of wanting to insert a predetermined amount of spacing within a line, you want to insert variable space that reaches the next predefined tab stop to automatically align across lines like a traditional text editor tab, you may use \NumTabs{⟨number⟩} and \tab from the tabto package as so:

\NumTabs{8} % define 8 equally spaced tabs starting at the left margin
            % and spanning \linewidth
\begin{itemize}
  \item\textbf{Dolphin}:\tab Delphinidae, Platanistidae, Iniidae, Pontoporiidae
  \item\textbf{Whale}:\tab Balaenopteridae, Balaenidae, Cetotheriidae,
  Eschrichtiidae, Monodontidae, Physeteridae, Kogiidae, Ziphiidae
\end{itemize}

Alternatively you may align to any particular length from the left margin with \tabto{⟨length⟩} as so:

\begin{itemize}
  \item\textbf{Dolphin}:\tabto{5em} Delphinidae, Platanistidae, Iniidae, Pontoporiidae
  \item\textbf{Whale}:\tabto{5em} Balaenopteridae, Balaenidae, Cetotheriidae,
  Eschrichtiidae, Monodontidae, Physeteridae, Kogiidae, Ziphiidae
\end{itemize}
3
  • Welcome to TeX.SE. Can you put a complete latex code and one screenshot, please?
    – Sebastiano
    Jun 7, 2020 at 12:14
  • This would be what I was looking for... if it worked inside the gather environment. Mar 7, 2022 at 0:55
  • 1
    This is the correct answer, \tab is not a horizontal spacer. It is like press the TAB key in a typewriter or Word , whereas the equivalent of \quad, \hpace{10mm}, \hfill, etc. is like press the SPACE key some (or many) times. Only add, that for a table-like format with unequal columns, is just better define before the default positions with some like \TabPositions {2cm, 0.25\linewidth, 10 cm, ...} and then just use \tab. The \tabto{} more sense for punctual uses where you do not want change the \NumTabs or \TabPositions.
    – Fran
    Sep 1, 2022 at 18:05
15

Instead of \tab, you may use \hspace{10mm} which gives a 10mm space similar to using \tab.

0
1

For me, \indent did the trick. Using this does not require any package.

After including a paragraph under \section{}, I needed to include another paragraph, but none of the methods mentioned here were working for me to indent the second paragraph. Adding sample code here:

\section{Acknowledgment}
The authors would like to thank. . .
\indent The authors would also like to thank. . .

Discovered this from here

3
  • 3
    You need an empty line before \indent, otherwise it would apply to the paragraph above it.
    – Werner
    Mar 3, 2021 at 6:35
  • 1
    you can use \\ to avoid the empty line
    – Krauss
    Sep 14, 2022 at 8:32
  • @Krauss -- A double backslash should never be used to end a paragraph. It is suitable for ending a line of poetry or a row in a table or a line line in a multi-line math display. A paragraph should be ended with a blank line or \par. Sep 30, 2022 at 2:49
1

In the package tabto, you can use the command tabto{1cm} to create an exact 1cm space in the document. also you can alter the parameter to any number you like.

1

You want to use the tabto package, as Mathematician suggested.

\usepackage{tabto}
\newcommand\mytab{\tabto{1cm}}

Yes, the tab command really spaces things a lot.

You must log in to answer this question.

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