2

When I try this table there's a problem at the end of the first row and I don't know how to fix it.

\documentclass{article}
\usepackage[utf8]{inputenc}

\title{A}
\author{AA }
\date{November 2018}

\usepackage{natbib}
\usepackage{graphicx}
\usepackage{tabu}



\begin{document}


\begin{tabu} to 0.9\textwidth { | X[c] | X[c] | X[c] | X[r] | }
 \hline
 l(cm) & V(V) & I(A) & R(\Omega)\\
 \hline
 4  & 0,020  & 1,70 & \\
 \hline
 8  & 0,051  & 1,70 & \\
 \hline
 12  & 0,077  & 1,70 &8\\
 \hline
 16  & 0,102  & 1,70 & \\
 \hline
 20  & 0,127  & 1,70 &\\
 \hline
 24  & 0,152  & 1,70 &\\
\hline
\end{tabu}


\end{document}
1
  • \Omega will only work in math mode.
    – schtandard
    Jun 9 '19 at 9:33
2

The tabu package is broken, don't use it. In this case you can just use an ordinary tabular.

Your first error tells you Missing $ inserted, because \Omega is a math mode command, you can't use it in text mode. In general, you should make a clear distinction in your code what is math and what is not. For example, the variables in your table head (l, V, I and R) should all be math.

For the numbers and units in your table (and anywhere else in your document), I recommend using the siunitx package. From your use of , as a decimal marker I guess that you are writing in German, so I chose that setting in the MWE below. (It is conveniently irrelevant if you use , or . in the input to siunitx macros, though. If you don't get the numbers with , from some other program, I would always prefer to type . in the code since that's compatible with pretty much any program you may want those numbers to interact with.)

For tables, I recommend using the booktabs package. Have a look at its documentation and maybe this post for why that's a good idea.

Now, here's how I would typeset your table:

\documentclass{article}

\usepackage{booktabs}
\usepackage[locale=DE]{siunitx}

\begin{document}

\begin{tabular}{S[table-format=2] S[table-format=1.3] S[table-format=1.2] S[table-format=1]}\toprule
    {\(\displaystyle\frac{l}{\si{\centi\meter}}\)}  &   {\(\displaystyle\frac{V}{\si{\volt}}\)} &   {\(\displaystyle\frac{I}{\si{\ampere}}\)}   &   {\(\displaystyle\frac{R}{\si{\ohm}}\)}  \\\midrule
    4   &   0.020   &   1.70    &   \\
    8   &   0.051   &   1.70    &   \\
    12  &   0.077   &   1.70    &   8   \\
    16  &   0.102   &   1.70    &   \\
    20  &   0.127   &   1.70    &   \\
    24  &   0.152   &   1.70    &   \\\bottomrule
\end{tabular}

\end{document}

MWE output

If you don't like the fraction notation in the table head, you can of course use something like {\(l\) in \si{\centi\meter}} or {\(l\) [\si{\centi\meter}]} instead. In tables with a lot of columns the fraction notation can be advantageous due to its slenderness, though.

1

(As has been pointed out in a comment by schtandard) \Omega -- like any other greek letter macro -- needs to be run in math mode. In this case you want it to be "inline", so just wrap it in single $, like $\Omega$

So your full line would be

 l(cm) & V(V) & I(A) & R($\Omega$)\\

N.B. If, as I suspect, you are using this as an Ohm symbol, there is a related question with some suggestions for displaying it in a more typographically correct way (i.e. upright, rather than italic).

1
  • Thank you very much, already solved!
    – Pep Torres
    Jun 9 '19 at 9:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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