Spalten haben nicht die gleiche Größe, obwohl zentriert

Spalten haben nicht die gleiche Größe, obwohl zentriert

Ich habe einen Tisch wie diesen gemacht

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
  \begin{document}
    \begin{table}[htb]
        \centering
        \caption{Reproduzierbarkeit der Elektroden}
        \begin{tabular}{ccccc|c|c|c|c|}
            \toprule
                \textbf{Elektrode} &\multicolumn{4}{c}{\textbf{Mittelwert [mV]}} &\multicolumn{4}{c}{\textbf{maximale Abweichung [\%]}} \\  
            \midrule
                &pH 6 &pH 7 & pH 8 &pH 9 &pH 6 &pH 7 &pH 8&pH 9\\
            \cmidrule[0.5pt]{2-9}
                 6 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
                 7 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
                 8 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
                 9 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
            \bottomrule
            \label{tab:reproduzierbarkeit}
        \end{tabular} 
    \end{table}
  \end{document}

und was ich bekomme ist:

Bildbeschreibung hier eingeben

Warum ist die Breite der neunten Spalte größer als die der anderen, obwohl alle Zeilen zentriert sind? Wie kann ich das ändern, sodass alle Spalten gleich breit sind?

Danke!

Antwort1

Sie müssen sicherstellen, dass die überspannten Zellen breiter sind als der mehrspaltige Eintrag.

Bildbeschreibung hier eingeben

\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
  \begin{document}
    \begin{table}[htb]
        \centering
        \newcommand\x{\makebox[1pt]{}}
        \caption{Reproduzierbarkeit der Elektroden}
        \begin{tabular}{@{}c*4{>\x c<\x}|*4{>\x c<\x|}@{}}
            \toprule
                \textbf{Elektrode} &\multicolumn{4}{c}{\textbf{Mittelwert [mV]}} &\multicolumn{4}{c}{\textbf{maximale Abweichung [\%]}} \\  
            \midrule
                &pH 6 &pH 7 & pH 8 &pH 9 &pH 6 &pH 7 &pH 8&pH 9\\
            \cmidrule[0.5pt]{2-9}
                 6 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
                 7 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
                 8 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
                 9 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
            \bottomrule
            \label{tab:reproduzierbarkeit}
        \end{tabular} 
    \end{table}
  \end{document}

Antwort2

Das könnten Sie tun. Ich weiß nicht, welche genau gleich breit sein sollen. Dadurch werden die letzten vier Spalten mit einem neuen Spaltentyp gleich breit H:

\documentclass{article}
\usepackage{array,calc}
\newlength{\origtabcolsep}
\setlength{\origtabcolsep}{\tabcolsep}
\newlength{\mycolswidth}
\settowidth{\mycolswidth}{\textbf{maximale Abweichung [\%]}}
\newlength{\mycolwidth}
\setlength{\mycolwidth}{.25\mycolswidth-.75\tabcolsep}
\newcolumntype{H}{>{\centering\arraybackslash}p{\mycolwidth}|}
\usepackage{booktabs}
\begin{document}
  \begin{table}[htb]
      \centering
      \caption{Reproduzierbarkeit der Elektroden}
      \setlength{\tabcolsep}{.75\origtabcolsep}
      \begin{tabular}{*{5}{c}|*{4}{H}}
          \toprule
              \textbf{Elektrode} &\multicolumn{4}{c}{\textbf{Mittelwert [mV]}} &\multicolumn{4}{c}{\textbf{maximale Abweichung [\%]}} \\
          \midrule
              &pH 6 &pH 7 & pH 8 &pH 9 &pH 6 &pH 7 &pH 8&pH 9\\
          \cmidrule[0.5pt]{2-9}
               6 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
               7 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
               8 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
               9 & 111 & 111 & 111 & 111 & 10 & 12 & 13 & 11\\
          \bottomrule
          \label{tab:reproduzierbarkeit}
      \end{tabular}
  \end{table}
\end{document}

Tabellarisch mit neuem Spaltentyp H für die letzten 4 Spalten

verwandte Informationen