![如何制作一个 Latex 表格,其中一列包含文本,另一列包含多行方程式?](https://linux22.com/image/445433/%E5%A6%82%E4%BD%95%E5%88%B6%E4%BD%9C%E4%B8%80%E4%B8%AA%20Latex%20%E8%A1%A8%E6%A0%BC%EF%BC%8C%E5%85%B6%E4%B8%AD%E4%B8%80%E5%88%97%E5%8C%85%E5%90%AB%E6%96%87%E6%9C%AC%EF%BC%8C%E5%8F%A6%E4%B8%80%E5%88%97%E5%8C%85%E5%90%AB%E5%A4%9A%E8%A1%8C%E6%96%B9%E7%A8%8B%E5%BC%8F%EF%BC%9F.png)
我正在制作表格来描述我的模型,但我不知道如何在表格中放入多行方程。我尝试使用多行,但结果非常奇怪,我尝试在单元格内使用 align*,但出现了错误。
我最接近的工作是在单元格内使用表格,但布局有点奇怪:文本单元格顶部有奇怪的填充,而方程式单元格没有填充。
\documentclass{report}
\usepackage[table,xcdraw]{xcolor}
\usepackage{multirow,rotating,lscape,amsmath}
\usepackage{booktabs,siunitx,ragged2e}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\label{submodels-for-derived-variables}
\begin{tabular}{|p{0.3\textwidth}|p{0.3\textwidth}|p{0.4\textwidth}|}
\textbf{Modelled variable}
& \textbf{Parameters}
& \textbf{Formula}\\
\hline
Fire spread probability from cell \textit{a} to cell \textit{b}, \textit{plain} topography
& Grass flammability parameter (\textit{f}), grass cell \textit{b} biomass (\textit{Bb})
& $F_{\text{ab}} = \text{fB}_{b}$ \\
\hline
Fire spread probability from cell \textit{a} to cell \textit{b}, non-plain topography
& Grass flammability parameter (f), grass biomass (Bb), slope between \textit{a} and \textit{b} (\textit{sab})
& \begin{tabular}{lll}
$F_t =fB_b,$ & $s >= 0.4,$ \\
$F_t =( s+0.6 )fB_b,$ &$s \in (-0.4,0.4)$\\
$F_t =0.2fB_b,$ &$s <= -0.4 $ \\
\end{tabular}\\
\hline
\end{tabular}
\end{table}
\end{landscape}
\end{document}
答案1
您可以使用很酷的新tabularray
包:
\documentclass{report}
\usepackage[table,xcdraw]{xcolor}
\usepackage{multirow,rotating,lscape,amsmath}
\usepackage{booktabs,siunitx,ragged2e}
\usepackage{tabularray}
\begin{document}
\begin{landscape}
\begin{table}
\centering
\begin{tblr}{vlines,hlines,colspec={X[l,valign=m]X[l,valign=m]Q[l,valign=m]}}
\textbf{Modelled variable}
& \textbf{Parameters}
& \textbf{Formula} \\
Fire spread probability from cell \textit{a} to cell \textit{b}, \textit{plain} topography
& Grass flammability parameter (\textit{f}), grass cell \textit{b} biomass (\textit{Bb})
& $F_{\text{ab}} = \text{fB}_{b}$ \\
Fire spread probability from cell \textit{a} to cell \textit{b}, non-plain topography
& Grass flammability parameter (f), grass biomass (Bb), slope between \textit{a} and \textit{b} (\textit{sab})
& \begin{tblr}{@{}ll@{}}
$F_t =fB_b,$ & $s >= 0.4,$ \\
$F_t =( s+0.6 )fB_b,$ & $s \in (-0.4,0.4)$\\
$F_t =0.2fB_b,$ & $s <= -0.4 $ \\
\end{tblr}\\
\end{tblr}
\end{table}
\end{landscape}
\end{document}
答案2
可以通过将可选参数传递给 来修复对齐问题tabular
。以下是使用以下方法重新制作的表格:booktabs
和tabularx
:
\documentclass{article}
\usepackage[margin=1in,landscape]{geometry}
\usepackage{booktabs,amsmath,tabularx}
\begin{document}
\begin{table}
\centering
\begin{tabularx}{\linewidth}{ p{0.3\linewidth} p{0.3\linewidth} X }
\toprule
\textbf{Modelled variable} &
\textbf{Parameters} &
\textbf{Formula} \\
\midrule
Fire spread probability from cell \textit{a} to cell \textit{b}, \textit{plain} topography &
Grass flammability parameter (\textit{f}), grass cell \textit{b} biomass (\textit{Bb}) &
$F_{\text{ab}} = \text{fB}_{b}$ \\
\addlinespace
Fire spread probability from cell \textit{a} to cell \textit{b}, non-plain topography &
Grass flammability parameter (f), grass biomass (Bb), slope between \textit{a} and \textit{b} (\textit{sab}) &
\begin{tabular}[t]{ @{} l l @{} }
$F_t = fB_b$, & $s \geq 0.4$, \\
$F_t = (s + 0.6) fB_b$, & $s \in (-0.4, 0.4)$, \\
$F_t = 0.2 fB_b$, & $s \leq -0.4$.
\end{tabular} \\
\bottomrule
\end{tabularx}
\end{table}
\end{document}
注意使用来设置操作\begin{tabular}[t]
的锚点。tabular
[t]
您的原始表格对于页面来说太宽;列宽总计为\textwidth
,但每列周围都有水平填充,以及垂直规则宽度。在这种情况下,如果您想要一个全宽表格,但不确定列宽的计算,请考虑使用tabularx
(至少有一X
列)。
答案3
使用amsmath
和tabularray
(2021Q 版本)包。
编辑:
变量的书写似乎不一致。我尝试在数学模式下书写所有变量。如果这不是您想要的,请将这些更改恢复为您的符号(使用\textit
...)
\documentclass{report}
\usepackage{pdflscape}
\usepackage{amsmath}
\usepackage{xcolor}
\usepackage{tabularray}
\begin{document}
\begin{landscape}
\begin{table}
\begin{tblr}{vlines,hlines,
colspec={X[l,m] X[l,m] X[l,m,$]},
row{1} = {font=\bfseries, mode=text, c}
}
Modelled variable
& Parameters
& Formula \\
Fire spread probability from cell $a$ to cell $b$, plain topography
& Grass flammability parameter $(f)$, grass cell $b$ biomass $(B_b)$
& F_{\text{ab}} = fB_{b} \\
Fire spread probability from cell $a$ to cell $b$, non-plain topography
& Grass flammability parameter $(f)$, grass biomass $(B_{b})$, slope between $a$ and $b$ $(\mathit{sab})$
& F_t = \begin{cases}
f B_b, & s \geq 0.4, \\
(s + 0.6)fB_b, & s \in (-0.4,0.4) \\
0.2fB_b, & s \leq -0.4 \\
\end{cases} \\
\end{tblr}
\end{table}
\end{landscape}
\end{document}