Graphics, Figures & TablesCaption from extern file

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mena
Posts: 2
Joined: Thu Jul 29, 2010 5:13 pm

Caption from extern file

Post by mena »

Hi all,
Its possible to set the captions of a figure from a extern file? I want to do something like this:

Code: Select all

\begin{figure}[h]
\centering
\includegraphics{Fig1}
\caption{\input{captionFig1.tex}}
\end{figure}
This example doesnt work :(
Any Ideas??

Thanks!!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Caption from extern file

Post by Stefan Kottwitz »

Hi Mena,

welcome to the board!
Use \protect:

Code: Select all

\caption{\protect\input{captionFig1.tex}}
Stefan
LaTeX.org admin
mena
Posts: 2
Joined: Thu Jul 29, 2010 5:13 pm

Caption from extern file

Post by mena »

Thanks Stefan!!
Another solution is just put the "\caption" on the extern file and call input:

Code: Select all

\begin{figure}[h]
\centering
\includegraphics{Fig1}
\input{captionFig1.tex}}
\end{figure}
and captionFig1.tex would be something like

Code: Select all

\caption{Some text}
I like yours 'cause in my solution u dont see that you called \caption, and that could be confuse for other people.

Thanks again
Post Reply