0
\begin{table}[!ht]
\centerline {\begin{tabular}{llr} 
\hline \hline
\cline{1-2}
Område & Area & x & y & $Ax$ & $Ay$ \\
\hline \hline
Triangeln & 157,5 & 14,83 & 6 & 2335,25 & 945 \\
Halvcirkeln & 127,17 & 5,18 & 9 & 658,78 & 1144,53 \\
\hline
\end{tabular}}
\caption{Det genomsnittliga tiden för en period hos varje försök.}
\end{table}

How do I fix this? All my variables doesn't fit in the table.

6
  • 1
    1) {llr} means three columns ... left,left and right aligned .... You need six columns and not 3. 2) Use \centering (no argument for \centering) instead of \centerline{...} – koleygr Oct 5 '20 at 15:21
  • Ahaa, what's the code for 6 columns? – Muhashka Oct 5 '20 at 15:24
  • @oni thank you! – Muhashka Oct 5 '20 at 15:27
  • 1
    could be {llllll} or {lrrrrr} etc .... Also there are columns like p{2cm} or m{2cm} ... l means left ... r means right ... c means centered in the cells.... p{2cm} is a column with automatic breaks and width of 2 cm m{2cm} is like p but verticlay centered – koleygr Oct 5 '20 at 15:27
  • Yeah got it, btw how can I make my variables be at center in the table, I mean "Område & Area & x & y & $Ax$ & $Ay$ \\" these, they are not in center if you understand what I mean. Well "Område & Area" these are but the rest are not. – Muhashka Oct 5 '20 at 15:45
8

You need to specify as many columns as you use in the table.

Do yourself a favor and learn a bit of siunitx for this kind of tables, so the numbers will line up perfectly. I also recommend booktabs for the better rules.

I lined up also the input, but it's not required: it's just easier to read the code and maybe fix faulty entries.

Note that \centerline is the wrong tool and a simple \centering declaration is better.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[swedish]{babel}

\usepackage{booktabs} % better tables
\usepackage{siunitx}  % numeric tables and more

\sisetup{output-decimal-marker={,}}

\begin{document}

\begin{table}[!htp]
\centering

\begin{tabular}{
  @{}
  l
  S[table-format=3.2]
  S[table-format=2.2]
  S[table-format=1.0]
  S[table-format=4.2]
  S[table-format=4.2]
  @{}
}
\toprule
Område      & {Area} & {$x$} & {$y$} & {$Ax$}  & {$Ay$} \\
\midrule
Triangeln   & 157,5  & 14,83 & 6     & 2335,25 &  945    \\
Halvcirkeln & 127,17 &  5,18 & 9     &  658,78 & 1144,53 \\
\bottomrule
\end{tabular}

\caption{Det genomsnittliga tiden för en period hos varje försök.}

\end{table}

\end{document}

enter image description here

1

You need to add more columns to your table. \begin{tabular}{llrlll} … \end{tabular}

\begin{table}[!ht]
\centering{\begin{tabular}{llrlll} 
\hline \hline
\cline{1-2}
Område & Area & x & y & $Ax$ & $Ay$ \\
\hline \hline
Triangeln & 157,5 & 14,83 & 6 & 2335,25 & 945 \\
Halvcirkeln & 127,17 & 5,18 & 9 & 658,78 & 1144,53 \\
\hline
\end{tabular}}
\caption{Det genomsnittliga tiden för en period hos varje försök.}
\end{table}

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.