插图的子图的标签嵌入在图片中去的方法

发布于 2023-01-09 22:29:15

有用户希望将子图的标签都贴在图片上面去,这样可以让子图的显示更清晰,特别是异形排版的时候比较好用。下面的代码可以给你些启发。
image.png

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subcaption,tikz}


\DeclareCaptionFormat{suboverlay}{\gdef\subcapoverlay{(\thesubfigure) #3\par}}
\DeclareCaptionStyle{suboverlay}{format=suboverlay}


\captionsetup[subfigure]{format=suboverlay}
\newcommand{\subcaptionOverlay}[1]{%
  \subcaption{}%
  \begin{tikzpicture}
    \node [inner sep=0,anchor=south west]at (-3ex,-2ex) (image) {#1};
    \draw node [black] {\subcapoverlay};
  \end{tikzpicture}%
}

\begin{document}

\begin{figure}%
  \begin{minipage}{.25\textwidth}
    \begin{subfigure}{\textwidth}
      \centering\textbf{Title 1}
      \subcaptionOverlay{\includegraphics[width=\textwidth]{example-image}}
    \end{subfigure}
    \begin{subfigure}{\textwidth}
      \centering\textbf{Title 3}
      \subcaptionOverlay{\includegraphics[width=\textwidth]{example-image}}
    \end{subfigure}
  \end{minipage}
  \hfill
  \begin{minipage}{.25\textwidth}
    \begin{subfigure}{\textwidth}
      \centering\textbf{Title 2}
      \subcaptionOverlay{\includegraphics[width=\textwidth]{example-image}}
    \end{subfigure}
    \begin{subfigure}{\textwidth}
      \centering\textbf{Title 4}
      \subcaptionOverlay{\includegraphics[width=\textwidth]{example-image}}
    \end{subfigure}
  \end{minipage}
  \hfill
  \begin{minipage}{.45\textwidth}
    \begin{subfigure}{\textwidth}
      \centering\textbf{Title 5}
      \subcaptionOverlay{\includegraphics[width=\textwidth]{example-image}}
    \end{subfigure}
  \end{minipage}
\end{figure}


\end{document}

选自这里:https://tex.stackexchange.com/questions/473505/different-positions-for-labels-and-captions-of-subfigures

0 条评论

发布
问题