TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

as I was reading different question This one I've found code of array enviroment which preamble is quite unknown to be... I see what it does but I would like to understand it to be able use that technique for different situations... I understand what "c" "l" "r" mean but not the rest:

\[
\begin{array}{@{}r@{}l@{\quad}@{}r@{}l@{}}
a&{}=bbb & c&{}=\dfrac{x}{y} \\
aa&{}=bbbb & cc&{}=\dfrac{x}{y}
\end{array}
\]

I was trying to apply it in such a form that I have just one centered column and then right and left which are aligned according to = inside so I wrote \begin{array}{c@{\quad}@{}r@{}l@{}} and something inside environment according to example above but it gave me an error in a form that there are unknown characters in preamble of array... so obviously I do not understand those "@{}"resp "@{\quad}" parts and I wasn't able to find satisfactory answer on the web...

share|improve this question
1  
The only error I get is caused by \dfrac not being defined - you need to load amsmath for that function. The @{...} constructions kill the intercolumn space and replace it with whatever is between the curly braces. – Andrew Swann Jan 17 at 19:57
    
I did not show complete code I just wanted to know meaning of those characters... – Jozef Janočko Jan 17 at 22:36

On either side of each column of an array (or tabular) latex adds \arraycolsep) (or \tabcolsep for tabular) of whitespace, so normally there is 2\arraycolsep space between the columns.

If you go @{hello} then instead of adding space between the columns latex inserts hello in each row.

Sometimes you see forms such as r@{\mbox{--}}l which would make 2 & 3 appear as 2–3

The most common form though is @{} which doesn't add anything but removes the inter column space.

\quad is short for \hspace{1em} so @{\quad} changes the inter-column space from 2\arraycolsep (which is usually 10pt) to 1em (which is usually 10pt).

share|improve this answer
    
Thanks, that's basically what I wanted to know ;) – Jozef Janočko Jan 17 at 22:36
    
And that {} inside of array after & sign is also used for removing spaces? – Jozef Janočko Jan 17 at 22:41
    
@JozefJanočko adding them actually. Compare $=1$ and ${}=1$ with the first form = is at the start so loses its infix relation spacing , here you want it to look like infix even though it is at the start of the cell so {} is added. – David Carlisle Jan 17 at 22:44
    
@Mico thanks, fixed, had an "interesting" effect on the last sentence:-) – David Carlisle Jan 18 at 7:42

David Carlisle has already given a thorough answer as to what @{} and @{\quad} do. I'd like to add an observation regarding how the code for the array could have been set up more elegantly in the first place, in a way that would have avoided the need for the five [5!] instances of the @{} directive.

Specifically, by inserting the instruction \setlength\arraycolsep{0pt} immediately after \[, all five instances of @{} could have been avoided, streamlining the code that sets up the structure of the array:

\documentclass{article}
\usepackage{amsmath} % for "\dfrac" macro
\begin{document}
\[
  \setlength\arraycolsep{0pt} % default value: 5pt
  \begin{array}{rl @{\quad} rl}
     a&{}=bbb  &  c&{}=\dfrac{x}{y} \\[3ex]
    aa&{}=bbbb & cc&{}=\dfrac{x}{y}
  \end{array}
\]
\end{document}
share|improve this answer

Here is the formal references that mentions this notation in the preamble construction of tabular or array:

  • source2e (section 56.2 array and tabular environments, p 300)

    The PREAMBLE argument of an array or tabular environment can contain the following:

    • l,r,c : indicate where entry is to be placed.
    • | : for vertical rule
    • @{EXP} : inserts the text EXP in every column.
      \arraycolsep or \tabcolsep spacing is suppressed.
    • *{N}{PRE} : equivalent to writing N copies of PRE in the preamble.
      PRE may contain *{N’}{EXP’} expressions.
    • p{LEN} : makes entry in \parbox of width LEN.

It's also mentioned in Table 1 (p 2) of the array package documentation.

@{<stuff>} suppresses the inter-column separation and uses <stuff> instead.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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