Graphics, Figures & TablesWhy do people insert @{} in table preamble?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mado
Posts: 16
Joined: Thu Dec 10, 2015 5:55 am

Why do people insert @{} in table preamble?

Post by mado »

It seems to make no difference in visual output. Why do people add @{}?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Why do people insert @{} in table preamble?

Post by Stefan Kottwitz »

Hi mado,

@{code} stands for a command which inserts code between columns, also before the first column and after the last one. So you could insert a \hspace you like, a symbol, or nothing. {} means nothing, as the code is empty. The consequence is, that the default space between columns is removed. This can be desirable, for example to align left and right side of a table with a horizontal separation line.

Take a look:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\begin{document}
Text
\begin{tabular}{ll}
1 & 2 \\
3 & 4
\end{tabular}
Text
\bigskip
Text
\begin{tabular}{@{}l@{}l@{}}
1 & 2 \\
3 & 4
\end{tabular}
Text
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
tabular1.png
tabular1.png (4.25 KiB) Viewed 11939 times
Or specifically using it for aligned margin:

Code: Select all

Code, edit and compile here:
\documentclass{article}
\pagestyle{empty}
\begin{document}
\begin{tabular}{lcr}
One & Two & Three \\
\hline
yes & maybe & or no
\end{tabular}
\bigskip
\begin{tabular}{@{}lcr@{}}
One & Two & Three \\
\hline
yes & maybe & or no
\end{tabular}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
tabular2.png
tabular2.png (7.35 KiB) Viewed 11939 times
Stefan
LaTeX.org admin
mado
Posts: 16
Joined: Thu Dec 10, 2015 5:55 am

Re: Why do people insert @{} in table preamble?

Post by mado »

Thanks. That clarifies things.
Post Reply