4

I would like to know if it is possible to combine the two next codes, i.e have a caption with a descrition and put only the short title into the listoffigures of TOC ?

This one

\caption[short title for list of figures]{long title for text}

with the custom caption with title + description Set different styles for "main" caption and description

\documentclass{article}
\newcommand\mycaption[2]{\caption{\textbf{#1}\newline\small#2}}
\begin{document}
\begin{figure}
\mycaption{Caption title}{I would like this sentence to be under the 
 title and smaller.}
\end{figure}
\end{document}

2 Answers 2

3

You can force the first argument as an optional argument for \caption:

enter image description here

\documentclass{article}

\newcommand{\mycaption}[2]{%
  \caption[#1]{\textbf{#1}\newline\small#2}%
}

\begin{document}

\listoffigures

\begin{figure}[!h]
  \mycaption
    {Caption title}
    {I would like this sentence to be under the title and smaller.}
\end{figure}

\end{document}

It would be possible to add an optional argument to \mycaption that would work in the same way you currently use \caption, allowing you to specify a different entry for the LoF.

1
  • thx it's perfect !
    – Tof
    Commented Oct 11, 2017 at 21:12
3

Here is a solution:

\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\newcommand\mycaption[3][\testOpt]{\xdef\testOpt{#2}\caption[#1]{\textbf{#2}\newline\small#3}}

\begin{document}
\listoffigures

\begin{figure}[H]
\mycaption[ Short Caption title]{Long Caption title}{I would like this sentence to be under the 
 title and smaller.}
\includegraphics[width=0.5\linewidth]{example-image-a}
\end{figure}

\begin{figure}[H]
\mycaption{Caption title}{I would like this sentence to be under the 
 title and smaller.}
\includegraphics[width=0.5\linewidth]{example-image-b}
\end{figure}

\end{document}

Output:

enter image description here

1
  • thx it's perfect !
    – Tof
    Commented Oct 11, 2017 at 21:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .