Take the 2-minute tour ×
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.

I'm kind of new to LaTeX and I want to put these 3 calculations in a table. But I'm getting errors

\begin{tabular}{ l | c | r }  
\begin{math} 
  \frac{9250}{7650} = 1,21 &
  \frac{10126}{7986} = 1,27 & 
  \frac{10210}{7850} = 1,30 
\end{math}
\end{tabular}

Maybe someone can see what is wrong?

The error:

Extra }, or forgotten $.

But I don't see where I might have forgotten that.

share|improve this question
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Thorsten Mar 27 '12 at 16:48
    
If you use , as a "decimal dot", you should put it in braces to get correct spacing. Because $1,27$ has a space after the comma and means "list of two numbers" whereas $1{,}27$ has no space after the comma and means "one point twenty-seven" in some languages (not in English though). –  yo' Mar 27 '12 at 17:17
    
Maybe you will also like the result of \quad and \qquad. Just put all your equations on one line between \[ \], and seperate them by \qquad instead of &. I guess you will appreciate the result. (Tabulars are kind of evil.) –  jmc Mar 27 '12 at 17:43

3 Answers 3

up vote 12 down vote accepted

You need to add each cells in math mode

    \begin{tabular}{ l | c | r } 
      $\frac{9250}{7650} = 1,21$  & 
      $\frac{10126}{7986} = 1,27$ &
      $\frac{10210}{7850} = 1,30$  
    \end{tabular}   

You can also write \begin{math}\frac{9250}{7650} = 1,21\end{math} etc...

I think it's perhaps useful to read the mathmode.pdf of Herbert Voss from here

share|improve this answer

use an array anvironment instead of a tabular:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
$\begin{array}{ l c r }  
    \dfrac{9250}{7650} = 1,21 &
    \dfrac{10126}{7986} = 1,27 & \dfrac{10210}{7850} = 1,30 
\end{array}$

\end{document}
share|improve this answer
1  
To clarify this answer (which in my eyes is the best): Array is designed for math straigtaway. Since the content of your table is math, you probably should consider array instead of tabular. Note that you should indead put {} around the commata, like {,}. –  jmc Mar 27 '12 at 17:41
2  
@jmc: The OP can use the [icomma](www.ctan.org/pkg/icomma) package to have proper spacing when using comma , as decimal separator. –  Martin Heller Mar 27 '12 at 20:43
    
@MartinHeller, Nice! I did not know that package. Since I am Dutch, it might come in helpful now and then. –  jmc Mar 27 '12 at 20:54
    
it is also possible to redefine the symbols with \DeclareMathSymbolif one needs it for the whole document –  Herbert Mar 27 '12 at 21:03

You can also use the array package to specify macros to be applied at the beginning of each element with >{\command} and after each element <{command}. For example >{\begin{math}}l<{\end{math}} would typeset the column as math text and would left (l) align it (as in the first example below).

Alternatively, you could also define a \newcolumntype{L}{>{\begin{math}}l<{\end{math}}} and then just use L and that column would automatically be in math mode (as in the second example below).

enter image description here

\documentclass{article}
\usepackage{array}

\newcolumntype{L}{>{\begin{math}}l<{\end{math}}}%
\newcolumntype{C}{>{\begin{math}}c<{\end{math}}}%
\newcolumntype{R}{>{\begin{math}}r<{\end{math}}}%


\begin{document}
\begin{tabular}{ 
    >{\begin{math}}l<{\end{math}} | 
    >{\begin{math}}c<{\end{math}} | 
    >{\begin{math}}r<{\end{math}}}  
    \frac{9250}{7650}  = 1,21 &
    \frac{10126}{7986} = 1,27 & \frac{10210}{7850} = 1,30 
\end{tabular}

\begin{tabular}{L | C | R}  
    \frac{9250}{7650}  = 1,21 &
    \frac{10126}{7986} = 1,27 & \frac{10210}{7850} = 1,30 
\end{tabular}
\end{document}
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.