如何垂直对齐多行表中的方程式?

如何垂直对齐多行表中的方程式?

我正在为我的一篇研究论文构建一个相当复杂的表格,结合了长方程式和图表。有人能帮我将右侧列垂直对齐,使其位于左侧每个图表的中间吗?

\usepackage{booktabs}
\usepackage{array}
\usepackage{multirow}

\begin{table}[]
\begin{tabular}{@{}c|ccc|ccc@{}}
\toprule
Multi-layer Network & $l_i^k$                                          & $l_j^k$                                                                                                                                                      & $l_m^k$                                          & $l_i^{k'}$          & $l_j^{k'}$          & $l_m^{k'}$          \\ \midrule
\includegraphics[scale=0.15]{Network1.png}                    & $\frac{1}{1-\beta}$                              & $\frac{1}{1-\beta}$                                                                                                                                          & $\frac{1}{1-\beta}$                              & $\frac{1}{1-\beta}$ & $\frac{1}{1-\beta}$ & $\frac{1}{1-\beta}$ \\ \midrule
\includegraphics[scale=0.15]{Network2.png}                    & $\frac{1+\beta}{\frac{1}{2}-\psi-\beta^2}$       & $\frac{1+\beta}{\frac{1}{2}-\psi-\beta^2}$                                                                                                                   & $\frac{1}{1-\beta}$                              & $1+\beta l_i^k$     & $1+\beta l_j^k$     & $\frac{1}{1-\beta}$ \\ \midrule
\includegraphics[scale=0.15]{Network3.png}                    & $\frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2}$ & $\frac{\left ( 1+\beta \right )\left ( \frac{1}{2}-\beta^2+2\psi\right )}{\left ( \frac{1}{3} -\beta^2\right )\left ( \frac{1}{2} -\beta^2\right )-2\psi^2}$ & $\frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2}$ & $1+\beta l_i^k$     & $1+\beta l_j^k$     & $1+\beta l_m^k$     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \midrule
                    &                                                  &                                                                                                                                                              &                                                  &                     &                     &                     \\ \bottomrule
\end{tabular}
\end{table}

在此处输入图片描述

答案1

以下是一些建议(无特定顺序):

  • 摆脱所有垂直规则并替换(几乎)所有\midrule指令,\addlinespace以消除大量视觉混乱。

  • 从一个tabular环境切换到另一个array环境,然后高兴地一举删除数十个出现的$(内联数学模式启动器和终止器)。

  • 加载amsmath包并将\includegraphics语句装入包装器中matrix以使图形图像垂直居中。

  • \frac{1}{1-\beta}用替换所有实例1/(1-\beta),然后观察分数表达式立即变得更加清晰。

在此处输入图片描述

\documentclass[demo]{article} % remove 'demo' option in real document
\usepackage{booktabs,graphicx,amsmath}
\usepackage[letterpaper,margin=1in]{geometry} % set page parameters suitably

\begin{document}
\begin{table}
\[
\begin{array}{@{} *{7}{c} @{}}
\toprule
\mbox{Multi-layer network} & l_i^k & l_j^k & l_m^k & l_i^{k'} & l_j^{k'} & l_m^{k'} \\
\cmidrule[\lightrulewidth](r){1-1}
\cmidrule[\lightrulewidth](lr){2-4} 
\cmidrule[\lightrulewidth](l){5-7}
\addlinespace
\begin{matrix} 
   \includegraphics[width=1cm,height=1cm]{Network1a.png} &
   \includegraphics[width=1cm,height=1cm]{Network1b.png}
\end{matrix}
& 1/(1-\beta) & 1/(1-\beta) & 1/(1-\beta) 
& 1/(1-\beta) & 1/(1-\beta) & 1/(1-\beta) \\ 
\addlinespace
\begin{matrix} 
   \includegraphics[width=1cm,height=1cm]{Network2a.png} &
   \includegraphics[width=1cm,height=1cm]{Network2b.png}
\end{matrix}
& \frac{1+\beta}{\frac{1}{2}-\psi-\beta^2} 
& \frac{1+\beta}{\frac{1}{2}-\psi-\beta^2} 
& 1/(1-\beta) & 1+\beta l_i^k & 1+\beta l_j^k & 1/(1-\beta) \\ 
\addlinespace
\begin{matrix} 
   \includegraphics[width=1cm,height=1cm]{Network3a.png} &
   \includegraphics[width=1cm,height=1cm]{Network3b.png}
\end{matrix}
& \frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2} 
& \frac{(1+\beta)\left( \frac{1}{2}-\beta^2+2\psi\right)}{
  \left( \frac{1}{3}-\beta^2\right)\left( \frac{1}{2}-\beta^2\right)-2\psi^2} 
& \frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2} 
& 1+\beta l_i^k & 1+\beta l_j^k & 1+\beta l_m^k \\ 
\bottomrule
\end{array}
\]
\end{table}
\end{document}

