使用命令在图片标题中换行

使用命令在图片标题中换行

我在使用自定义图形标题命令时遇到了问题。我有这个命令:

\newcommand{\figCaption[3]}{\justifying\textbf{\small\caption[#1] #2.}\space{#3}}

以及如下图所示的图形代码:

\begin{figure}[H]
\centering
\begin{overpic}[width=0.95\linewidth]{picture}
\end{overpic}
\figCaption{rough description} {detailed description}.}
\label{fig:Sec3_mYFP}
\end{figure}

不幸的是,结果是这样的:

在此处输入图片描述

我的目标是不要在第一个字母后切断粗略描述,而是将其全部放在一行中。对于较长的描述,它们应该放在一个块中,其中 Figure## 和粗略描述为粗体。

我能做什么吗?

答案1

由于您没有发布完整的 mwe 也没有发布所需输出的图像,所以我不知道这是否正是您所需要的。

请参阅我的代码中的注释。您不必将我标记为“仅用于测试目的”的内容添加到您的文档中。

\documentclass{article}
\usepackage{mwe}% only for testing purpose
\usepackage{float}
\usepackage{graphicx}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=period,format=hang,
indention=0cm]{caption}
\newcommand{\figCaption}[2]{\caption[#1]{\textbf{#1}\newline #2}}
\begin{document}
\listoffigures% if you would like the list of figures, remember to run pdflatex twice
\section{A section}
\blindtext% only for testing purpose
\begin{figure}[H]% H sould be avoided
    \centering
    \includegraphics[width=.95\textwidth]{example-image-a}% it's not clear to me why you used overpic
    \figCaption{Rough description.}{Detailed description. The detailed description is very very very very very very very very very very very very very very very very very very very very very very very very very very very very very long.}\label{fig:Sec3_mYFP}
\end{figure}
\blindtext% only for testing purpose
\end{document}

在此处输入图片描述

相关内容