0

I want my figure captions to have the following format:

  • Figure number is bold
  • First couple of words are the title of the figure and always bold
  • Rest of caption is not bold

Here's my MWE:

\documentclass{report}

\usepackage{graphicx}
\usepackage[labelfont=bf,textfont=bf]{caption}

\begin{document}
\begin{figure}
    \centering
    \includegraphics[width=\textwidth]{cat}
    \caption{A cat} depicted sitting at the table.
\end{figure}
\end{document}

This makes the following:

enter image description here

I don't like this because the caption shouldn't be centered and also the non-bold text shouldn't be on a new line. It should look like this:

enter image description here

And the name of the figure in the list of figures (not shown) should be only the bold portion, not the whole thing.

Unacceptable solutions:

  • Removing textfont=bf and then bolding A cat - figure caption will be too long in list of figures.
  • Using the short title parameter of \caption - I will end up typing every title twice, it's annoying and violates DRY.
  • Simply add \captionsetup{format=plain, justification=justified, font=bf}. – Bernard Feb 23 at 0:41
  • @Bernard, I think OP wants only the first 2 words in bold (and they should go to lof). – Sigur Feb 23 at 1:20
  • @sigur: Yes, I had misread. Your solution is perfectly fine. – Bernard Feb 23 at 9:34
3

What about this? Use the command

\mycaption[A cat]{depicted sitting at the table.} 

In this case you don't need to type it twice; you only need to split it.

enter image description here

enter image description here

\documentclass{report}
\usepackage{graphicx}
\usepackage[labelfont=bf]{caption}
\newcommand{\mycaption}[2][]{\caption[#1]{\textbf{#1} #2}}

\begin{document}
\listoffigures    
\begin{figure}\centering
    \includegraphics[width=\textwidth]{example-image-a}
    \mycaption[A cat]{depicted sitting at the table.}
\end{figure}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.