Bilder und Text in einer Abbildung - LATEX

Bilder und Text in einer Abbildung - LATEX

Ich habe derzeit eine Tabelle, die einige Gates und ihre Operationen zusammenfasst, aber sie sieht fehl am Platz aus und das Format ist nicht korrekt. Weiß jemand, wie man die Bilder mit dem Text ausrichtet? Auch in der Spalte „Effekt“ hätte ich den Text gerne untereinander. Bitte sehen Sie sich den Latex-Code unten und das angehängte Bild an.

\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}

- Latex

Antwort1

Um Ihr Bild vertikal in einer Tabellenzelle zu zentrieren, können Sie \raisebox{-0.5\height}vor dem verwenden \includegraphics. Bei einer einfachen Tabelle und einem Standardbeispielbild erhalten Sie Folgendes mit und ohne\raisebox{-0.5\height}

Bildbeschreibung hier eingeben

Der vollständige Code lautet

\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}

Viel Glück!

Antwort2

Hier ist mein Verwendungsvorschlag valign=c, der im adjustboxPaket enthalten ist. Ich habe auch eine angepasste Version itemizefür die Verwendung innerhalb dieser Tabelle hinzugefügt.

Bildbeschreibung hier eingeben

\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}

verwandte Informationen