0

The longtblr caption title does not change from "Table" to "Supplementary Table", as the table caption title does. Indeed, in the longtblr caption title, I would like to add the word "Supplementary" just before the word "Table". How can I do it?

Here following you can find a MWE, with the corresponding result, and the document class I used (that contains the command to add the word "Supplementary", i.e. \renewcommand{\fnum@table}{Supplementary \tablename~\thetable}):

MWE

\documentclass[twocolumn,fleqn,10pt,dvipsnames,table]{wlscirep_modified}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{multirow, booktabs, tabularx, longtable}
\usepackage{multirow, makecell}
\usepackage{xurl}
\usepackage{booktabs}
\usepackage{xfp} 
\usepackage{color}

\title{Supplementary Information for...} \author[1]{Luke} \affil[1]{University of }

% Add longtable and xcolor packages and define a color \definecolor{white}{HTML}{FFFFFF}

\usepackage{multirow, makecell} \usepackage{tikz} \usepackage{tabularray} \usepackage{textcomp,gensymb} \RequirePackage[labelfont=bf, labelsep=period]{caption}

\begin{document} \maketitle

\section{Supplementary Text} \subsection{Notes about ...} This is about...

\begin{table}[ht] \centering \begin{tabular}{|l|l|l|} \hline Condition & n & p \ \hline A & 5 & 0.1 \ \hline B & 10 & 0.01 \ \hline \end{tabular} \caption{\label{tab:example}Legend (350 words max). Example legend text.} \end{table}

\rowcolors{1}{white}{white}

\NewTblrTheme{fancy}{ \SetTblrStyle{caption-tag}{font=\bfseries} }

\begin{longtblr}[ theme=fancy, caption = {This is a summary of...},] { colspec={m{0.9cm} m{0.1cm} m{0.6cm} m{1cm} m{3cm} m{7.3cm} m{1.5cm}}, column{6}={preto={\minipage{\linewidth}}, appto={\endminipage}}, row{1}={font=\bfseries}, row{2,5,7-8,11-13,20-26,30,33-34,36,39-40,42}={bg=white}, hline{1,Z}=0.8pt, hline{2}=0.4pt, hline{4,8,10,12-13,15-19,21-26,28-29,32,34,38,40}=dotted, hline{3,5-7,9,11,14,20,27,30-31,33,35,36-37,39,41,42-43}=solid, rowhead=1 }

    Day
    &
    & Month
    & Hours
    & Event
    & Description
    & Further Info
    \\
    %-------------------------------------------------
    Friday
    & $6$
    & February
    & 08 $-$ 19
    & Musical festival
    & 
    Something here ...
    & Multiple 
    \\
    %-------------------------------------------------
    \SetCell[r=2]{l} Saturday 
    & \SetCell[r=2]{l} 8 
    & \SetCell[r=2]{l} February
    & 08
    & Birthday
    & On Saturdays...
    & Multiple 
    \\
    &
    &
    & 9
    & Local Cup \newline
    & Soemthing here...
    & Single
    \\
    % -------------------------------------------------
\end{longtblr}



\end{document}

Result

enter image description here

Document Class

This is my document class, i.e. wlscirep_modified, which is a modification of \documentclass{wlscirep} (that you can find in "Template for submissions to Scientific Reports"):

%
% An unofficial LaTeX class for Scientific Report articles.
%
% Copyright Overleaf (WriteLaTeX) 2016.
%
% Based on the SelfArx document class.
%
\NeedsTeXFormat{LaTeX2e}
% \ProvidesClass{wlscirep}[18/03/2016, v1.1]
% \ProvidesClass{wlscirep}[03/11/2016, v1.2]
% \ProvidesClass{wlscirep}[27/02/2017, v1.3]
\ProvidesClass{wlscirep}[08/08/2020, v1.4]
\RequirePackage[utf8]{inputenc}
\RequirePackage[english]{babel}

