1

Here is a MWE:

\documentclass{kaobook}

\usepackage{mwe}

\begin{document}
\mainmatter

\begin{figure}
    \begin{center}  % culprit
        \includegraphics[width=0.5\columnwidth]{example-image}
        \caption{
            A figure caption
        }
    \end{center}    % culprit
\end{figure}

\begin{table}[h]
    % \centering
    \begin{tabular}{|c|c|c|c|}
    \hline
    H1 & H2     \tabularnewline
    \hline
    \hline
    A & 1   \tabularnewline
    \hline
    B & 2   \tabularnewline
    \hline
    C & 3 \tabularnewline
    \hline
    D & 4   \tabularnewline
    \hline
    \end{tabular}
    \caption{A table caption.}
\end{table}

\end{document}

Then pdflatex halts:

[1] (build/proposal-mwe-kao-2.mw) [2] (build/proposal-mwe-kao-2.mw)
(/usr/local/texlive/2021/texmf-dist/tex/latex/newpx/ot1zpltlf.fd)
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsfonts/umsa.fd)
(/usr/local/texlive/2021/texmf-dist/tex/latex/microtype/mt-msa.cfg)
(/usr/local/texlive/2021/texmf-dist/tex/latex/amsfonts/umsb.fd)
(/usr/local/texlive/2021/texmf-dist/tex/latex/microtype/mt-msb.cfg)
(/usr/local/texlive/2021/texmf-dist/tex/latex/newpx/unpxmia.fd)
(/usr/local/texlive/2021/texmf-dist/tex/latex/newpx/unpxsym.fd)
(/usr/local/texlive/2021/texmf-dist/tex/latex/newpx/unpxsyc.fd)

! Package floatrow Error: Caption(s) lost.

See the floatrow package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.33    \caption{A table caption.}

?

If I remove the "culprit" lines, I get the output

enter image description here

I suppose the figure is centered anyway, but I'd like to understand what's the issue here. I have a document that I'm migrating from tufte-book to kaobook, and the center environment did not cause problems there.

Possibly related: How to solve the issue between side-by-side floats (tables) and floatrow package?

And if I'm interpreting this answer correctly, I should be using \centering instead of the center environment within a figure in any case. Version Info:

$ pdflatex --version
pdfTeX 3.141592653-2.6-1.40.22 (TeX Live 2021)
kpathsea version 6.3.3
Copyright 2021 Han The Thanh (pdfTeX) et al.
There is NO warranty.  Redistribution of this software is
covered by the terms of both the pdfTeX copyright and
the Lesser GNU General Public License.
For more information about these matters, see the file
named COPYING and the pdfTeX source.
Primary author of pdfTeX: Han The Thanh (pdfTeX) et al.
Compiled with libpng 1.6.37; using libpng 1.6.37
Compiled with zlib 1.2.11; using zlib 1.2.11
Compiled with xpdf version 4.03
3
  • \centering should be used in floats but what is kaobook doing? It isn't in texlive can you give a link? This? github.com/fmarotta/kaobook May 27, 2021 at 23:13
  • That's right. Sorry, I thought it was in texlive, but I am using the latest version.
    – Gus
    May 27, 2021 at 23:28
  • 1
    I got kaobook.cls and kao.sty from there but now I get ! Undefined control sequence. \__hook begindocument/before ...hrm \theoremstyle (oh that's a different issue, I get the caption lost error in tl 2020) May 28, 2021 at 7:10

1 Answer 1

2

This could have been demonstrated using article and floatrow it isn't related to the non standard kaobook class other than that uses floatrow. As more or less described in section 1.2 of the floatrow doc, captions have to be at the top level so floatrow and/or caption packages can re-arrange their position. So you can not put it in center.

Fortunately that isn't any hardship here as it is better to use \centering in floats. Floats are already set off with vertical display space and so the additional vertical space added by center is usually unwanted.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .