居中子字幕(包括换行符)

居中子字幕(包括换行符)

我在这里已经找到了有关该主题的一个已回答的问题: 使子标题居中 复制\captionsetup[subfigure]{justification=centering}并不能帮助我思考,因为我使用的是不同的包。

我希望我的标题和副标题与下面的文本对齐。就在我的图片下面。有什么建议吗?

多谢

\documentclass{article}
\usepackage{subfig}
\usepackage[labelfont=bf, justification=justified]{caption}
\usepackage[demo]{graphicx}% Remove demo option in real document

\begin{document}    
\begin{figure}
%   \captionsetup[subfigure]{justification=centering}
    \centering  
    \subfloat[Subcaption one \newline including a linebreak ]   {
    \includegraphics[width=0.2\textwidth]{image1}
    }
    \hspace{1cm}
    \subfloat[Subcaption two \newline including a linebreak]
    {
    \includegraphics[width=0.2\textwidth]{image2}
    }   
    \caption{Figure caption \newline with additional text right here}
\end{figure}

\begin{center}
This is correctly justified Text \\ including a longer linebreak than blabla.
\end{center}
\end{document}

答案1

该命令\subfloat有两个可选参数,第一个是 LoF 条目。

因此,用如下代码替换

\subfloat[Subcaption one \newline including a linebreak]

\subfloat[Subcaption one including a linebreak][Subcaption one \\ including a linebreak]

完成工作。

MWE(我还用 删除了一些虚假空格%

\documentclass{article}
\usepackage{subfig}
\usepackage[labelfont=bf, justification=justified]{caption}
\usepackage[demo]{graphicx}% Remove demo option in real document

\begin{document}
\begin{figure}
   \captionsetup[subfigure]{justification=centering}
    \centering
    \subfloat[Subcaption one including a linebreak][Subcaption one \\ including a linebreak]
    {%
    \includegraphics[width=0.2\textwidth]{image1}%
    }%
    \hspace{1cm}%
    \subfloat[Subcaption two including a linebreak][Subcaption two \\ including a linebreak]
    {%
    \includegraphics[width=0.2\textwidth]{image2}%
    }
    \caption{Figure caption \\ with additional text right here}
\end{figure}

\begin{center}
This is correctly justified Text \\ including a longer linebreak than blabla.
\end{center}

\end{document}

输出:

在此处输入图片描述

相关内容