表格单元格中方程的垂直对齐

表格单元格中方程的垂直对齐

我试图将方程式垂直居中在各自的单元格内,但无论如何它们始终与第一行对齐。这是我目前拥有的一个最小工作示例:

\documentclass[titlepage, twoside, 11pt]{book}
\usepackage[a4paper, margin=2.5cm]{geometry} %doc dimensions
\usepackage{booktabs}
\usepackage{makecell} % Tabular column heads and multilined cells
\usepackage{siunitx} % (SI) units package
\sisetup{
    range-phrase=\text{--},
    range-units=single,
}
\usepackage{tabularx} %Tabulars with adjustable-width columns
\newcolumntype{a}{>{\raggedright\arraybackslash}X}
\newcolumntype{b}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}[ht]
\begin{tabularx}{\textwidth}{l a p{7cm} l}
\toprule
Parameter & Reference & Formula & Unit\\
\midrule
\makecell[lt]{Leaf water\\content (LWC)} & Author &
$\displaystyle LWC=\frac{AWT}{A}=\frac{W_f-W_d}{A}$
& \si{\kilo\gram\per\meter\squared}\\
\makecell[lt]{Equivalent water\\thickness (EWT)} & Author &
$EWT=\frac{AWT}{\rho_w \cdot A}=\frac{W_f-W_d}{\rho_w \cdot A}$
& \si{\kilo\gram\per\meter\squared}\\
\makecell[lt]{Relative Water Content\\by fresh biomass (RWC$_f$)} & Author &
$RWC_f=\frac{AWC}{W_f}=\frac{W_f-W_d}{W_f}$
& - \\
\makecell[lt]{Relative Water Content\\by dry biomass (RWC$_d$)} & Author &
$RWC_{d}=\frac{AWC}{W_D}=\frac{W_f-W_d}{W_d}$
& - \\
\makecell[lt]{Fuel moisture content\\(FMC)} & Author &
$FMC=RWC_{d}\cdot100=\frac{W_f-W_d}{W_f} \cdot 100$
& \% \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

如何才能使方程式与单元格中心对齐而不是第一行?

答案1

在下面的示例中,我将\makecell命令的对齐说明符从lt更改为lc

\documentclass[titlepage, twoside, 11pt]{book}
\usepackage[a4paper, margin=2.5cm]{geometry} %doc dimensions
\usepackage{booktabs}
\usepackage{makecell} % Tabular column heads and multilined cells
\usepackage{siunitx} % (SI) units package
\sisetup{
    range-phrase=\text{--},
    range-units=single,
}
\usepackage{tabularx} %Tabulars with adjustable-width columns

\newcolumntype{a}{>{\raggedright\arraybackslash}X}
\newcolumntype{b}{>{\centering\arraybackslash}X}
\begin{document}

\begin{table}[ht]
\begin{tabularx}{\textwidth}{l a p{7cm} l}
\toprule
Parameter & Reference & Formula & Unit\\
\midrule
\makecell[lc]{Leaf water\\content (LWC)} & Author &
$\displaystyle LWC=\frac{AWT}{A}=\frac{W_f-W_d}{A}$
& \si{\kilo\gram\per\meter\squared}\\
\makecell[lc]{Equivalent water\\thickness (EWT)} & Author &
$EWT=\frac{AWT}{\rho_w \cdot A}=\frac{W_f-W_d}{\rho_w \cdot A}$
& \si{\kilo\gram\per\meter\squared}\\
\makecell[lc]{Relative Water Content\\by fresh biomass (RWC$_f$)} & Author &
$RWC_f=\frac{AWC}{W_f}=\frac{W_f-W_d}{W_f}$
& - \\
\makecell[lc]{Relative Water Content\\by dry biomass (RWC$_d$)} & Author &
$RWC_{d}=\frac{AWC}{W_D}=\frac{W_f-W_d}{W_d}$
& - \\
\makecell[lc]{Fuel moisture content\\(FMC)} & Author &
$FMC=RWC_{d}\cdot100=\frac{W_f-W_d}{W_f} \cdot 100$
& \% \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

enter image description here

编辑:为了使方程式更易于阅读,以下 MWE 包含了\addlinespaceBernard 在评论中建议的命令。

