![colunas não têm o mesmo tamanho, embora centralizadas](https://rvso.com/image/286344/colunas%20n%C3%A3o%20t%C3%AAm%20o%20mesmo%20tamanho%2C%20embora%20centralizadas.png)
fiz uma mesa assim
\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}
e o que eu recebo é:
Então, por que a largura da nona coluna é maior que as outras, embora todas as linhas estejam centralizadas? Como posso mudar isso para que cada coluna tenha a mesma largura?
Obrigado!
Responder1
Você precisa ter certeza de que as células estendidas são mais largas do que a entrada de várias colunas.
\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}
Responder2
Você poderia fazer isso. Não sei quais exatamente você deseja com largura igual. Isso faz com que as quatro colunas finais tenham largura igual usando um novo tipo de coluna 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}