Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
2  
try \caption{\protect\input .... –  Yiannis Lazarides Dec 20 '11 at 10:44
add comment

2 Answers 2

up vote 4 down vote accepted

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

\caption{\protect\input{figure.caption.tex}}
share|improve this answer
2  
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
add comment

\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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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