5

I am trying to center the equations vertically within their respective cells, but they are always aligned with the first line no matter what. This is a minimal working example of what I have so far:

\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}

How one can make the equations align to the center of the cell and not the first line?

  • 1
  • @TimothyTruckle: This question seem to be about horizontal centering while the OP requested vertically centered equations. – leandriis Dec 31 '17 at 13:24
  • Yes, the problem is the vertical alignment... May I add an image to clarify? – opengisapprendice Dec 31 '17 at 13:25
  • @leandriis but the suggested solution should be adjustable for vertical alignment too – Timothy Truckle Dec 31 '17 at 13:27
  • 1
    @TimothyTruckle Adding \centering to the definition of the corresponding column does not lead to vertically centered equations as you can see in the output image of theohadoulis' answer. The equations are still vertically centered with respect to the first line of a cell in the first column, not with respect to both lines of a cell in the first column. – leandriis Dec 31 '17 at 13:34
  • The standard approach to vertically center contents in cells (replacing p columns by m columns (for X columns see here: https://tex.stackexchange.com/a/343329/134144)) does not seem to work in this specific case due to makecells vertical alignment option. – leandriis Dec 31 '17 at 13:42
  • @leandriis there is some workaround that could allow to avoid using makecells? – opengisapprendice Dec 31 '17 at 13:51
  • @opengisapprendice: You don't have to avoid using makecell if you chose the correct alignent option. See my answer: https://tex.stackexchange.com/a/408290/134144 – leandriis Dec 31 '17 at 14:29

2 Answers2

4

In the following example, I have changed the alignment specifiers of the \makecell commands from lt to 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

Edit: To allow for better readability of the equations, the following MWE includes \addlinespace commands as suggested by Bernard in the comments.

\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

Edit 2: Here is another variant that does not require the use of the makecell package. I have changed the column type of the first column to X, as the command \newline that I used to indicate line breaks inside cells can only be used in p or X type columns. Additionally, I have inserted \renewcommand\tabularxcolumn[1]{m{#1}} to allow for vertically centered alignment. I have therefore also changed the column type of the third column from p to m.

\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}
leandriis
  • 62,593
1

Just put >{\centering}p{7cm} instead of 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}

Output

enter image description here

chadoulis
  • 702
  • 1
  • 6
  • 21