我正在尝试创建下图
下面是我的示例代码。我似乎无法让 AR 处于正确的位置。每次我改变 x 位置时,整个图形都会移动。我该如何将所有东西固定到位?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{float}
\usepackage{subfig}
\title{test}
\author{test}%
\date{January 2022}
\begin{document}
\maketitle
\tikzset
{%
label/.style={scale=0.7,fill=white,thick,draw=white!80,anchor=south west,align=left},
}
\def\lsep{-0.2}
\begin{figure}
\centering
\hspace{-7.5cm}
\subfloat{
\begin{tikzpicture}
\node[label] at (-0.5,\lsep) {\strut$A^{L}$};
\node[label] at (-0.5+4,\lsep) {\strut$A^{R}$};
{\includegraphics[width=0.4\columnwidth,height=5\columnheight]{example-image-a}}\hspace{1cm}
{\includegraphics[width=0.4\columnwidth,height=5\columnheight]{example-image-a}}
\end{tikzpicture}
}
\end{figure}
\section{Introduction}
\end{document}
答案1
试试这个代码。这四个元素是相对定位的。因此它们tikzpicture
会作为一个整体移动。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{float}
\usepackage{subfig}
\usepackage{showframe}
\title{test}
\author{test}%
\date{January 2022}
\begin{document}
\maketitle
\tikzset
{%
label/.style={scale=0.7,
draw,
fill=white,
thick,
draw=white!80,
above right= -1.5ex and -4.0ex,
align=left
},
}
\begin{figure}[H]
\centering
\subfloat{
\begin{tikzpicture}
\node[inner sep=0] (image1) {\includegraphics[width=0.4\linewidth,height=0.02\linewidth]{example-image-a}};
\node[inner sep=0, right=1cm of image1.east] (image2) {\includegraphics[width=0.4\linewidth,height=0.02\linewidth]{example-image-b}};
\node[label] at (image1.west) {\strut$A^{L}$};
\node[label] at (image2.west) {\strut$A^{R}$};
\end{tikzpicture}
}
\end{figure}
\section{Introduction}
\end{document}