如何在图形旁边插入文本并对齐两个相互叠放的图形?

如何在图形旁边插入文本并对齐两个相互叠放的图形?

如何在图形旁边添加文本并保持图形对齐?我尝试使用\includegraphics[left]\includegraphics[right]命令,但您可以看到图形和文本仍然没有对齐。

我正在关注这里的解决方案语法类似于 \centering 左右?

\begin{figure*}
\centering
\subfloat{
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {Left Hand \includegraphics[width=0.9\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip,left]{figures/qualitative/segmentation-l.png}};
\end{tikzpicture}}
\subfloat{
\begin{tikzpicture}
\node[anchor=south west,inner sep=0] (image) at (0,0) {Right Hand \includegraphics[width=0.9\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip,left]{figures/qualitative/segmentation-r.png}};
\end{tikzpicture}}
\end{figure*}

在此处输入图片描述

答案1

一个简单的替代方案。

A

\documentclass{article}

\usepackage{graphicx}

\begin{document}
        
    \noindent\begin{tabular}{@{}rl}     
        Left Hand  &\includegraphics[width=0.9\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}\\
        Right Hand &\includegraphics[width=0.9\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-b}\\
    \end{tabular}   

\end{document}

或者使用包subcaption(或subfig)使用两个节点,一个用于“手”,另一个用于图形。

\documentclass{article}

\usepackage{graphicx}

\usepackage{subcaption}% <<<<<<<<<<<<<<<<<

\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\tikzset{
    Hands/.style={
    below left = 0.2ex and 3.0ex,
    anchor= east,
    inner sep=0,
    text width=15ex,  
    align = right, 
     },
}

\begin{figure}
    \centering
    \begin{subfigure}{\linewidth}
        \begin{tikzpicture}
            \node[inner sep=0] (image) {\includegraphics[width=0.9\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-a}};
            \node[Hands] (label) at (image.west) {\strut Left Hand};
        \end{tikzpicture}
    \end{subfigure}\\
    \begin{subfigure}{\linewidth}
        \begin{tikzpicture}
            \node[inner sep=0] (image) {\includegraphics[width=0.9\textwidth,height=0.02\textwidth,trim={0 0 0 0},clip]{example-image-b}};
            \node[Hands] (label) at (image.west) {\strut Right Hand};
        \end{tikzpicture}
    \end{subfigure}
\end{figure}

\end{document}

相关内容