标题longtblr
不会像标题那样从“表格”变为“补充表格” table
。事实上,在longtblr
标题中,我想在“表格”一词之前添加“补充”一词。我该怎么做?
下面您可以找到一个 MWE,以及相应的结果,以及我使用的文档类(其中包含添加单词“补充”的命令,即\renewcommand{\fnum@table}{Supplementary \tablename~\thetable}
):
平均能量损失
\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}
结果
文档类
这是我的文档类,即wlscirep_modified
,它是\documentclass{wlscirep}
(您可以在“科学报告投稿模板“):
%
% 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
与原始文档类相比只有两处修改,即:
% 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}
和
% 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
根据@Celdor 的回答进行编辑
非常感谢@Celdor!只是有点怀疑。这正常吗?附表2标题,与\begin{longtblr}[theme = supplementary, ...
...相关更小比附表1标题,相关
\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}
如下图所示?
答案1
我想在“表格”一词之前添加“补充”一词。我该怎么做?
tabularray
,具体来说,以及longtblr
与模板一起工作。和的talltblr
每个组件都有一个模板。默认情况下会创建两个模板和。前者默认应用于所有元素。更改模板会更改通过/创建的所有表。longtblr
talltblr
tabularray
default
empty
default
longtblr
talltblr
为了将特定表格中的标签名称从 更改为Table
,Supplementary Table
第一步是supplementary
为标题组件和标题本身创建自己的模板,例如 。由于longtablr
当表格位于第一页、中间页和最后一页时会应用三个单独的标题模板,即firsthead
、middlehead
和lasthead
,因此您必须为每个标题应用相同(或不同)的标题模板。乍一看可能很复杂,但最终它提供了很大的灵活性。
在您的具体情况下,您需要在代码中添加以下内容:
% 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}
}
请参阅下面的 MWE 代码
对于常规表格和标题,我建议也使用模板。例如,您可以bfdot
为自定义标题创建模板。caption
为此提供命令,例如
\DeclareCaptionFormat{bfdot}{\textbf{#1}.~#3}
然后,此类模板可以在table
环境中本地应用,也可以在两种情况下全局应用\captiosetup{fromat=...}
。请参阅 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}