I am writing a longer document divided into \frontmatter
and \mainmatter
using the scrbook
class. While both a table caption and a LOT entry should be generated for tables provided in the mainmatter, both items need be omitted/suppressed for tables given in the frontmatter (think e.g. list of abbreviations, list of symbols ...).
Furthermore, to have consistent caption formatting for tables, figures, listings etc., I decided to rely on the caption
package.
Using the caption
package to format the caption of tabularray
tables as been elaborated in several places like:
- How to auto-copy the formatting from \usepackage{caption} to the caption of tabularray?
- Use caption style defined with caption package in tabularray's longtblr
- Table captions continued
Similarily, creating tables without caption and LOT entry is described in multiple instances:
tabularray
's manual (https://ftp.rrzn.uni-hannover.de/pub/mirror/tex-archive/macros/latex/contrib/tabularray/tabularray.pdf, end of section 4.1):
If you write entry=none, tabularray package will not add an entry in List of Tables. Therefore caption=text,entry=none is similar to \caption[]{text} in longtable. If you write label=none, tabularray package will not step table counter, and set the caption-tag and caption-sep elements (see below) to empty. Therefore caption=text,entry=none,label=none is similar to \caption*{text} in longtable, except for the counter.
- How do I omit the caption of a continued table on the second page using tabularray
- Remove the table label within "longtblr"
While both approaches are working when used on their own (I might have missed some edge cases), I do not get it working in combination.
What am I missing? How can a use the caption
package to format the captions of a tabularray
table supporting both tables without captions and LOT entries (in the frontmatter) and "normal" tables (in the mainmatter) of my document?
MWE:
\documentclass{scrbook}
\usepackage[english]{babel}
\usepackage[
font={footnotesize, sf},
labelfont={bf},
]{caption}
\usepackage{tabularray}
\usepackage{tblr-extras}
\UseTblrLibrary{booktabs}
\UseTblrLibrary{caption}
% remove continuation line at table footer
\DefTblrTemplate{contfoot-text}{default}{}
% define table template with empty captions on first and continued table instances,
% remove continuation line in footer
\DeclareTblrTemplate{caption}{nocaptemplate}{}
\DeclareTblrTemplate{capcont}{nocaptemplate}{}
\DefTblrTemplate{contfoot}{nocaptemplate}{}
% use table template to define new theme
\NewTblrTheme{mytabletheme}{
\SetTblrTemplate{caption}{nocaptemplate}{}
\SetTblrTemplate{capcont}{nocaptemplate}{}
\SetTblrTemplate{caption-lot}{empty}
}
\begin{document}
\frontmatter
\chapter{First Chapter in Frontmatter}
This chapter contains a table without any caption, label or LOT entry:
\begin{itemize}
\item \texttt{entry = none}
\item \texttt{label = none}
\end{itemize}
Problem: (Empty) caption and LOT entry are provided, when using \texttt{caption} and \texttt{tblr-extras} packages for formatting. Uncomment corresponding lines in header to see that is it working without the these two packages.
\begin{longtblr}[
entry = none,
label = none,
% apply theme to obtain table without caption on continued table
theme = mytabletheme,
]{
colspec={
l
X[l]
},
rowhead = 1, rowfoot = 0,
}
\toprule
column 1 & column 2 \\
\midrule
a & b \\
\pagebreak
a & b \\
\bottomrule
\end{longtblr}
\listoftables
\mainmatter
\chapter{First Chapter in Mainmatter}
This chapter contains a table with caption, label and LOT entry.
\begin{longtblr}[
caption = {The first table with caption},
entry = {The first table with caption},
label = {tbl:first_table_with_caption},
]{
colspec={
l
X[l]
},
rowhead = 1, rowfoot = 0,
}
\toprule
column 1 & column 2 \\
\midrule
a & b \\
\pagebreak
a & b \\
\bottomrule
\end{longtblr}
\end{document}