避免在表格列表中重复 longtblr 的标题

避免在表格列表中重复 longtblr 的标题

我在上一个问题中发布了我的代码 目录中的表格和图片列表,我的问题是如何防止或避免表格列表中的重复?这是我得到的在此处输入图片描述

我的代码示例

\documentclass[a4paper,12pt,oneside,openany]{book}
\usepackage{tabularray}
\DefTblrTemplate{contfoot-text}{normal}{} \SetTblrTemplate{contfoot-text}{normal} 
 \DefTblrTemplate{conthead-text}{normal}{"Continued"} \SetTblrTemplate{conthead-text} 
 {normal}
 \usepackage{caption}
 \captionsetup{labelfont=bf}
 \RequirePackage[labelfont=bf]{caption}
 \usepackage{tocloft}
 \usepackage[labelsep=space, figurewithin=none, tablewithin=none, labelfont=bf]{caption}
 \captionsetup{justification = centering}
 \NewTblrTheme{captionof}%   % <---
 {\DefTblrTemplate{caption}{default}%
 {\addtocounter{table}{-1}%
 \captionof{table}{\InsertTblrText{caption}}%
 }
 \DefTblrTemplate{capcont}{default}%
 {\addtocounter{table}{-1}%
  \captionof{table}{\InsertTblrText{caption} (continue)}
  }%
  }
  \renewcommand*\contentsname{\null\hfill {TABLE OF CONTENTS}} 
   \usepackage{tocbibind}

    \let\oldaddcontentsline\addcontentsline
    \newcommand{\ADDCONTENTSLINE}[3]{%
   \oldaddcontentsline{#1}{#2}{\MakeUppercase{#3}}%
    }
   \newcommand{\CAPinToC}{\let\addcontentsline\ADDCONTENTSLINE}
   \newcommand{\noCAPinToC}{\let\addcontentsline\oldaddcontentsline}
  \begin{document}
   \newlength{\mylen}
   \newlength{\tempp}
   \setlength{\tempp}{\cftfignumwidth}

    \setlength{\cftfigindent}{0pt}
      \renewcommand{\figurename}{Figure}
      \renewcommand\cftfigpresnum{\bfseries \figurename~}
      \renewcommand\cftfigaftersnum{\normalfont}
     \settowidth{\mylen}{\cftfigpresnum\cftfigaftersnum}
      \addtolength{\cftfignumwidth}{\mylen}
       \chapter*{LIST OF FIGURES}
      \renewcommand\listfigurename{\vspace{-3.2em}}
      \addcontentsline{toc}{chapter}{LIST OF FIGURES}
    \listoffigures
     \clearpage
    
      \setlength{\cfttabindent}{0pt}
       \renewcommand{\tablename}{Table}
       \renewcommand\cfttabpresnum{\bfseries \tablename~}
       \renewcommand\cfttabaftersnum{\normalfont}
       \settowidth{\mylen}{\cfttabpresnum\cfttabaftersnum}
      \addtolength{\cfttabnumwidth}{\mylen}
       \chapter*{LIST OF TABLES}
       \renewcommand\listtablename{\vspace{-3.2em}}
      \addcontentsline{toc}{chapter}{LIST OF TABLES}
      \listoftables
      \clearpage
      \ par 
       \begin{longtblr}[theme = captionof,
                        caption = {My work},
                        label = {tab:1},
                        ]{
                   width = \linewidth,
                  colspec = {Q[113]Q[127]Q[177]Q[177]Q[146]Q[171]},
                  cells = {c},
                  column{1} = {h},
                  cell{2}{1} = {r=8}{},
                  cell{2}{2} = {r=2}{},
                 cell{2}{3} = {r=2}{},
                cell{4}{2} = {r=2}{},
                cell{4}{3} = {r=2}{},
               cell{6}{2} = {r=2}{h},
              cell{6}{3} = {r=2}{h},
              cell{8}{2} = {r=2}{},
            cell{8}{3} = {r=2}{},
             cell{10}{1} = {r=8}{},
             cell{10}{2} = {r=2}{},
            cell{10}{3} = {r=2}{},
            cell{12}{2} = {r=2}{},
            cell{12}{3} = {r=2}{},
            cell{14}{2} = {r=2}{},
            cell{14}{3} = {r=2}{},
           cell{16}{2} = {r=2}{h},
          cell{16}{3} = {r=2}{h},
           cell{18}{1} = {r=8}{},
         cell{18}{2} = {r=2}{},
         cell{18}{3} = {r=2}{},
         cell{20}{2} = {r=2}{},
        cell{20}{3} = {r=2}{},
        cell{22}{2} = {r=2}{},
        cell{22}{3} = {r=2}{},
       cell{24}{2} = {r=2}{},
       cell{24}{3} = {r=2}{},
       vlines,
       hline{1-2,10,18,26} = {-}{},
       hline{3,5,7,9,11,13,15,17,19,21,23,25} = {4-6}{},
        hline{4,6,8,12,14,16,20,22,24} = {2-6}{},
        }
     Test & Test & Test         & Test & Test~~ & Test \\
      5     & 44    & AA          & 00      & 99     & NN     \\
             &       &                  & 54       & 23     & QQ     \\
            & 65    & AA          & 22      & 45     & WW     \\
  &       &                  & 54      & 68     & ZZ     \\
  & 43    & AA          & 79      & 00     & RR     \\
  &       &                  & 34      & 07     & MM     \\
  & 2    & AA           & 21      & 25     & PP     \\
  &       &                  & 12      & 07      & XX     \\
  6     & 12    & AA          & 66       & 06     & BB     \\
  &       &                  & 50      & 04     & KK     \\
  & 11    & AA          & 12      & 09     & SS     \\
  &       &                  & 51      & 03     & DD     \\
  & 56    & AA          & 12      & 23     & HH     \\
  &       &                  & 97      & 05     & FF     \\
  & 9    & AA            & 03      & 58     & GG     \\
  &       &                  & 1      & 8     & JJ      \\
   7     & 12    & AA          & 87       & 41     & FF     \\
  &       &                  & 60      & 08     & UU     \\
  & 56    & AA          & 54      & 08     & EE     \\
  &       &                  & 71      & 61     & TT      \\
  & 11    & AA          & 32      & 31     & LL     \\
  &       &                  & 10       & 09     & RR     \\
  & 23    & AA          & 04      & 60     & PP     \\
  &       &                  & 8      & 61     & GG     
  \end{longtblr}

 \end{document}
   

这就是我应该得到的在此处输入图片描述

答案1

看来,longtblr使用caption包中的变通方法定义主题来格式化标题的方式captionof并不能解决Lof和的问题LoT

一个可能的解决方法是以下字幕设置:

%---------------------------------------------------------------%
% emulation of captions style for use in `longtblr`             % 
%---------------------------------------------------------------%
\DefTblrTemplate{conthead-text}{default}{(continued)}
    \SetTblrStyle{caption-tag} {font=\small\bfseries}
    \SetTblrStyle{caption-text}{font=\small\sffamily}\DefTblrTemplate{caption-sep}{default}{ \enskip}
\DefTblrTemplate{firsthead}{default}%
{\centering%
  \UseTblrTemplate{caption-tag}{default}
  \UseTblrTemplate{caption-sep}{default}
  \UseTblrTemplate{caption-text}{default}%
  \par
}
\DefTblrTemplate{middlehead,lasthead}{default}%
{\centering%
  \UseTblrTemplate{caption-tag}{default}%
  \UseTblrTemplate{caption-sep}{default}{~\enskip}%
  \UseTblrTemplate{caption-text}{default}%
  \UseTblrTemplate{conthead-text}{default}%
  \par
}
\DefTblrTemplate{contfoot-text}{normal}{Continued on next page}
     \SetTblrStyle{contfoot-text}{\footnotesize\itshape}
%---------------------------------------------------------------%

在 MWE 中,我删除了所有不相关的内容以展示LoT作品。我还更改了表格设置,现在更短了,单元格中的文本位置也统一了:

\documentclass[a4paper,12pt,oneside,openany]{book}
\usepackage{lipsum}
\usepackage{xcolor}
\usepackage{tabularray}

\usepackage[labelfont=bf,
            labelsep=space, 
            figurewithin=none, 
            tablewithin=none, 
            labelfont=bf,
            justification=centering]{caption}   %   for use in table/figure caption, 
                                                %   but not considered in `longtblr`
%---------------------------------------------------------------%
% emulation of captions style for use in `longtblr`             % 
%---------------------------------------------------------------%
\DefTblrTemplate{conthead-text}{default}{(continued)}
    \SetTblrStyle{caption-tag} {font=\small\bfseries}
    \SetTblrStyle{caption-text}{font=\small\sffamily}\DefTblrTemplate{caption-sep}{default}{ \enskip}
\DefTblrTemplate{firsthead}{default}%
{\centering%
  \UseTblrTemplate{caption-tag}{default}
  \UseTblrTemplate{caption-sep}{default}
  \UseTblrTemplate{caption-text}{default}%
  \par
}
\DefTblrTemplate{middlehead,lasthead}{default}%
{\centering%
  \UseTblrTemplate{caption-tag}{default}%
  \UseTblrTemplate{caption-sep}{default}{~\enskip}%
  \UseTblrTemplate{caption-text}{default}%
  \UseTblrTemplate{conthead-text}{default}%
  \par
}
\DefTblrTemplate{contfoot-text}{normal}{Continued on next page}
     \SetTblrStyle{contfoot-text}{\footnotesize\itshape}
%---------------------------------------------------------------%


\usepackage{tocloft}

\begin{document}
%    \chapter*{LIST OF TABLES}
\listoftables
    \clearpage
\begin{table}
\caption[Test of caption settings.]
        {Test of caption settings. Filler for longer caption text: \lipsum[66]}
\end{table}
\begin{longtblr}[
caption = {My work. \quad Filler for longer caption text: \lipsum[66]},
  entry = {short caption},
  label = {tab:1},
                ]{hlines, vlines,
                  colspec = {Q[c, h, 113]Q[c, 127]Q[c, 177]Q[c, 177]Q[c, 146]Q[c, 171]},
                  cell{2,10,18}{1} = {r=8}{},
                  cell{even}{2,3}  = {r=2}{},
                      }
Test    & Test  & Test  & Test  & Test  & Test  \\*
5       & 44    & AA    & 00    & 99    & NN    \\*
        &       &       & 54    & 2     & QQ    \\*
        & 65    & AA    & 22    & 45    & WW    \\*
        &       &       & 54    & 68    & ZZ    \\*
        & 43    & AA    & 79    & 00    & RR    \\*
        &       &       & 34    & 07    & MM    \\*
        & 2     & AA    & 21    & 25    & PP    \\*
        &       &       & 12    & 07    & XX    \\
%
  6     & 12    & AA    & 66    & 06    & BB    \\*
        &       &       & 50    & 04    & KK    \\*
        & 11    & AA    & 12    & 09    & SS    \\*
        &       &       & 51    & 03    & DD    \\*
        & 56    & AA    & 12    & 23    & HH    \\*
        &       &       & 97    & 05    & FF    \\*
        & 9     & AA    & 03    & 58    & GG    \\*
        &       &       & 1     & 8     & JJ    \\
%
7       & 12    & AA    & 87    & 41    & FF    \\*
        &       &       & 60    & 08    & UU    \\*
        & 56    & AA    & 54    & 08    & EE    \\*
        &       &       & 71    & 61    & TT    \\*
        & 11    & AA    & 32    & 31    & LL    \\*
        &       &       & 10    & 09    & RR    \\*
        & 23    & AA    & 04    & 60    & PP    \\*
        &       &       & 8     & 61    & GG    \\*
\end{longtblr}
\end{document}

在此处输入图片描述

相关内容