2

I created this table, but I am not happy with the layout. The column "Musical" is too much to the right. Is there a way to have the columns "Oper", "Operette" and "Musical" in more equal big columns? Can you follow me? Would be great to find a solution for that. Thank you.

\begin{table}[h!]
\centering

\begin{tabular}{lccc}
\noalign{%
\setlength{\arrayrulewidth}{1.1pt}%
\let\noalign\empty
\hline
}%
\rowcolor[HTML]{D7D7D7} & \multicolumn{3}{c}{\textbf{CAGR der Veranstaltungsentwicklung in \%}}  \\
\rowcolor[HTML]{D7D7D7} \textbf{Theater} & \textbf{Oper} & \textbf{Operette} & \textbf{Musical} \\ 
\hline
Staatstheater & -1,15 & -3,16 & 5,55 \\
Landestheater & -1,21 & -5,45 & -1,66 \\
Stadttheater & -1,71 & -2,48 & -3,09 \\
fusionierte Theater & -1,90 & -3,86 & -1,28 \\
\hline
\end{tabular}
\caption[Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018]{Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018}
\label{tab:entwickl_veranstaltung_alle_Theater}
\end{table}

enter image description here

1
  • There remains a problem: the minus signs are actually hyphens.
    – Bernard
    Commented Mar 22, 2021 at 14:24

4 Answers 4

1

A better solution with tabularray package:

\documentclass{article}
\usepackage{xcolor}
\usepackage{tabularray}
\UseTblrLibrary{siunitx}
\begin{document}

With \verb!hspan=even! option:

\begin{table}[h!]
\centering
\begin{tblr}{
  colspec = {lccc},
  row{1-2} = {gray9,font=\bfseries},
  cell{1}{2} = {c=3}{c}, % multicolumn
  hspan = even, % distribute extra space evenly
}
\hline[1.1pt]
                      & CAGR der Veranstaltungsentwicklung in \% & &  \\
  Theater             & Oper  & Operette & Musical \\ 
\hline
  Staatstheater       & -1,15 & -3,16    &  5,55   \\
  Landestheater       & -1,21 & -5,45    & -1,66   \\
  Stadttheater        & -1,71 & -2,48    & -3,09   \\
  fusionierte Theater & -1,90 & -3,86    & -1,28   \\
\hline
\end{tblr}
\caption[Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018]{Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018}
\label{tab:entwickl_veranstaltung_alle_Theater}
\end{table}

With \verb!hspan=even! option and \verb!siunitx! library:

\begin{table}[h!]
\centering
\begin{tblr}{
  colspec = {l*{3}{S[table-format=-1.2]}},
  row{1-2} = {gray9,font=\bfseries},
  cell{1}{2} = {c=3}{c}, % multicolumn
  hspan = even, % distribute extra space evenly
}
\hline[1.1pt]
                      & {{{CAGR der Veranstaltungsentwicklung in \%}}} & & \\
  Theater             & {{{Oper}}}  & {{{Operette}}} & {{{Musical}}} \\ 
\hline
  Staatstheater       & -1,15 & -3,16    &  5,55   \\
  Landestheater       & -1,21 & -5,45    & -1,66   \\
  Stadttheater        & -1,71 & -2,48    & -3,09   \\
  fusionierte Theater & -1,90 & -3,86    & -1,28   \\
\hline
\end{tblr}
\caption[Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018]{Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018}
\label{tab:entwickl_veranstaltung_alle_Theater}
\end{table}

\end{document}

enter image description here

0

I would use a \makecell directive to line-break the long header.

enter image description here

\documentclass{article}
\usepackage[ngerman]{babel}
\usepackage[T1]{fontenc}
\usepackage[table]{xcolor}
\usepackage{makecell}
\usepackage[locale=DE]{siunitx}
\begin{document}

\begin{table}[h!]
\centering
\begin{tabular}{ l *{3}{S[table-format=-1.2]} }
\noalign{%
\setlength{\arrayrulewidth}{1.1pt}%
\let\noalign\empty
\hline
}%
\rowcolor[HTML]{D7D7D7} 
& \multicolumn{3}{c}{\bfseries \makecell{CAGR der Veranstaltungs-\\entwicklung, in \%}}  \\ 
\cline{2-4}
\rowcolor[HTML]{D7D7D7}  
\textbf{Theater} & {\textbf{Oper}} & {\textbf{Operette}} & {\textbf{Musical}} \\ 
\hline
Staatstheater & -1,15 & -3,16 & 5,55 \\
Landestheater & -1,21 & -5,45 & -1,66 \\
Stadttheater  & -1,71 & -2,48 & -3,09 \\
fusionierte Theater & -1,90 & -3,86 & -1,28 \\
\hline
\end{tabular}
\caption[Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018]{Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018}
\label{tab:entwickl_veranstaltung_alle_Theater}
\end{table}
\end{document}
5
  • that's an idea but I would prefer not to line break the word here
    – qu33ristan
    Commented Mar 22, 2021 at 14:05
  • 1
    @Mico: I tend to not use makecell with coloured rows, as there are often problems, which disappear with stackengine and its \Centerstack command.
    – Bernard
    Commented Mar 22, 2021 at 17:05
  • @qu33ristan - If you don't want to line-break the 25-letter/7-syllable word Veranstaltungsentwicklung at the place I chose in my answer, which other line break do you consider to be preferable?
    – Mico
    Commented Mar 22, 2021 at 17:13
  • @Bernard - Thanks for pointing out this fact. It would certainly explain why the output of \cline{2-4} isn't visibie.
    – Mico
    Commented Mar 23, 2021 at 8:40
  • @Mico: When ordinary rules are not or hardly visible, \hhlines are, usually.
    – Bernard
    Commented Mar 23, 2021 at 10:23
0

I propose to use the S column type, from siunitx, for the last three columns and to fix their width. I also took the liberty to change the shade of grey for the first two rows.

    \documentclass{article}
    \usepackage{calc} 
    \usepackage{siunitx}
    \usepackage{caption} 
    \usepackage[table, svgnames]{xcolor}

    \begin{document}

    \begin{table}[h!]
    \centering
    \sisetup{table-format=-1.2, table-number-alignment=center, copy-decimal-marker, table-column-width=2cm}
    \captionsetup{labelfont=sc}
    \caption[Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018]{Entwicklung der Musiktheaterveranstaltungszahlen der Theater der Studie 1 im Zeitraum 2008/2009 bis 2017/2018}
    \label{tab:entwickl_veranstaltung_alle_Theater}
    \begin{tabular}{lSSS}
    \noalign{%
    \setlength{\arrayrulewidth}{1.1pt}%
    \let\noalign\empty
    \hline
    }%
    \rowcolor{Gainsboro!50!Lavender} \multicolumn{4}{r}{\textbf{CAGR der Veranstaltungsentwicklung in \%}} \\
    \rowcolor{Gainsboro!50!Lavender}\textbf{Theater} & {\bfseries Oper} & {\bfseries Operette} & {\bfseries Musical} \\
    \hline
    Staatstheater & -1,15 & -3,16 & 5,55 \\
    Landestheater & -1,21 & -5,45 & -1,66 \\
    Stadttheater & -1,71 & -2,48 & -3,09 \\
    fusionierte Theater & -1,90 & -3,86 & -1,28 \\
    \hline
    \end{tabular}
    \end{table}

    \end{document} 

enter image description here

2
  • that works but it's a complete different layout than I am using...
    – qu33ristan
    Commented Mar 22, 2021 at 14:05
  • I answered your requirement: the last three columns have the same width. The only things I changed are the row colors (it's easy to revert to your own color if you prefer – it is only a suggestion), and using a \multicolumn{4}{r}{…} in the first row to avoid problems with the \rowcolor.
    – Bernard
    Commented Mar 22, 2021 at 14:22
0

I helped myself now with

\usepackage{array}

\newcolumntype{L}[1]{>{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}
\newcolumntype{R}[1]{>{\raggedleft\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{table}[h!]
\centering
\small
\begin{tabular}{ l  C{2.1cm}  C{2.1cm}  C{2.1cm} }

...
1
  • Since line-breaking in the three data columns is neither advisable nor needed, defining the L, C, and R column types may be a bit of overkill. You could write, more simply, \begin{tabular}{ l *{3}{ w{c}{2.1cm} } }.
    – Mico
    Commented Mar 22, 2021 at 17:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .