如何制作一个 Latex 表格,其中一列包含文本,另一列包含多行方程式?

如何制作一个 Latex 表格,其中一列包含文本,另一列包含多行方程式?

我正在制作表格来描述我的模型,但我不知道如何在表格中放入多行方程。我尝试使用多行,但结果非常奇怪,我尝试在单元格内使用 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。以下是使用以下方法重新制作的表格:booktabstabularx

在此处输入图片描述

\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

使用amsmathtabularray(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}

在此处输入图片描述

相关内容