考虑一下这个MWE:
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{table}[H]
\centering\scriptsize
\begin{tabular}{ccccc}
\toprule
\arraybackslash Medi\c{c}\~{a}o (cm)\\
\midrule
Ensaios & 1 & 2 & 3 & M\'{e}dia\\
\hline Comprimento (b) (cm) & 49,90 & 49,80 & 49,80 & 49,83\\
\hline Largura (a) (cm) & 2,10 & 2,00 & 2,05 & 2,05\\
\hline Dist\^{a}ncia do CM (cm) & 24,95 & 24,90 & 24,90 & 24,90\\
\hline d (dist\^{a}ncia do CM at\'{e} ao eixo de rota\c{c}\~{a}o) (cm)
& 19,20 & 19,25 & 19,15 & 19,20\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
我想将文本“Medições”放在第一行的中间tabular
。我该怎么做?
答案1
\documentclass{article}
\usepackage{booktabs}
\begin{document}
\centering\scriptsize
\begin{tabular}{ccccc}
\toprule
\multicolumn{5}{c}{Medi\c{c}\~{a}o (cm)}\\
\midrule
Ensaios & 1 & 2 & 3 & M\'{e}dia\\
\hline Comprimento (b) (cm) & 49,90 & 49,80 & 49,80 & 49,83\\
\hline Largura (a) (cm) & 2,10 & 2,00 & 2,05 & 2,05\\
\hline Dist\^{a}ncia do CM (cm) & 24,95 & 24,90 & 24,90 & 24,90\\
\hline d (dist\^{a}ncia do CM at\'{e} ao eixo de rota\c{c}\~{a}o) (cm)
& 19,20 & 19,25 & 19,15 & 19,20\\
\bottomrule
\end{tabular}
\end{document}
答案2
您不应使用太多水平线,无论如何,避免混合使用 'normal'\hrule
和\rules
from booktabs
。我建议改为cellspace
在单元格上方和下方使用一些垂直填充。此外,您还可以在第 2 至第 5 列的小数点逗号上进行垂直对齐:
\documentclass[11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{amstext}
\usepackage{ragged2e}
\usepackage{mathtools,float,geometry}
\usepackage{booktabs,array,tabularx,threeparttablex, cellspace, siunitx}
\setlength\cellspacetoplimit{3pt}
\setlength\cellspacebottomlimit{3pt}
\usepackage{subfig}
\usepackage{scalefnt}
\begin{document}
\begin{table}[H]
\scriptsize \centering
\begin{tabular}{@{}Cc*{4}{S[table-format = 2.2,output-decimal-marker={,}]}@{}}
\toprule
\multicolumn{5}{Cc}{Medição (cm)} \\
\midrule
Ensaios & {1} & {2} & 3 & {Média} \\
Comprimento (b) (cm) & 49,90 & 49,80 & 49,80 & 49,83 \\
Largura (a) (cm) & 2,10 & 2,00 & 2,05 & 2,05 \\
Distância do CM (cm) & 24,95 & 24,90 & 24,90 & 24,90 \\
d (distância do CM até ao eixo de rotação) (cm)
& 19,20 & 19,25 & 19,15 & 19,20 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}