5

Dear latexperts: I am experimenting with pandoc as a text processor that translates into LaTeX. This means that the LaTeX coding is mostly out of my control.

pandoc uses longtable for its table environment, which in turn redefines the caption macro everytime longtable is invoked. Styling control of the caption is accomplished through caption.sty.

\documentclass{article}
\usepackage{longtable,color,caption}

\begin{document}
{
 \color{blue}
 \begin{longtable}[c]{lrr}
    left & mid & right \\
    \hline
    \caption{Why is this caption not blue??}
  \end{longtable}
  blue after text
}
\end{document}

I wish I could just redefine the caption in the preamble altogether, but the \longtable macro at the start of \begin{longtable} wipes it. I cannot omit caption.sty altogether (it is emitted by pandoc, with a couple of options). As said, I am pretty much stuck with the pandoc LaTeX code. I can only define further TeX macros in a style file to get my desired looks, which is enclosed after caption.sty is included.

I searched the doc for caption.sty for color, but color is not mentioned.

So, how do I convince caption not to switch color back to black, but to leave it as is?

3

This can be done with the caption package by placing:

\captionsetup[table]{font={color=blue}}

in the preamble.

\documentclass{article}
\usepackage{longtable,color,caption}
\captionsetup[table]{font={color=blue}}

\begin{document}
{
 \color{blue}
 \begin{longtable}[c]{lrr}
    left & mid & right \\
    \hline
    \caption{Why is this caption not blue??}
  \end{longtable}
  blue after text
}

\end{document}

Generally placing caption above the table is somewhat good for readability. For figures it comes below.

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.