\RequirePackage{ifthen} \RequirePackage{calc} \AtEndOfClass{\RequirePackage{microtype}} \DeclareOption{\PassOptionsToClass{\CurrentOption}{article}} \ProcessOptions \LoadClass{article} \RequirePackage{amsmath,amsfonts,amssymb} \RequirePackage{mathptmx} % Loads the Times-Roman Math Fonts \RequirePackage{helvet} \RequirePackage{courier} \RequirePackage{ifpdf}

\RequirePackage{graphicx,xcolor} \RequirePackage{booktabs}

% Settings for the author block \RequirePackage{authblk} \setlength{\affilsep}{1.5em} \renewcommand\Authfont{\fontsize{12}{12}\usefont{OT1}{phv}{b}{n}} \renewcommand\Affilfont{\fontsize{10}{12}\usefont{OT1}{phv}{m}{n}}

\RequirePackage[left=2cm,% right=2cm,% top=2.25cm,% bottom=2.25cm,% headheight=12pt,% letterpaper]{geometry}%

\RequirePackage[labelfont={bf,sf},% labelsep=period,% justification=raggedright]{caption}

\RequirePackage[colorlinks=true, allcolors=blue]{hyperref}

% Set up of the bibliography style

% \RequirePackage[numbers]{natbib} \RequirePackage[superscript,biblabel,nomove]{cite} %% Nov 3, 2016: Support DOI \bibliographystyle{naturemag-doi}

% % headers and footers % \RequirePackage{fancyhdr} % custom headers/footers \RequirePackage{lastpage} % Number of pages in the document \pagestyle{fancy} % Enables the custom headers/footers % Headers \lhead{}% \chead{}% \rhead{}% % Footers \lfoot{}% \cfoot{}% \rfoot{\small\sffamily\bfseries\thepage/\pageref{LastPage}}% \renewcommand{\headrulewidth}{0pt}% % No header rule \renewcommand{\footrulewidth}{0pt}% % No footer rule

