2

I'd like to right-center a column within a tabular* environment. See the following snippet:

\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} llc}
\hline 
\textbf{Art} & \textbf{Stundensatz} & \textbf{Gesamt} \\ 
\hline 
Doing this & 1,5 à 100 Euro & 150,00 Euro \\ 
\hline 
This \& That & 3 à 100 Euro & 300,00 Euro \\
\hline
Even more stuff and corrections & 3,5 à 100 Euro & 350,00 Euro \\ 
\hline
Hearing & 1 à 100 Euro & 100,00 Euro \\
\hline
MwSt. in Höhe von 19\% &  & 171,00 Euro \\
\hline
Gesamt & & 1071,00 Euro \\ 
\hline 
\end{tabular*} 

Which looks like

enter image description here

How to have the last two columns right-centered?

  • 2
    To right align the last two columns, use \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} rr} instead of \begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} llc} By the way, you defined 4 columns but only use 3 of them – leandriis Mar 10 at 11:15
  • What do you mean by right-centered? – Bernard Mar 10 at 11:24
  • @Bernard: Maybe not well phrased, but I meant what leandriis answered. – Jan Mar 10 at 11:28
  • @Jan: The correct english term for 'rechtsbündig' would be flush right, right-aligned or right-justified. – leandriis Mar 10 at 11:35
4

In order to right align the second and third column, use r instead of l. In the following MWE, I have also removed the fourth column cpacifier (c) as you only need three columns. I have also added \multicolumn{1}{c}{...} in order to center the column headers of the second and third column.

The second table in the MWE ise done using tabularx to make sure that long entries in the first column are automatically split into two or more lines so that the table's with does not exceed the textwidth. In this second table, I have also used rules from the booktabs package. These lines have some vertical white space above and below them.

enter image description here

\documentclass{article}

\usepackage{booktabs}
\usepackage{tabularx}
\begin{document}


\begin{tabular*}{\textwidth}{l @{\extracolsep{\fill}} rr}
\hline 
\textbf{Art} & \textbf{Stundensatz} & \textbf{Gesamt} \\ 
\hline 
Doing this & 1,5 à 100 Euro & 150,00 Euro \\ 
\hline 
This \& That & 3 à 100 Euro & 300,00 Euro \\
\hline
Even more stuff and corrections & 3,5 à 100 Euro & 350,00 Euro \\ 
\hline
Hearing & 1 à 100 Euro & 100,00 Euro \\
\hline
MwSt. in Höhe von 19\% &  & 171,00 Euro \\
\hline
Gesamt & & 1071,00 Euro \\ 
\hline 
\end{tabular*} 

\bigskip

\begin{tabularx}{\textwidth}{Xrr}
\toprule 
\textbf{Art} & \multicolumn{1}{c}{\textbf{Stundensatz}}  & \multicolumn{1}{c}{\textbf{Gesamt}} \\ 
\midrule 
Doing this & 1,5 à 100 Euro & 150,00 Euro \\  
This \& That & 3 à 100 Euro & 300,00 Euro \\
Even more stuff and corrections & 3,5 à 100 Euro & 350,00 Euro \\ 
Hearing & 1 à 100 Euro & 100,00 Euro \\
MwSt. in Höhe von 19\% &  & 171,00 Euro \\
a very long entry a very long entry a very long entry a very long entry   &  &  \\
\midrule
Gesamt &  & 1071,00 Euro \\ 
\bottomrule 
\end{tabularx} 

\end{document}
  • Thanks for the detailed answer, very appreciated. – Jan Mar 10 at 11:27

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.