\documentclass[titlepage, twoside, 11pt]{book}
\usepackage[a4paper, margin=2.5cm]{geometry} %doc dimensions
\usepackage{booktabs}
\usepackage{makecell} % Tabular column heads and multilined cells
\usepackage{siunitx} % (SI) units package
\sisetup{
    range-phrase=\text{--},
    range-units=single,
}
\usepackage{tabularx} %Tabulars with adjustable-width columns
\newcolumntype{a}{>{\raggedright\arraybackslash}X}
\newcolumntype{b}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}[ht]
\begin{tabularx}{\textwidth}{l a p{7cm} l}
\toprule
Parameter & Reference & Formula & Unit\\
\midrule
\addlinespace[10pt]
\makecell[lc]{Leaf water\\content (LWC)} & Author &
$\displaystyle LWC=\frac{AWT}{A}=\frac{W_f-W_d}{A}$
& \si{\kilo\gram\per\meter\squared}\\
\addlinespace[5pt]
\makecell[lc]{Equivalent water\\thickness (EWT)} & Author &
$EWT=\frac{AWT}{\rho_w \cdot A}=\frac{W_f-W_d}{\rho_w \cdot A}$
& \si{\kilo\gram\per\meter\squared}\\
\addlinespace[5pt]
\makecell[lc]{Relative Water Content\\by fresh biomass (RWC$_f$)} & Author &
$RWC_f=\frac{AWC}{W_f}=\frac{W_f-W_d}{W_f}$
& - \\
\addlinespace[5pt]
\makecell[lc]{Relative Water Content\\by dry biomass (RWC$_d$)} & Author &
$RWC_{d}=\frac{AWC}{W_D}=\frac{W_f-W_d}{W_d}$
& - \\
\addlinespace[5pt]
\makecell[lc]{Fuel moisture content\\(FMC)} & Author &
$FMC=RWC_{d}\cdot100=\frac{W_f-W_d}{W_f} \cdot 100$
& \% \\
\addlinespace[5pt]
\bottomrule
\end{tabularx}
\end{table}

\end{document}

enter image description here

编辑2:这是另一种不需要使用该makecell包的变体。我已将第一列的列类型更改为X,因为我用来指示单元格内换行符的命令\newline只能在pX类型的列中使用。此外,我已插入\renewcommand\tabularxcolumn[1]{m{#1}}以允许垂直居中对齐。因此,我还将第三列的列类型从更改pm

\documentclass[titlepage, twoside, 11pt]{book}
\usepackage[a4paper, margin=2.5cm]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\sisetup{
    range-phrase=\text{--},
    range-units=single,
}

\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}

\begin{document}

\begin{table}[ht]
\begin{tabularx}{\textwidth}{X l m{7cm} l}
\toprule
Parameter & Reference & Formula & Unit\\
\midrule
\addlinespace[5pt]
Leaf water \newline content (LWC) & Author &
$\displaystyle LWC=\frac{AWT}{A}=\frac{W_f-W_d}{A}$
& \si{\kilo\gram\per\meter\squared}\\
\addlinespace[5pt]
Equivalent water \newline thickness (EWT) & Author &
$EWT=\frac{AWT}{\rho_w \cdot A}=\frac{W_f-W_d}{\rho_w \cdot A}$
& \si{\kilo\gram\per\meter\squared}\\
\addlinespace[5pt]
Relative Water Content \newline by fresh biomass (RWC$_f$) & Author &
$RWC_f=\frac{AWC}{W_f}=\frac{W_f-W_d}{W_f}$
& - \\
\addlinespace[5pt]
Relative Water Content \newline by dry biomass (RWC$_d$) & Author &
$RWC_{d}=\frac{AWC}{W_D}=\frac{W_f-W_d}{W_d}$
& - \\
\addlinespace[5pt]
Fuel moisture content \newline (FMC) & Author &
$FMC=RWC_{d}\cdot100=\frac{W_f-W_d}{W_f} \cdot 100$
& \% \\
\addlinespace[5pt]
\bottomrule
\end{tabularx}
\end{table}

\end{document}

答案2

只需 >{\centering}p{7cm}改为p{7cm}

\documentclass[titlepage, twoside, 11pt]{book}
\usepackage[a4paper, margin=2.5cm]{geometry} %doc dimensions
\usepackage{booktabs}
\usepackage{makecell} % Tabular column heads and multilined cells
\usepackage{siunitx} % (SI) units package
\sisetup{
    range-phrase=\text{--},
    range-units=single,
}
\usepackage{tabularx} %Tabulars with adjustable-width columns
\newcolumntype{a}{>{\raggedright\arraybackslash}X}
\newcolumntype{b}{>{\centering\arraybackslash}X}

\begin{document}

\begin{table}[ht]
\begin{tabularx}{\textwidth}{l a >{\centering}p{7cm} l}
\toprule
Parameter & Reference & Formula & Unit\\
\midrule
\makecell[lt]{Leaf water\\content (LWC)} & Author &
$\displaystyle LWC=\frac{AWT}{A}=\frac{W_f-W_d}{A}$
& \si{\kilo\gram\per\meter\squared}\\
\makecell[lt]{Equivalent water\\thickness (EWT)} & Author &
$EWT=\frac{AWT}{\rho_w \cdot A}=\frac{W_f-W_d}{\rho_w \cdot A}$
& \si{\kilo\gram\per\meter\squared}\\
\makecell[lt]{Relative Water Content\\by fresh biomass (RWC$_f$)} & Author &
$RWC_f=\frac{AWC}{W_f}=\frac{W_f-W_d}{W_f}$
& - \\
\makecell[lt]{Relative Water Content\\by dry biomass (RWC$_d$)} & Author &
$RWC_{d}=\frac{AWC}{W_D}=\frac{W_f-W_d}{W_d}$
& - \\
\makecell[lt]{Fuel moisture content\\(FMC)} & Author &
$FMC=RWC_{d}\cdot100=\frac{W_f-W_d}{W_f} \cdot 100$
& \% \\
\bottomrule
\end{tabularx}
\end{table}

\end{document}

输出

enter image description here

相关内容