乳胶表的内容没有与多行单元格的中心对齐。
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[document]{ragged2e}
\usepackage{array}
\usepackage{multirow}
\usepackage{float}
\usepackage{makecell}
\begin{document}
\begin{table}[hbt!]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
er & \thead{erg\\eg\\ \text{[ff]}} & \thead{egeg \\ \text{[fff]}} & $ff_ef [-]$ & \thead{wf\\wf} & \thead{wfwff\\wfw} \\ \hline
evev & 433 & 345 & 0.334 & evevev & evev \\ \hline
\multirow{3}{*}{\thead{multivitamin\\tea}} & egeg & \multirow{3}{*}{411} & eg & ege egeg & grteg \\ \cline{2-2}\cline{4-6}
& ege & & eg & \thead{eg eg\\eg} & \thead{eg eg\\ege\\eg} \\ \cline{2-2}\cline{4-6}
& egg & & egeg & eg eg & egeg \\ \hline
\end{tabular}
\caption{title}\label{tab1}
\end{table}
\end{document}
和multivitamin tea
没有411
与单元格的中心对齐。
答案1
它没有居中,因为行数参数假设行中只有一行单元格。如果您计算三行中的实际行数,则应使用 \multirow{5}。另请注意,对于微调,行数可以有小数部分。
我使用 简化了代码,\multirowcell{…}
因为您加载了makecell
,并且(不相关),当在几何中时,所有边距都具有相同的值,您可以简单地将其用作参数[margin = …]
。
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage[margin=2cm]{geometry}
\usepackage[document]{ragged2e}
\usepackage{array}
\usepackage{multirow}
\usepackage{float}
\usepackage{makecell}
\begin{document}
\begin{table}[hbt!]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
er & \thead{erg\\eg\\ \text{[ff]}} & \thead{egeg \\ \text{[fff]}} & $ff_ef [-]$ & \thead{wf\\wf} & \thead{wfwff\\wfw} \\ \hline
evev & 433 & 345 & 0.334 & evevev & evev \\ \hline
\multirowcell{5}{multivitamin\\tea} & egeg & \multirow{3}{*}{411} & eg & ege egeg & grteg \\ \cline{2-2}\cline{4-6}
& ege & & eg & \thead{eg eg\\eg} & \thead{eg eg\\ege\\eg} \\ \cline{2-2}\cline{4-6}
& egg & & egeg & eg eg & egeg \\ \hline
\end{tabular}
\caption{title}\label{tab1}
\end{table}
\end{document}
答案2
这是您的表格的三个版本。在第一个版本中,我只更正了错误的第一个参数,\multirow
并保留了不一致的字体大小。在第二个表格中,我还更改了字体大小,以确保较小的字体仅用于列标题。在最后一个表格中,我使用了nicematrix
及其\Block
命令而不是\multirow
并确保整个表格的字体大小一致。
\documentclass[12pt,a4paper]{article}
\usepackage{amsmath,amssymb}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[document]{ragged2e}
\usepackage{array}
\usepackage{multirow}
\usepackage{float}
\usepackage{makecell}
\usepackage{nicematrix} % only needed for the last example.
\begin{document}
\begin{table}[hbt!]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
er & \thead{erg\\eg\\ {[ff]}} & \thead{egeg \\ {[fff]}} & $ff_ef [-]$ & \thead{wf\\wf} & \thead{wfwff\\wfw} \\ \hline
evev & 433 & 345 & 0.334 & evevev & evev \\ \hline
\multirow{5}{*}{\thead{multivitamin\\tea}} & egeg & \multirow{5}{*}{411} & eg & ege egeg & grteg \\ \cline{2-2}\cline{4-6}
& ege & & eg & \thead{eg eg\\eg} & \thead{eg eg\\ege\\eg} \\ \cline{2-2}\cline{4-6}
& egg & & egeg & eg eg & egeg \\ \hline
\end{tabular}
\caption{corrected multirow option to vertically center contents}\label{tab1}
\end{table}
\begin{table}[hbt!]
\centering
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\thead{er} & \thead{erg\\eg\\ {[ff]}} & \thead{egeg \\ {[fff]}} & \thead{$ff_ef [-]$} & \thead{wf\\wf} & \thead{wfwff\\wfw} \\ \hline
evev & 433 & 345 & 0.334 & evevev & evev \\ \hline
\multirow{5}{*}{\makecell{multivitamin\\tea}} & egeg & \multirow{5}{*}{411} & eg & ege egeg & grteg \\ \cline{2-2}\cline{4-6}
& ege & & eg & \makecell{eg eg\\eg} & \makecell{eg eg\\ege\\eg} \\ \cline{2-2}\cline{4-6}
& egg & & egeg & eg eg & egeg \\ \hline
\end{tabular}
\caption{corrected multirow option to vertically center contents + smaller font size in column headers only}\label{tab1}
\end{table}
\begin{table}[hbt!]
\centering
\begin{NiceTabular}{cccccc}[hvlines]
er & \makecell{erg\\eg\\ {[ff]}} & \makecell{egeg \\ {[fff]}} & $ff_ef [-]$ & \makecell{wf\\wf} & \makecell{wfwff\\wfw} \\
evev & 433 & 345 & 0.334 & evevev & evev \\
\Block{3-1}{multivitamin\\tea} & egeg & \Block{3-1}{411} & eg & ege egeg & grteg \\
& ege & & eg & \makecell{eg eg\\eg} & \makecell{eg eg\\ege\\eg} \\
& egg & & egeg & eg eg & egeg \\ \hline
\end{NiceTabular}
\caption{vertically centered content using nicematrix and its Block command + consistent font size throughout the table}\label{tab1}
\end{table}
\end{document}