![Как централизовать столбец, уже центрированный в табличной преамбуле?](https://rvso.com/image/392337/%D0%9A%D0%B0%D0%BA%20%D1%86%D0%B5%D0%BD%D1%82%D1%80%D0%B0%D0%BB%D0%B8%D0%B7%D0%BE%D0%B2%D0%B0%D1%82%D1%8C%20%D1%81%D1%82%D0%BE%D0%BB%D0%B1%D0%B5%D1%86%2C%20%D1%83%D0%B6%D0%B5%20%D1%86%D0%B5%D0%BD%D1%82%D1%80%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%BD%D1%8B%D0%B9%20%D0%B2%20%D1%82%D0%B0%D0%B1%D0%BB%D0%B8%D1%87%D0%BD%D0%BE%D0%B9%20%D0%BF%D1%80%D0%B5%D0%B0%D0%BC%D0%B1%D1%83%D0%BB%D0%B5%3F.png)
Я делаю таблицу с 6 столбцами с 2 рядами заголовков. Есть 3 основных заголовка и 6 подзаголовков. Все столбцы напечатаны c
, однако столбцы 3 и 4 не центрированы правильно. Есть ли помощь?
\documentclass[12pt,a4paper]{article}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage[
font=footnotesize,
justification=centering,
figurewithin=section,
tablewithin=section
]{caption}
\usepackage{siunitx}
\usepackage{chemformula}
\begin{document}
\begin{table}[h]
\centering
\footnotesize
\caption{My caption}
\label{my-label}
\begin{tabular}{cccccc}
\toprule
\multicolumn{2}{c}{\textbf{Time (\si{min})}} &%
\multicolumn{2}{c}{\textbf{Water + \ch{CH3COOH} \SI[inter-unit-product=~]{0,15}{\%~v/v}}} &%
\multicolumn{2}{c}{\textbf{Oil}} \\
\midrule
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} \\
\midrule
0,00 & 0,00 & 100 & 90 & 0 & 10 \\
0,50 & 0,50 & 90 & 70 & 10 & 30 \\
8,50 & 8,00 & 100 & 0 & 0 & 100 \\
13,50 & 8,10 & 100 & 90 & 0 & 10 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
решение1
Вариант на основе makecell
и cmidrule
s:
\documentclass[12pt,a4paper]{article}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{makecell}
\renewcommand{\theadfont}{\bfseries}
\usepackage[
font=footnotesize,
justification=centering,
figurewithin=section,
tablewithin=section,
skip=6pt
]{caption}
\usepackage{siunitx}
\usepackage{chemformula}
\begin{document}
\begin{table}[h]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{cccccc}
\toprule
\multicolumn{2}{c}{\thead{Time \\(\si{min})}} &%
\multicolumn{2}{@{}c@{}}{\thead{Water\,$+$\,\ch{CH3COOH}\\ \SI[inter-unit-product=~]{0,15}{\%~v/v}}} &%
\multicolumn{2}{c}{\thead{Oil}} \\
\cmidrule(lr){1-2}\cmidrule(lr){3-4}\cmidrule(lr){5-6}
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} \\
\cmidrule(lr){1-2}\cmidrule(lr){3-4}\cmidrule(lr){5-6}
0,00 & 0,00 & 100 & 90 & 0 & 10 \\
0,50 & 0,50 & 90 & 70 & 10 & 30 \\
8,50 & 8,00 & 100 & 0 & 0 & 100 \\
13,50 & 8,10 & 100 & 90 & 0 & 10 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
решение2
Один из способов использования tabularx
:
\documentclass[12pt,a4paper]{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{chemformula}
\begin{document}
\tabcolsep.5em\small
\begin{tabularx}{\linewidth}{cc>{\hfil}X>{\hfil}Xcc}\toprule
\multicolumn{2}{c}{\textbf{Time (\si{min})}} &%
\multicolumn{2}{c}{\textbf{Water + \ch{CH3COOH} \SI[inter-unit-product=~]{0,15}{\%~v/v}}}&%
\multicolumn{2}{c}{\textbf{Oil}} \\
\cmidrule(rl){1-2}\cmidrule(rl){3-4}\cmidrule(rl){5-6}
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} \\
\cmidrule(rl){1-1}\cmidrule(rl){2-2}\cmidrule(rl){3-3}
\cmidrule(rl){4-4}\cmidrule(rl){5-5}\cmidrule(rl){6-6}
0,00 & 0,00 & 100 & 90 & 0 & 10 \\
0,50 & 0,50 & 90 & 70 & 10 & 30 \\
8,50 & 8,00 & 100 & 0 & 0 & 100 \\
13,50 & 8,10 & 100 & 90 & 0 & 10 \\\bottomrule
\end{tabularx}
\end{document}
Но лично я просто изменю заголовок на более короткий Acetic acid \SI{0,15}{\percent}
и останусь со стандартной таблицей и c
столбцами:
решение3
Вот версия с заголовком столбца, разделенным на две строки, и более крупным \tabcolsep
:
\documentclass[12pt,a4paper]{article}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage[
font=footnotesize,
justification=centering,
figurewithin=section,
tablewithin=section
]{caption}
\usepackage{siunitx}
\usepackage{chemformula}
\usepackage{makecell}
\begin{document}
\begin{table}[h]
\centering
\footnotesize
\setlength{\tabcolsep}{15pt}
\caption{My caption}
\label{my-label}
\begin{tabular}{@{\hspace{7pt}}cccccc@{\hspace{7pt}}}
\toprule
\multicolumn{2}{c}{\textbf{Time (\si{min})}} &%
\multicolumn{2}{c}{\textbf{\makecell[cc]{Water + \ch{CH3COOH} \\ \SI[inter-unit-product=~]{0,15}{\%~v/v}}}} &%
\multicolumn{2}{c}{\textbf{Oil}} \\
\cmidrule(r){1-2} \cmidrule(lr){3-4} \cmidrule(l){5-6}
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} &%
\textbf{Point 1} & \textbf{Point 2} \\
\midrule
0,00 & 0,00 & 100 & 90 & 0 & 10 \\
0,50 & 0,50 & 90 & 70 & 10 & 30 \\
8,50 & 8,00 & 100 & 0 & 0 & 100 \\
13,50 & 8,10 & 100 & 90 & 0 & 10 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}