![垂直居中表格条目](https://linux22.com/image/303141/%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%E8%A1%A8%E6%A0%BC%E6%9D%A1%E7%9B%AE.png)
我希望第二个“扩散率”垂直放置在其明显范围内
平均能量损失
\documentclass{scrreprt}
\usepackage{amsmath}
\begin{document}
\begin{table}
\centering
\begin{tabular}{c c c c}
\hline
Variable &Region Variable &Value &Unit \\ \hline
area &$A$ &0 &m\\ \hline
&$L_{1}$ &0 &m\\
lengths &$L_{2}$ &0 &m\\
&$L_{3}$ &0 &m\\ \hline
&$D_{1}$\\
diffusivity &$D_{2}$\\
&$D_{3}$\\ \hline
diffusivity &$D_{1}$\\
&$D_{2}$\\ \hline
\end{tabular}
\caption{xyz}
\label{tab:para}
\end{table}
\end{document}
答案1
您可以使用makecell
包来完成此操作(代码更少,因为它允许在单元格内换行)。我还使用了包booktabs
,以使行之间的垂直间距不那么紧密:
\documentclass{scrreprt}
\usepackage{amsmath}
\usepackage{booktabs, makecell}
\begin{document}
\begin{table}
\centering
\begin{tabular}{r c c c}
\toprule
\makecell{Variable} & \makecell{Region\\ Variable} &Value &Unit \\
\midrule
area &$A$ &0 &m\rlap{\textsuperscript 2}\\
\addlinespace[1.5ex]
lengths &\makecell{$L_{1}$\\$L_{2}$\\$L_{3}$ }&\makecell{0\\0\\0} &\makecell{m\\m\\m}\\
\addlinespace[1.5ex]
diffusivity &\makecell{$D_{1}$\\$D_{2}$\\$D_{3}$}\\
\addlinespace[1.5ex]
diffusivity &\makecell{$D_{1}$\\$D_{2}$}
&\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
答案2
\documentclass{article}
\usepackage{multirow}
\begin{document}
\begin{table}[htbp]
\centering
\begin{tabular}{c c c c}
\hline
Variable &Region Variable &Value &Unit \\ \hline
area &$A$ &0 &m\\ \hline
&$L_{1}$ &0 &m\\
lengths &$L_{2}$ &0 &m\\
&$L_{3}$ &0 &m\\ \hline
&$D_{1}$ &0\\
diffusivity &$D_{2}$ &0\\
&$D_{3}$ &0\\ \hline
\multirow{ 2}{*}{diffusivity} & $D_{1}$ & 0 & \\
& $D_{1}$ & 0 & \\ \hline
\end{tabular}
\caption{A test caption}
\label{table2}
\end{table}
\end{document}