[Tex/LaTex] Centering just one line in a multi-line caption

captionshorizontal alignment

There are multiple questions already answered for centering an entire caption, but my problem is that I wish to just \centerline or \begin{center} ... \end{center} just one line in a multi-line caption.

For example (I am using the \ce package for chemistry) if I were to write the following:

\caption{In the presence of A and B, C will be generated:

\centerline{ \ce{A + B -> C}.}

}

Will just error out on me.

Best Answer

This should do the job:

\caption[Short caption needed.]{In the presence of A and B, C will be generated:
\[ \text{\ce{A + B -> C}.} \]
}

The most convenient way how to center an equation is to use the equation more, which is done by \[..\]. However, you can't bring that to the list of floats, because that causes errors, well, you don't want the equation on display in the list of floats, do you? So the short caption is the solution.

Related Question