# Input Auto-Generated Figures Captions

I'm trying to include an Matlab-auto-generated figure-caption tex-file using

\caption{\input{Spectrogram-2011-09-28-S003.title.tex}}


but if fails with error

ERROR: Argument of \@caption has an extra }.


I've tried all kinds of syntactic variants. How to solve this?

-
try \caption{\protect\input .... –  Yiannis Lazarides Dec 20 '11 at 10:44

The easiest method is to protect the input command by using:

\caption{\protect\input{figure.caption.tex}}

-
Yes, you need .tex at the end if there is another dot in the file name, which is the case here. Otherwise an extension .caption is used. –  Martin Scharrer Dec 20 '11 at 10:46
@MartinScharrer, I was not aware of that. Thanks, will modify the answer. –  Roelof Spijker Dec 20 '11 at 10:47

\caption{<caption>} will try to write the <caption> to an auxiliary file and LaTeX's \input isn't fully expandable. This alone will cause an error. You should store the content of the Spectrogram-2011-09-28-S003.title.tex file first into a macro. The catchfile package can be used for this.

\usepackage{catchfile}
% ...

\CatchFileDef{\matlabcaption}{Spectrogram-2011-09-28-S003.title.tex}{}%
\caption{\matlabcaption}

-