图形副标题(subfloat)

图形副标题(subfloat)

如何为由两个独立图形组成的图形添加副标题?我希望副标题位于两个图形下方。非常感谢您的帮助!

\begin{figure}[ht]
 \caption{XX}
 \centering
    \subfloat[XXX1]{\includegraphics[width=0.5\textwidth]{Figure1a.jpg}\label{fig:f1}}
  \hfill
  \subfloat[XXX2]{\includegraphics[width=0.5\textwidth]{Figure1b.jpg}\label{fig:f2}}
\end{figure}

答案1

像这样?

enter image description here

它是通过使用包获得的stackengine

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{stackengine}% for put note about sorce below image
\usepackage{graphicx}
\usepackage[font=small]{caption}
\usepackage{url}
\usepackage{tabularx}

\begin{document}
    \begin{figure}[hb]
    \centering
\def\stackalignment{r}
\begin{tabularx}{\hsize}{*2{>{\centering\arraybackslash}X}}
\caption{Left figure}
\label{fig:left}
\stackunder{\includegraphics[width=\linewidth]{example-image-a}}%
           {\scriptsize%
            Source: \url{http://tex.stackexchange.com/}}
    &
\caption{Right figure}
\label{fig:right}
\stackunder{\includegraphics[width=\linewidth]{example-image-b}}%
           {\scriptsize%
            Source: \url{http://tex.stackexchange.com/}}
\end{tabularx}
    \end{figure}
\end{document}

或者使用包\copyrightbox

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage[font=small]{caption}
\usepackage{copyrightbox}
\usepackage{url}

\usepackage{tabularx}

\begin{document}
    \begin{figure}[hb]
    \centering
\begin{tabularx}{\hsize}{*2{>{\centering\arraybackslash}X}}
\caption{Left figure}
\label{fig:left}
\copyrightbox[b]{\includegraphics[width=\linewidth]{example-image-a}}%
           {Source: \url{http://tex.stackexchange.com/}}
    &
\caption{Right figure}
\label{fig:right}
\copyrightbox[b]{\includegraphics[width=\linewidth]{example-image-b}}%
           {Source: \url{http://tex.stackexchange.com/}}
\end{tabularx}
    \end{figure}

\end{document}

附註: 如果该图像有两个子图。使用\copyrightbox[b]{...}{...}和选项position=topsubfig

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}

\usepackage[font=small]{caption}
\usepackage{copyrightbox}
\usepackage{url}

\usepackage[position=top]{subfig}

\begin{document}
    \begin{figure}[hb]
    \centering
    \caption{Figure caption}
\subfloat[Left sub-figure   \label{fig:left}]{
\copyrightbox[b]{\includegraphics[width=0.45\linewidth]{example-image-a}}%
           {Source: \url{http://tex.stackexchange.com/}}
}                        
\hfil
\subfloat[Right sub-figure  \label{fig:right}]{
\copyrightbox[b]{\includegraphics[width=0.45\linewidth]{example-image-b}}%
           {Source: \url{http://tex.stackexchange.com/}}
}
    \end{figure}
\end{document}

附註(2): 似乎该包\copyrightbox不支持将带有源信息的文本置于图像下方的中央。使用stackengine没有这个限制。下面是该包position=top的一个示例和选项:subfig

enter image description here

右图下方有灰色文字(仅供比较)。MWE:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[table]{xcolor}
\usepackage{graphicx}
\usepackage{stackengine}% for put note about sorce below image
\usepackage[font=small]{caption}
\usepackage[position=top]{subfig}
\usepackage{url}

\begin{document}
    \begin{figure}[hb]
    \centering
\def\stackalignment{c}% <-- define alignment of stack
    \caption{Figure caption}
\subfloat[Left sub-figure   \label{fig:left}]{
\stackunder{\includegraphics[width=0.45\linewidth]{example-image-a}}%
           {\scriptsize%
            Source: \url{http://tex.stackexchange.com/}}
}
\hfil
\subfloat[Right sub-figure  \label{fig:right}]{
\stackunder{\includegraphics[width=0.45\linewidth]{example-image-b}}%
           {\scriptsize\color{gray}% <-- if you prefer to have text in gray
            Source: \url{http://tex.stackexchange.com/}}
}
    \end{figure}
\end{document}

相关内容