图中的图像和文本 - LATEX

图中的图像和文本 - LATEX

我目前有一张表格,总结了一些门及其操作,但它看起来不合适,格式也不正确。有人知道如何将图像与文本对齐吗?此外,在“效果”列中,我希望文本一个接一个地排列。请参阅下面的 Latex 代码和附加的图像。

\begin{figure}
  \centering 
  \begin{threeparttable}
    \begin{tabular}{cccc}
    %{m{15mm} m{70mm} m{18mm}}
    Gates  & Circuit Symbol & Matrix Representation & Effect\\
     \midrule\midrule



Pauli-X  & 

\includegraphics[scale = 1 , trim= {50 50 32 25}, clip
]{Chapter2/Figs/Raster/x.png} &

$U(\pi, 0 , \pi) = 
\begin{pmatrix}
0 & 1 \\
1& 0 
\end{pmatrix}$ &

\begin{itemize}
\item $\emph{X}\ket{0}\longrightarrow\ket{1}$ 
\item $\emph{X}\ket{1}\longrightarrow\ket{0}$
\end{itemize}

\\%new row

Pauli-Y  & 

\includegraphics[scale = 1 , trim= {50 50 32 25}, clip
]{Chapter2/Figs/Raster/y.png} &    

$U(\pi , \frac{\pi}{2},\frac{\pi}{2}) = 
\begin{pmatrix}
0 & -i \\
i & 0 
\end{pmatrix}$ & 

\begin{itemize}
\item $\emph{Y}\ket{0}\longrightarrow i\ket{1}$ 
\item $\emph{Y}\ket{1}\longrightarrow-i\ket{0}$,
\end{itemize}

\\%new row

Pauli-Z  & 

\includegraphics[scale = 1 , trim= {50 50 32 25}, clip
]{Chapter2/Figs/Raster/z.png} &

$U(0 , 0 , \pi) = 
\begin{pmatrix}
1 & 0 \\
0 & -1 
\end{pmatrix}$ & 

\begin{itemize}
\item $\emph{Z}\ket{0}\longrightarrow\ket{0}$  
\item $\emph{Z}\ket{1}\longrightarrow-\ket{1}$
\end{itemize}

\\%new row

Hadamard  &
\includegraphics[scale = 1 , trim= {50 50 32 25}, clip
]{Chapter2/Figs/Raster/h.png} & 

$U(\frac{\pi}{2},0 , \pi) = \frac{1}{\sqrt{2}}
\begin{pmatrix}
1 & 1 \\
1 & -1 
\end{pmatrix}$ &

\begin{itemize}
\item $\emph{H}\ket{0}\longrightarrow \frac{1}{\sqrt{2}}(\ket{0}+\ket{1})$  
\item $\emph{H}\ket{1}\longrightarrow \frac{1}{\sqrt{2}}(\ket{0}-\ket{1})$  \end{itemize}

\\% end of rows
    \midrule\midrule
    \end{tabular}
    \begin{tablenotes}
  \caption{Names, circuit symbols and unitary matrix representation for common single qubit gates.}

\end{tablenotes}
\end{threeparttable}
  \end{figure}

- 乳胶

答案1

要将图像垂直居中于表格单元格内,您可以\raisebox{-0.5\height}在 之前使用\includegraphics。使用简单的表格和标准示例图像,这是使用和不使用 时获得的结果。\raisebox{-0.5\height}

在此处输入图片描述

完整代码如下

\documentclass[leqno]{article}
\usepackage{graphicx}
\usepackage{booktabs}
\begin{document}
%
%
\begin{table}
    \centering
    \caption{Vertical centering of figures in cells.}
    \begin{tabular}{lll}
        \toprule
        Column1 & Column2 & Column3 \\
        \midrule
        Cols1 & \raisebox{-0.5\height}{\includegraphics[width=2cm]{example-image}} & Cols3 \\
        Cols1 & \raisebox{-0.5\height}{\includegraphics[width=4cm]{example-image}} & Cols3 \\
        Cols1 & Cols2 & Cols3 \\
        \bottomrule
    \end{tabular}
\end{table}
%
\begin{table}
    \centering
    \caption{NO vertical centering of figures in cells.}
    \begin{tabular}{lll}
        \toprule
        Column1 & Column2 & Column3 \\
        \midrule
        Cols1 & \includegraphics[width=2cm]{example-image} & Cols3 \\
        Cols1 & \includegraphics[width=4cm]{example-image} & Cols3 \\
        Cols1 & Cols2 & Cols3 \\
        \bottomrule
    \end{tabular}
\end{table}
%

\end{document}

祝你好运!

答案2

这是我建议使用valign=c该软件包附带的adjustbox。我还添加了一个自定义版本以itemize供此表内使用。

在此处输入图片描述

\documentclass{article}
\usepackage{graphicx} 
\usepackage[export]{adjustbox}
\usepackage{amsmath}

\usepackage{booktabs}
%\usepackage{threeparttable}
\usepackage{array}
\usepackage{physics}

\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{wide=0pt, leftmargin= * ,label=\textbullet}

\begin{document}
\begin{figure}

  \centering 
%  \begin{threeparttable}
    \begin{tabular}{cccm{37mm}}
    %{m{15mm} m{70mm} m{18mm}}
    Gates  & Circuit Symbol & Matrix Representation & Effect\\
     \midrule\midrule



Pauli-X  & 

\includegraphics[width=1cm, valign=c]{example-image} &

$U(\pi, 0 , \pi) = 
\begin{pmatrix}
0 & 1 \\
1& 0 
\end{pmatrix}$ &

\begin{tabitem}
\item $\emph{X}\ket{0}\longrightarrow\ket{1}$ 
\item $\emph{X}\ket{1}\longrightarrow\ket{0}$
\end{tabitem}

\\%new row

Pauli-Y  & 

\includegraphics[width=1cm, valign=c]{example-image} &    

$U(\pi , \frac{\pi}{2},\frac{\pi}{2}) = 
\begin{pmatrix}
0 & -i \\
i & 0 
\end{pmatrix}$ & 

\begin{tabitem}
\item $\emph{Y}\ket{0}\longrightarrow i\ket{1}$ 
\item $\emph{Y}\ket{1}\longrightarrow-i\ket{0}$,
\end{tabitem}

\\%new row

Pauli-Z  & 

\includegraphics[width=1cm, valign=c]{example-image} &

$U(0 , 0 , \pi) = 
\begin{pmatrix}
1 & 0 \\
0 & -1 
\end{pmatrix}$ & 

\begin{tabitem}
\item $\emph{Z}\ket{0}\longrightarrow\ket{0}$  
\item $\emph{Z}\ket{1}\longrightarrow-\ket{1}$
\end{tabitem}

\\%new row

Hadamard  &
\includegraphics[width=1cm, valign=c]{example-image} & 

$U(\frac{\pi}{2},0 , \pi) = \frac{1}{\sqrt{2}}
\begin{pmatrix}
1 & 1 \\
1 & -1 
\end{pmatrix}$ &

\begin{tabitem}
\item $\emph{H}\ket{0}\longrightarrow \frac{1}{\sqrt{2}}(\ket{0}+\ket{1})$  
\item $\emph{H}\ket{1}\longrightarrow \frac{1}{\sqrt{2}}(\ket{0}-\ket{1})$  
\end{tabitem}

\\% end of rows
    \midrule\midrule
    \end{tabular}
%    \begin{tablenotes}
%
%\end{tablenotes}
%\end{threeparttable}
    \caption{Names, circuit symbols and unitary matrix representation for common single qubit gates.}

  \end{figure}
  \end{document}

相关内容