9

I have some tables that are generated automatically by a third-party program. I would like to change their captions without editing their text. Is there any way to change the caption of a table after it has been declared? For example:

\input{file_containing_the_table}
\some_command_to_change_the_caption{new_caption}

where file_containing_the_table.tex is something like this:

\begin{table}
a tabular ...
\caption{old_caption}
\label{table_label}
\end{table}

Thanks.

8

It's easier to change it before input:

{
\let\origcaption\caption
\def\caption#1{\origcaption{newcaption}}
\input{file_containing_the_table}
}

This code locally redefines \caption to discard its argument and instead use the original caption command with your new text.

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.