答案2

您可以使用adjustbox和 其valign键。我通过使用 简化了您的输入

>{$\displaystyle}c<{$}

这样您就可以省去所有$符号。根据实际的文本宽度,您可能能够使用\small而不是\footnotesize

\documentclass{article}

\usepackage{graphicx}
\usepackage[export]{adjustbox}
\usepackage{array}
\usepackage{booktabs}

\begin{document}

\begin{table}[htp] % <--- NOT []

\footnotesize
\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
  @{\extracolsep{\fill}}
  c % the images
  *{6}{>{$\displaystyle}c<{$}} % the formulas
  @{}
}
\toprule
\begin{tabular}{@{}c@{}} Multi-layer \\ Network \end{tabular} &
  l_i^k & l_j^k & l_m^k & l_i^{k'} & l_j^{k'} & l_m^{k'} \\
\midrule
\includegraphics[valign=c,width=1.6cm]{example-image} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} \\
\midrule
\includegraphics[valign=c,width=1.6cm]{example-image} &
  \frac{1+\beta}{\frac{1}{2}-\psi-\beta^2} &
  \frac{1+\beta}{\frac{1}{2}-\psi-\beta^2} &
  \frac{1}{1-\beta} &
  1+\beta l_i^k &
  1+\beta l_j^k &
  \frac{1}{1-\beta} \\
\midrule
\includegraphics[valign=c,width=1.6cm]{example-image} &
  \frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2} &
  \frac{(1+\beta)(\frac{1}{2}-\beta^2+2\psi)}
       {(\frac{1}{3}-\beta^2)(\frac{1}{2} -\beta^2)-2\psi^2} &
  \frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2} &
  1+\beta l_i^k &
  1+\beta l_j^k &
  1+\beta l_m^k \\
\bottomrule
\end{tabular*}

\end{table}

\end{document}

在此处输入图片描述

答案3

使用tabularrayadjustbox包,使用图像大小和基线的通用设置:

\documentclass{article}

\usepackage[export]{adjustbox} % it load graphicx too
\usepackage{tabularray}
\UseTblrLibrary{booktabs}

\begin{document}
    \begin{table}[htp] % <--- NOT []
\adjustboxset{width=\linewidth,valign=M}
\footnotesize
\begin{tblr}{hline{3-Y} = {dashed, 0.2pt},
              colsep = 3pt,
             colspec = {@{}  X[c,m] 
                        *{6}{Q[c,mode=dmath]}
                        @{}},
              rowsep = 3pt
            }
    \toprule
Multi-layer Network
    & l_i^k & l_j^k & l_m^k & l_i^{k'} & l_j^{k'} & l_m^{k'} \\
    \midrule
\adjincludegraphics{example-image-duck} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} &
  \frac{1}{1-\beta} \\
\adjincludegraphics{example-image-duck} &
  \frac{1+\beta}{\frac{1}{2}-\psi-\beta^2} &
  \frac{1+\beta}{\frac{1}{2}-\psi-\beta^2} &
  \frac{1}{1-\beta} &
  1+\beta l_i^k &
  1+\beta l_j^k &
  \frac{1}{1-\beta} \\
\adjincludegraphics{example-image-duck} &
  \frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2} &
  \frac{(1+\beta)(\frac{1}{2}-\beta^2+2\psi)}
       {(\frac{1}{3}-\beta^2)(\frac{1}{2} -\beta^2)-2\psi^2} &
  \frac{1+\beta+\psi l_j^k}{\frac{1}{2}-\beta^2} &
  1+\beta l_i^k &
  1+\beta l_j^k &
  1+\beta l_m^k \\
    \bottomrule
\end{tblr}
    \end{table}
\end{document}

在此处输入图片描述

相关内容