我需要一些快速帮助来弄清楚如何在longtable
我使用的地方将文本居中bigdelim/multirow
。
MWE:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[utf8]{inputenc}
%---------- Page Style ----------
\usepackage[top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm]{geometry}
%------------ Tables ------------
\usepackage{dcolumn}
\usepackage{longtable}
\usepackage{multirow,bigdelim} % for curly braces in tables
\usepackage{booktabs} % redefines thickness of lines for table frames
%-------- Chemistry -------------
\usepackage[version=4]{mhchem}
%--------------- END OF PREAMBLE ---------------------%
\begin{document}
\begin{longtable}{@{} l c c c c @{}}
\caption[]{Constants and parameters (modern-day standards).} \\
\hline \addlinespace
Parameter & Definition & Value & Units & Ref \\ \midrule
$R$ & ideal gas law constant & 8.314 & $m^3$Pa/Kmol & \\
$\text{Pa}_\text{atm}$ & pascals per atmosphere & $1.023\times10^5$& Pa & \\
$\kappa_\text{0,O2}$ & \rdelim\}{5}{250pt}[ Henry's Law constants at $T_0$ ] \ldelim\{{5}{35pt}[] & $1.2\times10^{-5}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,CO2}$ & & $3.3\times10^{-4}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,CH4}$ & & $1.4\times10^{-5}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,N2}$ & & $6.4\times10^{-6}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,NH3}$ & & $5.9\times10^{-1}$ & mol/m$^{3}$Pa & S15\\
$D_\text{O2}$ & \rdelim\}{5}{250pt}[ Diffusion constants ] \ldelim\{{5}{22pt}[]& $1.78\times10^{-5}$ & cm/s & CRC\\
$D_\text{CO2}$ & & $1.45\times10^{-5}$ & cm/s & CRC\\
$D_\text{CH4}$ & & $1.55\times10^{-5}$ & cm/s & CRC\\
$D_\text{N2}$ & & $2\times10^{-5}$ & cm/s & CRC\\
$D_\text{NH3}$ & & $1.5\times10^{-5}$ & cm/s & CRC\\
$K_\text{O,rm}$ & half-saturation uptake values for \ce{O2} in remineralization & $12\times10^{-6}$ & mol/L & L17\\
\bottomrule
\end{longtable}
例如,我希望文本“亨利定律常数”位于两个花括号之间的中心。
答案1
- 对于 { 引入了新列
r
- 对于化学公式来说,严格使用宏
\ce{...}
(即使在下标中) - 对于单位使用
siunitx
包 - 第二列的文本未居中,我认为左对齐更好
\documentclass[11pt,letterpaper,twoside]{book}
%---------- Page Style ----------
\usepackage[margin=2.5cm]{geometry}
%------------ Tables ------------
%\usepackage{dcolumn}
\usepackage{bigdelim} % for curly braces in tables
\usepackage{array, booktabs, longtable, multirow} % redefines thickness of lines for table frames
%-------- Chemistry -------------
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}
\begin{longtable}{@{} >{$}l<{$} p{150pt} r @{\hspace{-2em}} S s[per-mode=symbol,
table-unit-alignment=left] l @{}}
\caption[]{Constants and parameters (modern-day standards).} \\
\toprule
Parameter & Definition & & {Value} & {Units} & Ref \\
\midrule
R & ideal gas law constant
& & 8.314 & \cubic\metre\pascal\per\kilo\mole & \\
\text{Pa}_\text{atm}& pascals per atmosphere
& & 1.023e5 & Pa & \\
\addlinespace
\kappa_{\ce{0,O2}} & \rdelim\}{5}{150pt}[ Henry's Law constants at $T_0$]
& \ldelim\{{5}{0pt}[]
& 1.2e-5 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,CO2}} & & & 3.3e-4 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,CH4}} & & & 1.4e-5 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,N2}} & & & 6.4e-6 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,NH3}} & & & 5.9e-1 & \mole\cubic\metre\pascal & S15 \\
\addlinespace
D_{\ce{O2}} & \rdelim\}{5}{150pt}[ Diffusion constants ]
& \ldelim\{{5}{0pt}[]
& 1.78e-5 & \centi\metre\per\second & CRC \\
D_{\ce{CO2}} & & & 1.45e-5 & \centi\metre\per\second & CRC \\
D_{\ce{CH4}} & & & 1.55e-5 & \centi\metre\per\second & CRC \\
D_{\ce{N2}} & & & 2e-5 & \centi\metre\per\second & CRC \\
D_{\ce{NH3}} & & & 1.5e-5 & \centi\metre\per\second & CRC \\
\addlinespace
K_{\ce{O,rm}} & half-saturation uptake values for \ce{O2} in remineralization
& & 12e-6 & \centi\metre\per\second & CRC \\
\bottomrule
\end{longtable}
\end{document}
附录: 对于第二列中垂直和水平居中的文本,引入一个新列并将文本移动到花括号中间的行:
\documentclass[11pt,letterpaper,twoside]{book}
%---------- Page Style ----------
\usepackage[margin=2.5cm]{geometry}
%------------ Tables ------------
%\usepackage{dcolumn}
\usepackage{bigdelim} % for curly braces in tables
\usepackage{array, booktabs, longtable, multirow} % redefines thickness of lines for table frames
%-------- Chemistry -------------
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}
\begin{longtable}{@{} >{$}l<{$} l @{\hspace{-10em}}
>{\centering}p{0.3\linewidth}
r @{\hspace{-2em}} S s[per-mode=symbol,
table-unit-alignment=left] l @{}}
\caption[]{Constants and parameters (modern-day standards).} \\
\toprule
Parameter && Definition
& & {Value} & {Units} & Ref \\
\midrule
R && ideal gas law constant
& & 8.314 & \cubic\metre\pascal\per\kilo\mole & \\
\text{Pa}_\text{atm}
&& pascals per atmosphere
& & 1.023e5 & Pa & \\
\addlinespace
\kappa_{\ce{0,O2}}
& \rdelim\}{5}{0pt}[]
& & \ldelim\{{5}{0pt}[]
& 1.2e-5 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,CO2}}
&& & & 3.3e-4 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,CH4}}
&& Henry's Law constants at $T_0$
& & 1.4e-5 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,N2}}
&& & & 6.4e-6 & \mole\cubic\metre\pascal & S15 \\
\kappa_{\ce{0,NH3}}
&& & & 5.9e-1 & \mole\cubic\metre\pascal & S15 \\
\addlinespace
D_{\ce{O2}} & \rdelim\}{5}{150pt}[]
& & \ldelim\{{5}{0pt}[]
& 1.78e-5 & \centi\metre\per\second & CRC \\
D_{\ce{CO2}} && & & 1.45e-5 & \centi\metre\per\second & CRC \\
D_{\ce{CH4}} && Diffusion constants
& & 1.55e-5 & \centi\metre\per\second & CRC \\
D_{\ce{N2}} && & & 2e-5 & \centi\metre\per\second & CRC \\
D_{\ce{NH3}} && & & 1.5e-5 & \centi\metre\per\second & CRC \\
\addlinespace
K_{\ce{O,rm}}
& & half-saturation uptake values for \ce{O2} in remineralization
& & 12e-6 & \centi\metre\per\second & CRC \\
\bottomrule
\end{longtable}
\end{document}
附录: 还有一个解决方案:不用花括号,但使用彩色表格:
\documentclass[11pt,letterpaper,twoside]{book}
%---------- Page Style ----------
\usepackage[margin=2.5cm]{geometry}
%------------ Tables ------------
\usepackage[table]{xcolor}
\usepackage{array, booktabs, longtable, multirow} %-------- Chemistry -------------
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}
\begin{longtable}{>{$}l<{$}
>{\centering}p{0.3\linewidth}
S
s[per-mode=symbol,
table-unit-alignment=left]
l}
\caption[]{Constants and parameters (modern-day standards).} \\
\toprule
\text{Parameter}
& Definition & {Value} & {Units} & Ref \\
\midrule
R & ideal gas law constant
& 8.314 & \cubic\metre\pascal\per\kilo\mole & \\
\text{Pa}_\text{atm}
& pascals per atmosphere
& 1.023e5 & Pa & \\
\addlinespace
\rowcolor{gray!15}
\kappa_{\ce{0,O2}}
& & 1.2e-5 & \mole\cubic\metre\pascal & S15 \\
\rowcolor{gray!15}
\kappa_{\ce{0,CO2}}
& & 3.3e-4 & \mole\cubic\metre\pascal & S15 \\
\rowcolor{gray!15}
\kappa_{\ce{0,CH4}}
& & 1.4e-5 & \mole\cubic\metre\pascal & S15 \\
\rowcolor{gray!15}
\kappa_{\ce{0,N2}}
& & 6.4e-6 & \mole\cubic\metre\pascal & S15 \\
\rowcolor{gray!15}
\kappa_{\ce{0,NH3}}
& \multirow{-5}{=}{\centering
Henry's Law constants at $T_0$}
& 5.9e-1 & \mole\cubic\metre\pascal & S15 \\
\addlinespace
\rowcolor{gray!15}
D_{\ce{O2}}
& & 1.78e-5 & \centi\metre\per\second & CRC \\
\rowcolor{gray!15}
D_{\ce{CO2}}
& & 1.45e-5 & \centi\metre\per\second & CRC \\
\rowcolor{gray!15}
D_{\ce{CH4}}
& & 1.55e-5 & \centi\metre\per\second & CRC \\
\rowcolor{gray!15}
D_{\ce{N2}}
& & 2e-5 & \centi\metre\per\second & CRC \\
\rowcolor{gray!15}
D_{\ce{NH3}}
& \multirow{-5}{=}{\centering
Diffusion constants}
& 1.5e-5 & \centi\metre\per\second & CRC \\
\addlinespace
K_{\ce{O,rm}} & half-saturation uptake values for \ce{O2} in remineralization
& 12e-6 & \centi\metre\per\second & CRC \\
\bottomrule
\end{longtable}
\end{document}
答案2
这是一个不同的布局建议,它不依赖于大括号和表格中间相对大量的空白:
\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm]{geometry}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage[version=4]{mhchem}
\usepackage{siunitx}
\begin{document}
\begin{longtable}{ >{$}l<{$}
S[table-format=2.3e-1, table-align-exponent=false]
s[per-mode=symbol,table-unit-alignment=left]
l @{}}
\caption[]{Constants and parameters (modern-day standards).} \\
\toprule
\multicolumn{1}{@{}l}{Parameter \& Definition} & {Value} & {Units} & {Ref} \\
\midrule
\multicolumn{4}{@{}l}{ideal gas law constant}\\
\addlinespace
R & 8.314 & \cubic\metre\pascal\per\kilo\mole & \\
\multicolumn{4}{@{}l}{pascals per atmosphere}\\
\text{Pa}_\text{atm}& 1.023e5 & Pa & \\
\addlinespace
\multicolumn{4}{@{}l}{Henry's Law constants at $T_0$}\\
\kappa_{\ce{0,O2}} & 1.2e-5 & \mole\per\cubic\metre\per\pascal & S15 \\
\kappa_{\ce{0,CO2}} & 3.3e-4 & \mole\per\cubic\metre\per\pascal & S15 \\
\kappa_{\ce{0,CH4}} & 1.4e-5 & \mole\per\cubic\metre\per\pascal & S15 \\
\kappa_{\ce{0,N2}} & 6.4e-6 & \mole\per\cubic\metre\per\pascal & S15 \\
\kappa_{\ce{0,NH3}} & 5.9e-1 & \mole\per\cubic\metre\per\pascal & S15 \\
\addlinespace
\multicolumn{4}{@{}l}{Diffusion constants}\\
D_{\ce{O2}} & 1.78e-5 & \centi\metre\per\second & CRC \\
D_{\ce{CO2}} & 1.45e-5 & \centi\metre\per\second & CRC \\
D_{\ce{CH4}} & 1.55e-5 & \centi\metre\per\second & CRC \\
D_{\ce{N2}} & 2e-5 & \centi\metre\per\second & CRC \\
D_{\ce{NH3}} & 1.5e-5 & \centi\metre\per\second & CRC \\
\addlinespace
\multicolumn{4}{@{}l}{half-saturation uptake values for \ce{O2} in remineralization}\\
K_{\ce{O,rm}} & 12e-6 & \centi\metre\per\second & CRC \\
\bottomrule
\end{longtable}
\end{document}
答案3
您可以使用 来制作该{NiceTabular}
表nicematrix
。
\documentclass[landscape]{book}
\usepackage[top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm]{geometry}
\usepackage{booktabs}
\usepackage{nicematrix}
\usepackage[version=4]{mhchem}
\begin{document}
\begin{NiceTabular}{@{} l c c c c @{}}
\toprule
Parameter & Definition & Value & Units & Ref \\ \midrule
$R$ & ideal gas law constant & 8.314 & $m^3$Pa/Kmol & \\
$\text{Pa}_\text{atm}$ & pascals per atmosphere & $1.023\times10^5$& Pa & \\
$\kappa_\text{0,O2}$ & \Block{5-1}{Henry's Law constants at $T_0$} & $1.2\times10^{-5}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,CO2}$ & & $3.3\times10^{-4}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,CH4}$ & & $1.4\times10^{-5}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,N2}$ & & $6.4\times10^{-6}$ & mol/m$^{3}$Pa & S15\\
$\kappa_\text{0,NH3}$ & & $5.9\times10^{-1}$ & mol/m$^{3}$Pa & S15\\[2pt]
$D_\text{O2}$ & \Block{5-1}{Diffusion constants} & $1.78\times10^{-5}$ & cm/s & CRC\\
$D_\text{CO2}$ & & $1.45\times10^{-5}$ & cm/s & CRC\\
$D_\text{CH4}$ & & $1.55\times10^{-5}$ & cm/s & CRC\\
$D_\text{N2}$ & & $2\times10^{-5}$ & cm/s & CRC\\
$D_\text{NH3}$ & & $1.5\times10^{-5}$ & cm/s & CRC\\
$K_\text{O,rm}$ & half-saturation uptake values for \ce{O2} in remineralization & $12\times10^{-6}$ & mol/L & L17\\
\bottomrule
\CodeAfter
\SubMatrix{.}{4-1}{8-1}{\}}
\SubMatrix{.}{9-1}{13-1}{\}}
\SubMatrix{\{}{4-3}{8-3}{.}
\SubMatrix{\{}{9-3}{13-3}{.}
\end{NiceTabular}
\end{document}
你至少需要 5.10 (2021-02-05) 版本nicematrix
。如果你使用 Overleaf,你可以上传最新版本的文件nicematrix.sty
。如果你使用 Overleaf,你可以在项目的目录中SVN 服务器来自 TeXLive 的网站。
您需要多次编译(因为nicematrix
使用 PGF/Tikz 节点)。