Latex 多列不居中

Latex 多列不居中

在第一行中,包含 A 的列没有位于块的中间,而是位于底部,无法弄清楚原因。这是乳胶材料

\documentclass[a4paper,10pt]{article}

\usepackage{multirow}

\begin{document}

\begin{table}[H]
\label{table:LG_0^0}
\centering
\caption{Laguerre Gaussian $L_0^0$ Beam improvement}
\begin{tabular}{| m{0.5cm} | m{1.5cm} | m{1cm} | m{3cm} | m{3cm} | m{3cm} |}
\hline
A &
\multicolumn{3}{|c|}{\includegraphics[width=0.4\textwidth, height=0.3\textwidth]{D7_BH.png}} & \multicolumn{2}{|c|}{\includegraphics[width=0.4\textwidth, height=0.3\textwidth]{D7_IL.png}}\\
\hline
&Iterations & error value & Initial Zernike Hologram & Final Zernike Hologram & Final Laser\\
\hline
B & 8 & $1e^{-3}$ & \includegraphics[width=3cm, height=2.5cm]{D7_IH.png} & \includegraphics[width=3cm, height=2.5cm]{D7_FH.png} & \includegraphics[width=3cm, height=2.5cm]{D7_FL.png}\\
\hline
C & 2 & $1e^{-2}$ & \includegraphics[width=3cm, height=2.5cm]{D8_IH.png} & \includegraphics[width=3cm, height=2.5cm]{D8_FH.png} & \includegraphics[width=3cm, height=2.5cm]{D8_FL.png}\\
\hline
\end{tabular}
\end{table}

\end{document}

结果如下 截图1

答案1

首先,如果你给别人一份无法使用的文档,我认为这是对那些试图帮助你的人的侮辱。例如,因为它使用了未知图像,并且没有包含所有必需的软件包。

您的设置存在问题,因为第一行图像排版在c单元格中,而单元格的内容不像m{..}单元格那样垂直居中。因此,这些图像的基线位于底部,并且A与底部对齐。因此,您必须确保这些图像的基线位于其垂直中心。一种实现此目的的方法是使用adjustbox带有export选项的包并将其包含valign=c在 中\includegraphics

\documentclass[a4paper,10pt]{article}

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

\begin{document}

\begin{table}
\label{table:LG_0^0}
\centering
\caption{Laguerre Gaussian $L_0^0$ Beam improvement}
\begin{tabular}{| m{0.5cm} | m{1.5cm} | m{1cm} | m{3cm} | m{3cm} | m{3cm} |}
\hline
A &
\multicolumn{3}{|c|}{\includegraphics[width=0.4\textwidth, height=0.3\textwidth,valign=c]{example-image}} & \multicolumn{2}{|c|}{\includegraphics[width=0.4\textwidth, height=0.3\textwidth,valign=c]{example-image}}\\
\hline
&Iterations & error value & Initial Zernike Hologram & Final Zernike Hologram & Final Laser\\
\hline
B & 8 & $1e^{-3}$ & \includegraphics[width=3cm, height=2.5cm]{example-image} & \includegraphics[width=3cm, height=2.5cm]{example-image} & \includegraphics[width=3cm, height=2.5cm]{example-image}\\
\hline
C & 2 & $1e^{-2}$ & \includegraphics[width=3cm, height=2.5cm]{example-image} & \includegraphics[width=3cm, height=2.5cm]{example-image} & \includegraphics[width=3cm, height=2.5cm]{example-image}\\
\hline
\end{tabular}
\end{table}

\end{document}

在此处输入图片描述

答案2

略有修改彼得·范·奥斯特鲁姆的回答(+1)带有额外的支撑。

在此处输入图片描述

[draft]编辑。@OP,请删除包的可选参数graphicx以恢复您的图像。我无法访问您的文件,因此必须以这种方式编译文档。

代码:

