2

According to my prior questions: First and Second. Is it somehow possible to have a different caption than what's shown in the list of figures? So what i want to do is basically the following:

\documentclass{article}
\usepackage{mwe}% just for the example

\usepackage{linegoal}


\newcommand{\mycaption}[1]{%
\refstepcounter{figure}%
\addcontentsline{lof}{figure}{\protect\numberline{\thefigure}{\ignorespaces  
#1}}
\quad\parbox[b]{\linegoal}{#1}}

\begin{document}
\listoffigures
\begin{itemize}
\item \includegraphics[scale=.15]{example-image} \mycaption{caption} \myTitleInListOfFigures{This is another text}
\item \includegraphics[scale=.2]{example-image} \mycaption{another caption} \myTitleInListOfFigures{This is another text 2235434t}
\end{itemize}
\end{document}

Does someone know how to do this?

So the list of figures should then look like:

1.1 This is another text
1.2 This is another text 2235434t
...
3

Here is a solution with the help of etoolbox package. To be used

\mycaption[This is another text (for list)]{caption (for body)} 

if another text is needed or just

 \mycaption{caption} 

if same text need to be used


\documentclass{article}
\usepackage{mwe}% just for the example

\usepackage{linegoal}
\usepackage{etoolbox}


\newcommand{\mycaption}[2][]{%
\refstepcounter{figure}%
\addcontentsline{lof}{figure}{\protect\numberline{\thefigure}{\ignorespaces  
\ifblank{#1}{#2}{#1}}}
\quad\parbox[b]{\linegoal}{#2}}

\begin{document}
\listoffigures
\begin{itemize}
\item \includegraphics[scale=.15]{example-image} \mycaption[This is another text]{caption} 
\item \includegraphics[scale=.2]{example-image} \mycaption{another caption} 
\end{itemize}
\end{document}
  • Strange, I'm getting the optional argument as caption of the image (where should be "caption" is "This is another text") – Guilherme Zanotelli Sep 22 '16 at 18:39
  • it works like this: \mycaption[text in list]{caption in body} and if you want same text you can use \mycaption[caption]{caption} or simply \mycaption{caption} – touhami Sep 22 '16 at 18:50
  • No, I found the problem, where there's linegoal{#1} it should be #2. See for yourself. – Guilherme Zanotelli Sep 22 '16 at 18:51
  • @GuilhermeZ.Santos ok, i see it, i am sorry. – touhami Sep 22 '16 at 18:54
  • No need for apologies! We're here for helping right? :D – Guilherme Zanotelli Sep 22 '16 at 18:56

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.