![열은 중앙에 있지만 크기가 동일하지 않습니다.](https://rvso.com/image/286344/%EC%97%B4%EC%9D%80%20%EC%A4%91%EC%95%99%EC%97%90%20%EC%9E%88%EC%A7%80%EB%A7%8C%20%ED%81%AC%EA%B8%B0%EA%B0%80%20%EB%8F%99%EC%9D%BC%ED%95%98%EC%A7%80%20%EC%95%8A%EC%8A%B5%EB%8B%88%EB%8B%A4..png)
이런 테이블을 만들었어요
\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}
내가 얻는 것은 다음과 같습니다.
그렇다면 모든 행이 중앙에 정렬되어 있음에도 불구하고 9번째 열의 너비가 다른 열보다 큰 이유는 무엇입니까? 각 열의 너비가 동일하도록 하려면 어떻게 해야 합니까?
감사해요!
답변1
확장된 셀이 여러 열 항목보다 넓은지 확인해야 합니다.
\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}
답변2
당신은 이것을 할 수 있습니다. 너비가 정확히 어느 것을 원하는지 모르겠습니다. 그러면 새로운 열 유형을 사용하여 동일한 너비의 마지막 4개 열이 만들어집니다 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}