2

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}
1

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.

| improve this answer | |
  • thx it's perfect ! – Tof Oct 11 '17 at 21:12
2

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

| improve this answer | |
  • thx it's perfect ! – Tof Oct 11 '17 at 21:09

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.