我制作了一个表格,其中包含位于不同行的几个方程式。我需要按=
符号对齐它们。例如这个:
我的代码是:
\documentclass{article}
\usepackage{tabularray}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage[version=4]{mhchem}
\usepackage{mathtools}
\UseTblrLibrary{booktabs, siunitx,amsmath}
\begin{document}
\begin{longtblr}[
caption={test},
label={tab:test}
]{
colsep=0.5pt,
colspec={c X[c,2.3] c
},rowhead=1
}
\toprule
one&two&{{{$\mathrm{R}^2$(three)}}} \\
\midrule
\SetCell[r=6]{c} 1 5+23&\SetCell[r=6]{c} {{{$\begin{aligned} [\ce{Ca^2+}]=&-3.19301 \mathrm{pH}^{3}\\&-5.11013 \mathrm{pH}^{2}\\&- 991.914 \mathrm{pH}\\&+10^{0.0420576 \mathrm{pH}+3.90459}\\&-7521.77\end{aligned}$}}}&\SetCell[r=6]{c} 0.996176\\
& & \\
& & \\
& & \\
& & \\
& & \\
\hline[dotted]
\SetCell[r=5]{c} 2 5+23&\SetCell[r=5]{c} {{{$\begin{aligned} [\ce{HCO3-}]=&-0.540849 \mathrm{pH}^{3}\\&+12.9563\mathrm{pH}^{2}\\&- 103.195 \mathrm{pH}\\&+10^{ \mathrm{pH}-103.348}\\&+274.589\end{aligned}$}}}&\SetCell[r=5]{c} 0.996175\\
& & \\
& & \\
& & \\
& & \\
\bottomrule
\end{longtblr}
\end{document}
答案1
尽管我看到了使用aligned
环境的诱惑,但我认为如果您已经在使用表格,那么让表格进行对齐可能会更简单;表格在这方面很擅长。
我的意思是引入一列表示等式的左边,一列表示等式的右边,如下所示:
\documentclass{article}
\usepackage{tabularray}
\usepackage{siunitx}
\usepackage{tabularx}
\usepackage[version=4]{mhchem}
\usepackage{mathtools}
\UseTblrLibrary{booktabs, siunitx,amsmath}
\begin{document}
\begin{longtblr}[
caption={test},
label={tab:test}
]{
colsep=0.5pt,
colspec={c X[r,1] @{\ } X[l,1.5,$] c
},
rowhead=1
}
\toprule
one & \SetCell[c=2]{c} two & & $\mathrm{R}^2$ (three) \\
\midrule
\SetCell[r=5]{c,m}1 5+23 & [\ce{Ca^2+}] = & -3.19301 \mathrm{pH}^{3} & \SetCell[r=5]{c,m}0.996176\\
& & -5.11013 \mathrm{pH}^{2} & \\
& & - 991.914 \mathrm{pH} & \\
& & +10^{0.0420576 \mathrm{pH}+3.90459} & \\
& & -7521.77 & \\
\hline[dotted]
\SetCell[r=5]{c,m} 2 5+23 & [\ce{HCO3-}] = & -0.540849 \mathrm{pH}^{3} & \SetCell[r=5]{c,m}0.996175\\
& & +12.9563\mathrm{pH}^{2} & \\
& & -103.195 \mathrm{pH} & \\
& & +10^{ \mathrm{pH}-103.348} & \\
& & +274.589 & \\
\bottomrule
\end{longtblr}
\end{document}
我认为代码的可读性也提高了许多。