当subfigures
使用包添加时subcaption
,包在 pdf 中生成的标签showlabels
不可读。
包裹在包裹subcaption
之前就已包含showlabels
。我该如何纠正这个问题?
\usepackage{subcaption}
\usepackage{showlabels}
\begin{figure}
\centering
\begin{subfigure}[t]{0.48\linewidth}
\includegraphics[width=1\linewidth]{plots/membrane/error_H1_rel_1d_100_11_11.pdf}
\caption{Full RBs}
\label{fig:membrane_recon_error_full_RB}
\end{subfigure}
\begin{subfigure}[t]{0.48\linewidth}
\includegraphics[width=1\linewidth]{plots/membrane/error_H1_rel_1d_100_11_7.pdf}
\caption{Full primal RB and truncated dual RB}
\label{fig:membrane_recon_error_truncated_RB}
\end{subfigure}
\caption{Reconstruction error for points in and outside training set}
\label{fig:membrane_recon_error}
\end{figure}
答案1
这将创建一个新的环境queuelabels,以防止showlabel在其中重叠标签。它使用url和marginnote包来格式化和打印标签。
注意:标签需要运行两次才能显示。
\documentclass{article}
\usepackage{subcaption}
\usepackage{marginnote}
\usepackage{url}
\usepackage{graphicx}
\let\normallabel=\label
\usepackage{showlabels}
\newsavebox{\labelbox}
\newenvironment{queuelabels}{\def\label##1{\normallabel{##1}%
\global\setbox\labelbox=\vbox{%
\hsize=\marginparwidth\raggedright
\ifvoid\labelbox\else \unvbox\labelbox\vskip\baselineskip\fi
\url{##1}}}}%
{\dimen0=\ht\labelbox
\marginnote{\unvbox\labelbox}[-\dimen0]}
\begin{document}
\begin{figure}
\begin{queuelabels}
\centering
\begin{subfigure}[t]{0.48\linewidth}
\includegraphics[width=1\linewidth]{example-image-a}
\caption{Full RBs}
\label{fig:membrane_recon_error_full_RB}
\end{subfigure}
\begin{subfigure}[t]{0.48\linewidth}
\includegraphics[width=1\linewidth]{example-image-b}
\caption{Full primal RB and truncated dual RB}
\label{fig:membrane_recon_error_truncated_RB}
\end{subfigure}
\caption{Reconstruction error for points in and outside training set}
\label{fig:membrane_recon_error}
\end{queuelabels}
\end{figure}
\end{document}