\documentclass[a4paper,10pt]{article}
\usepackage{array}
\usepackage{multirow}
\usepackage{float}
\usepackage[draft]{graphicx}
\usepackage[export]{adjustbox}

\newcolumntype{L}[1]{p{#1}}
\newcommand\xlocstrut[1]{\rule[\dimexpr0.55ex-0.5\dimexpr#1]{0pt}{#1}}


\begin{document}

\begin{table}[H]
  \label{table:LG_0^0}
  \centering
  \caption{Laguerre Gaussian $L_0^0$ Beam improvement}
  \begin{tabular}{| L{0.5cm} | L{1.5cm} | L{1cm} | L{3cm} | L{3cm} | L{3cm} |}
    \hline
    A
    & \multicolumn{3}{c|}{%
      \xlocstrut{0.31\textwidth}
      \includegraphics[width=0.4\textwidth, height=0.3\textwidth, valign=c]{D7_BH.png}}
    & \multicolumn{2}{c|}{%
      \includegraphics[width=0.4\textwidth, height=0.3\textwidth, valign=c]{D7_IL.png}} \\
    \hline
    & Iterations & error value & Initial Zernike Hologram & Final Zernike Hologram & Final Laser \\
    \hline
    B & 8 & $1e^{-3}$
    & \xlocstrut{2.65cm}%
      \includegraphics[width=3cm, height=2.5cm, valign=c]{D7_IH.png}
                 & \includegraphics[width=3cm, height=2.5cm, valign=c]{D7_FH.png}
                               & \includegraphics[width=3cm, height=2.5cm, valign=c]{D7_FL.png} \\
    \hline
    C & 2 & $1e^{-2}$
    & \xlocstrut{2.65cm}%
      \includegraphics[width=3cm, height=2.5cm, valign=c]{D8_IH.png}
                 & \includegraphics[width=3cm, height=2.5cm, valign=c]{D8_FH.png}
                               & \includegraphics[width=3cm, height=2.5cm, valign=c]{D8_FL.png}\\
    \hline
  \end{tabular}
\end{table}

\end{document}

答案3

我把水平方向和垂直方向都设置成居中,这样比较美观。

\documentclass[a4paper,10pt]{article}
\usepackage[margin=1cm]{geometry}
\usepackage{tabularray}
\usepackage[export]{adjustbox}
\begin{document}
\begin{table}
\centering
\caption{Laguerre Gaussian $L_0^0$ Beam improvement}
\label{table:LG_0^0}
\begin{tblr}
{
hlines,
vlines,
colspec    = {Q[c,m,0.5cm]Q[c,m,1.5cm]Q[c,m,1cm]Q[c,m,3cm]Q[c,m,3cm]Q[c,m,3cm]},
cell{1}{2} = {c=3}{},
cell{1}{5} = {c=2}{}
}
A & \includegraphics[width=0.4\textwidth,height=0.3\textwidth,valign=c]{example-image} &             &                                                                  & \includegraphics[width=0.4\textwidth,height=0.3\textwidth,valign=c]{example-image} &                                                                  \\
  & Iterations                                                                         & error value & Initial Zernike Hologram                                         & Final Zernike Hologram                                                             & Final Laser                                                      \\
B & 8                                                                                  & $1e^{-3}$   & \includegraphics[width=3cm,height=2.5cm,valign=c]{example-image} & \includegraphics[width=3cm,height=2.5cm,valign=c]{example-image}                   & \includegraphics[width=3cm,height=2.5cm,valign=c]{example-image} \\
C & 2                                                                                  & $1e^{-2}$   & \includegraphics[width=3cm,height=2.5cm,valign=c]{example-image} & \includegraphics[width=3cm,height=2.5cm,valign=c]{example-image}                   & \includegraphics[width=3cm,height=2.5cm,valign=c]{example-image} \\
\end{tblr}
\end{table}
\end{document}

在此处输入图片描述

相关内容