% % section/subsection/paragraph set-up % \RequirePackage[explicit]{titlesec} \titleformat{\section} {\color{color1}\large\sffamily\bfseries} {\thesection} {0.5em} {#1} [] \titleformat{name=\section,numberless} {\color{color1}\large\sffamily\bfseries} {} {0em} {#1} []
\titleformat{\subsection} {\sffamily\bfseries} {\thesubsection} {0.5em} {#1} [] \titleformat{\subsubsection} {\sffamily\small\bfseries\itshape} {\thesubsubsection} {0.5em} {#1} []
\titleformat{\paragraph}[runin] {\sffamily\small\bfseries} {} {0em} {#1} \titlespacing{\section}{0pc}{3ex @plus4pt @minus3pt}{5pt} \titlespacing{\subsection}{0pc}{2.5ex @plus3pt @minus2pt}{0pt} \titlespacing{\subsubsection}{0pc}{2ex @plus2.5pt @minus1.5pt}{0pt} \titlespacing{\paragraph}{0pc}{1.5ex @plus2pt @minus1pt}{10pt}

% % tableofcontents set-up % \usepackage{titletoc} \contentsmargin{0cm} \titlecontents{section}[\tocsep] {\addvspace{4pt}\small\bfseries\sffamily} {\contentslabel[\thecontentslabel]{\tocsep}} {} {\hfill\thecontentspage} [] \titlecontents{subsection}[\tocsep] {\addvspace{2pt}\small\sffamily} {\contentslabel[\thecontentslabel]{\tocsep}} {} {\ \titlerule[.5pc]{.}\ \thecontentspage} [] \titlecontents{subsubsection}[\tocsep] {\footnotesize\sffamily} {} {} {} [\ \textbullet\ ]

\RequirePackage{enumitem} %\setlist{nolistsep} % Uncomment to remove spacing between items in lists (enumerate, itemize)

% Remove brackets from numbering in List of References \renewcommand{@biblabel}[1]{\bfseries\color{color1}#1.}

% % article meta data % \newcommand{\keywords}[1]{\def@keywords{#1}}

% MODIFICATION 1 - comment all the abstract % \def\xabstract{abstract} % \long\def\abstract#1\end#2{\def\two{#2}\ifx\two\xabstract % \long\gdef\theabstract{\ignorespaces#1} % \def\go{\end{abstract}}\else % \typeout{^^J^^J PLEASE DO NOT USE ANY \string\begin\space \string\end^^J % COMMANDS WITHIN ABSTRACT^^J^^J}#1\end{#2} % \gdef\theabstract{\vskip12pt BADLY FORMED ABSTRACT: PLEASE DO % NOT USE {\tt\string\begin...\string\end} COMMANDS WITHIN % THE ABSTRACT\vskip12pt}\let\go\relax\fi % \go}

% % custom title page % \renewcommand{@maketitle}{% {% \thispagestyle{empty}% \vskip-36pt% {\raggedright\sffamily\bfseries\fontsize{20}{25}\selectfont @title\par}% \vskip10pt {\raggedright\sffamily\fontsize{12}{16}\selectfont @author\par} \vskip18pt% {% \noindent {\parbox{\dimexpr\linewidth-2\fboxsep\relax}{\color{color1}\large\sffamily\textbf{ABSTRACT}}} }% \vskip10pt {% \noindent \colorbox{color2}{% \parbox{\dimexpr\linewidth-2\fboxsep\relax}{% % \sffamily\small\textbf\\theabstract }% }% % \vskip18pt% % \noindent % \parbox{\dimexpr\linewidth-2\fboxsep\relax}{% % {\color{color1}\keywordname\hspace*{1em}} @keywords% %}% }% \vskip25pt% }% }% %----------------------------------------------- \setlength{\columnsep}{0.55cm} % Distance between the two columns of text \setlength{\fboxrule}{0.75pt} % Width of the border around the abstract

\definecolor{color1}{RGB}{0,0,0} % Color of section headings \definecolor{color2}{gray}{1} % Color of the box behind the abstract \newcommand{\keywordname}{Keywords:} % Defines the keywords heading name

\newlength{\tocsep} \setlength\tocsep{1.5pc} % Sets the indentation of the sections in the table of contents \setcounter{tocdepth}{3} % Show only three levels in the table of contents section: sections, subsections and subsubsections

\usepackage{lipsum} % Required to insert dummy text %----------------------------------------------- \let\oldbibliography\thebibliography \renewcommand{\thebibliography}[1]{% \addcontentsline{toc}{section}{\hspace*{-\tocsep}\refname}% \oldbibliography{#1}% \setlength\itemsep{0pt}% } %% Automatically abbreviate journal names \RequirePackage{jabbrv}

% MODIFICATION 2 - Add the word "Supplementary" % https://tex.stackexchange.com/questions/44115/how-can-i-change-figure-caption-label \makeatletter \renewcommand{\fnum@figure}{Supplementary \figurename~\thefigure} \renewcommand{\fnum@table}{Supplementary \tablename~\thetable} \makeatother

Compared to the original document class there are only two modifications, i.e.:

% MODIFICATION 1 - comment all the abstract
% \def\xabstract{abstract}
% \long\def\abstract#1\end#2{\def\two{#2}\ifx\two\xabstract 
% \long\gdef\theabstract{\ignorespaces#1}
% \def\go{\end{abstract}}\else
% \typeout{^^J^^J PLEASE DO NOT USE ANY \string\begin\space \string\end^^J
% COMMANDS WITHIN ABSTRACT^^J^^J}#1\end{#2}
% \gdef\theabstract{\vskip12pt BADLY FORMED ABSTRACT: PLEASE DO
% NOT USE {\tt\string\begin...\string\end} COMMANDS WITHIN
% THE ABSTRACT\vskip12pt}\let\go\relax\fi
% \go}

and

% MODIFICATION 2 - Add the word "Supplementary"
% https://tex.stackexchange.com/questions/44115/how-can-i-change-figure-caption-label
\makeatletter
\renewcommand{\fnum@figure}{Supplementary \figurename~\thefigure}
\renewcommand{\fnum@table}{Supplementary \tablename~\thetable}
\makeatother

EDITED after the @Celdor's answer

Thanks a lot @Celdor! Just a doubt.. Is it normal that the Supplementary Table 2 caption title, related to \begin{longtblr}[theme = supplementary, ... is smaller than the Supplementary Table 1 caption title, related to

\begin{table}[ht]
\centering
\begin{tabular}{|l|l|l|}
\hline
Condition & n & p \\
\hline
A & 5 & 0.1 \\
\hline
B & 10 & 0.01 \\
\hline
\end{tabular}
\caption{\label{tab:example}Legend (350 words max). Example legend text.}
\end{table}

as shown in the following picture?

enter image description here

Ommo
  • 835

1 Answers1

3

I would like to add the word "Supplementary" just before the word "Table". How can I do it?

tabularray, specifically with longtblr as well as talltblr works along templates. Each component of a longtblr and talltblr has a template. By default tabularray creates two templates default and empty. The former is applied to all elements by default. Changing the default template changes all tables created via longtblr/talltblr.

In order to change a tag name from Table to Supplementary Table in a specific table, the first step would be to create your own template, say supplementary, for the caption components and caption itself. Since longtablr applies three separate caption templates when table is on the first, middle, and the last page, that is for firsthead, middlehead, and lasthead, you have to apply the same (or different) caption template for each one. It might look complicated at first but in the end it provides a lot of flexibility.

In your specific case, you would need to add the following to your code:

% Define and setup templates
\DefTblrTemplate{caption}{supplementary}{
  \DefTblrTemplate{caption-tag}{supplementary}{Supplementary Table \thetable}%
  \DefTblrTemplate{caption-sep}{supplementary}{.}%
  \centering
  \UseTblrTemplate{caption-tag}{supplementary}%
  \UseTblrTemplate{caption-sep}{supplementary}
  \UseTblrTemplate{caption-text}{default}\par
}
\DefTblrTemplate{firsthead}{supplementary}{\UseTblrTemplate{caption}{supplementary}}
\DefTblrTemplate{middlehead}{supplementary}{\UseTblrTemplate{caption}{supplementary}}
\DefTblrTemplate{lasthead}{supplementary}{\UseTblrTemplate{caption}{supplementary}}
% Apply templates%
\NewTblrTheme{supplementary}{
  \SetTblrStyle{caption-tag}{font=\bfseries}
  \SetTblrTemplate{firsthead}{supplementary}
  \SetTblrTemplate{middlehead}{supplementary}
  \SetTblrTemplate{lasthead}{supplementary}
}

See the code below for the MWE

In therms of regular tables and captions, I would recommend working with templates, as well. For instance, you could create a template bfdot for custom captions. caption provides commands for that, e.g.

\DeclareCaptionFormat{bfdot}{\textbf{#1}.~#3}

Then such template could applied either locally inside table env. or globally in both cases using \captiosetup{fromat=...}. See code of the MWE.

The MWE:

\documentclass[twocolumn,fleq]{article}
\usepackage[dvipsnames,table]{xcolor}
\usepackage{caption}
\usepackage{tabularray}

% tabularray's internal package is recommended for improved formatting, including vertical bars \UseTblrLibrary{booktabs}

% Define and setup templates \DefTblrTemplate{caption}{supplementary}{ \DefTblrTemplate{caption-tag}{supplementary}{Supplementary Table \thetable}% \DefTblrTemplate{caption-sep}{supplementary}{.}% \centering \UseTblrTemplate{caption-tag}{supplementary}% \UseTblrTemplate{caption-sep}{supplementary} \UseTblrTemplate{caption-text}{default}\par } \DefTblrTemplate{firsthead}{supplementary}{\UseTblrTemplate{caption}{supplementary}} \DefTblrTemplate{middlehead}{supplementary}{\UseTblrTemplate{caption}{supplementary}} \DefTblrTemplate{lasthead}{supplementary}{\UseTblrTemplate{caption}{supplementary}} % Apply templates% \NewTblrTheme{supplementary}{ \SetTblrStyle{caption-tag}{font=\bfseries} \SetTblrTemplate{firsthead}{supplementary} \SetTblrTemplate{middlehead}{supplementary} \SetTblrTemplate{lasthead}{supplementary} } % Define and apply caption template in regular tables \DeclareCaptionFormat{bfdot}{\textbf{#1}.~#3} \captionsetup[table]{format=bfdot}

\title{Supplementary Information for...} % \author[1]{Luke} % \affil[1]{University of}

\begin{document} \maketitle

\section{Supplementary Text} \subsection{Notes about ...} This is about...

\begin{table}[ht] \centering \begin{tabular}{|l|l|l|} \hline Condition & n & p \ \hline A & 5 & 0.1 \ \hline B & 10 & 0.01 \ \hline \end{tabular} \caption{Legend (350 words max). Example legend text.} \label{tab:example} \end{table}

\begin{longtblr}[ theme = supplementary, caption = {This is a summary of...}, ]{ width = \textwidth, colspec = {m{1.5cm} m{0.1cm} m{0.9cm} m{1.5cm,mode=math} m{3cm} X[m] m{1.5cm}}, column{6} = {preto={\minipage{\linewidth}}, appto={\endminipage}}, row{1} = {font=\bfseries}, row{2,5,7-8,11-13,20-26,30,33-34,36,39-40,42} = {bg=white}, hline{1,Z} = 0.8pt, hline{2} = 0.4pt, hline{4,8,10,12-13,15-19,21-26,28-29,32,34,38,40} = dotted, hline{3,5-7,9,11,14,20,27,30-31,33,35,36-37,39,41,42-43} = solid, rowhead = 1, }

\SetRow{mode=text}Day & & Month & Hours & Event & Description & Further Info \ % ------------------------------------------------- Friday & 6 & Feb & 08 - 19 & Musical festival & Something here ... & Multiple \ % ------------------------------------------------- \SetCell[r=2]{l} Saturday & \SetCell[r=2]{l} 8 & \SetCell[r=2]{l} Feb & 08 & Birthday & On Saturdays... & Multiple \ & & & 9 & Local Cup & Soemthing here... & Single \ % ------------------------------------------------- \end{longtblr} \end{document}

enter image description here

Celdor
  • 9,058
  • Many thanks@Celdor !!! Please see my *EDITED* part in my original question about a silly doubt I got after implementing your solution into my code :-) – Ommo Nov 13 '23 at 14:01
  • 1
    Np. The content inside \DefTblrTemplate{caption}{supplementary}{...} is nearly a regular paragraph. As such, it accepts almost any formatting macro. For instance, in order to achieve right alignment, change \centering to \raggedright. ragged2e package defines a much improved version \RaggedRight which also adds hyphenations. You could also try to change \centering to \raggedright\hangindent1.25cm\hangafter1 and have a hang-out caption by 1.25cm. For more sophisticated formatting, you would need to apply boxes. – Celdor Nov 13 '23 at 14:34
  • Thanks for your comment @Celdor !! :-) .....but I think there has been a tiny misunderstanding... Is your comment related to the size of the captions titles? I was indeed talking about the size of *Supplementary Table 2* caption title (related to longtblr), which is smaller than the size of *Supplementary Table 1* caption title (related to the classical table).. :-) – Ommo Nov 13 '23 at 15:02
  • 1
    I assumed caption size rather than font size. my bad. On my end, they look the same while I can see your screenshot shows otherwise. It's likely due to a custom document class and custom style, which my approach does not pick. You can adjust it by yourself. For regular tables use \captionsetup[...]{..., font=<size>} where <size> keyword must be normalsize or small etc. (see documentation for more key words). For tabularray use a regular paragraph macro : \normalsize or \small etc. – Celdor Nov 13 '23 at 15:38
  • Thanks a lot :-) Very kind! – Ommo Nov 13 '23 at 15:50