表列表中的 longtable 名称

表列表中的 longtable 名称

我正在使用 LaTeX 和来自我大学的模板。我不得不使用longtable包来在多个页面上显示表格。不幸的是,这给我的表格列表带来了问题:表格的名称(不是标题)没有显示。例如,对于两个表格(5.1 和 5.3)和一个长表(5.2),我得到以下渲染:

      LIST OF TABLES
Tableau 1.1     DSCP1       
1.2             Title of my long table
Tableau 1.3     DSCP2

请注意,“Tableau”在法语中是“Table”,这是我的论文的语言。我明白模板中没有考虑“longtable”,我想重新定义它们的名称。

我能够轻松使用 LaTeX,但我对“sty”文件却一头雾水。有什么办法可以解决我的问题吗?

这是名为“Document.tex”的主 LaTeX 文件:

\documentclass[letterpaper,12pt,oneside,final]{book}
\usepackage[utf8]{inputenc}
\usepackage{lmodern}
\usepackage[T1]{fontenc}
\usepackage[english,frenchb]{babel} 
%%
\usepackage{graphicx}
\usepackage{epstopdf}
%%
\graphicspath{{./images/}{./dia/}{./gnuplot/}}
%%
\usepackage{flafter,placeins,natbib,amsmath,color,soulutf8,longtable,colortbl,setspace,ifthen,xspace,url,pdflscape}
%%
\usepackage[nolist]{acronym}
\onehalfspacing
%%
\usepackage{fancyhdr}
\fancypagestyle{pagenumber}{\fancyhf{}\fancyhead[R]{\thepage}}
\renewcommand\headrulewidth{0pt}
\makeatletter
\let\ps@plain=\ps@pagenumber
\makeatother
%%
\usepackage{hyperref}
\usepackage{caption}
\makeatletter
\providecommand*{\toclevel@compteur}{0}
\makeatother
%%
\usepackage{CustomStyleSheet}

\begin{document}
%%
\pagestyle{pagenumber}%
{\setlength{\parskip}{0pt}
%%
%% Table of content
\renewcommand\contentsname{TABLE DES MATIÈRES}
\tableofcontents
%%
%% List of tables.
\renewcommand\listtablename{LISTE DES TABLEAUX}
\listoftables
%%
}
\mainmatter
\include{5-Introduction}
\end{document}

以下是我的论文内容,在“5-Introduction.tex”中:

\Chapter{INTRODUCTION}

\begin{table}[ht]
\caption{DSCP 1}
\centering
\begin{tabular}{|c|c|l|}
\hline\rowcolor[gray]{0.8}\color{black}
Field & Val & Rule\\\hline
1 & xxxxx0 & foo\\\hline
2 & xxxx11 & bar\\\hline
\end{tabular}\label{tab:1DSCP}
\end{table}

\begin{longtable}{|c|l|}
    \hline\rowcolor[gray]{0.8}\color{black}
    ID & entry\\\hline
    A & 1010\\\hline
    A & 1010\\\hline
    \caption{Title of my longtable}
    \label{tab:spec}
\end{longtable}

\begin{table}[ht]
\caption{DSCP 2}
\centering
\begin{tabular}{|c|c|l|}
\hline\rowcolor[gray]{0.8}\color{black}
Field & Val & Rule\\\hline
2 & xxxx11 & bar\\\hline
3 & xxxx01 & baz\\\hline
\end{tabular}\label{tab:2DSCP}
\end{table}

样式表“CustomStyleSheet.sty”:

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{MemoireThese}
             [2005/04/20 v1.0
                 Poly-specific LaTeX package (Revised chapter titles)]

\def\@makechapterhead#1{%
  {\parindent \z@ \raggedright \normalfont
    \centering
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \normalsize\bfseries CHAPITRE\space\thechapter
        \space\space\space\space
      \fi
    \fi
    \interlinepenalty\@M
    \normalsize \bfseries #1\par\nobreak
    \vskip 35\p@
  }}

\def\@makeschapterhead#1{%
  {\parindent \z@ \raggedright
    \centering
    \normalfont
    \interlinepenalty\@M
    \normalsize \bfseries #1\par\nobreak
    \vskip 35\p@
  }}

\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3ex \@plus -1ex \@minus -.2ex}%
                                   {1.75ex \@plus.2ex}%
                                   {\normalfont\normalsize\bfseries}}
\renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-2.75ex\@plus -1ex \@minus -.2ex}%
                                     {1ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
                                     {-2.75ex\@plus -1ex \@minus -.2ex}%
                                     {1ex \@plus .2ex}%
                                     {\normalfont\normalsize\bfseries}}
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                    {2.75ex \@plus1ex \@minus.2ex}%
                                    {-1em}%
                                    {\normalfont\normalsize\bfseries}}

\long\def\@makecaption#1#2{%
  \vskip\abovecaptionskip
  \sbox\@tempboxa{#1 #2}%
  \ifdim \wd\@tempboxa >\hsize
    #1 #2\par
  \else
    \global \@minipagefalse
    \hb@xt@\hsize{\hfil\box\@tempboxa\hfil}%
  \fi
  \vskip\belowcaptionskip}


% Specific definition of \caption to include the word FIGURE or TABLEAU
\def\caption{\refstepcounter\@captype \@dblarg{\@caption\@captype}}
\long\def\@caption#1[#2]#3{%
  \par
  \addcontentsline{\csname ext@#1\endcsname}{#1}%
    {\protect\numberline{\csname fnum@#1\endcsname}{\ignorespaces #2}}%
  \begingroup
    \@parboxrestore
    \if@minipage
      \@setminipage
    \fi
    \normalsize
    \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par
  \endgroup}

% Replace the abrev Fig and Tab with Figure and Tableau
\addto\captionsfrench{\renewcommand\figurename{Figure}\renewcommand\tablename{Tableau}}

% Ajustement des marges selon le format de l'École.
\setlength{\voffset}{0in}
\setlength{\hoffset}{0in}
\setlength{\topmargin}{-1.28cm}
\setlength{\oddsidemargin}{-0.04cm}
\setlength{\evensidemargin}{-0.04cm}
\setlength{\headheight}{12pt}
\setlength{\headsep}{22pt}
\setlength{\textwidth}{16.59cm}
\setlength{\textheight}{22.94cm}
\setlength{\marginparwidth}{0in}
\setlength{\marginparsep}{0in}
\setlength{\parindent}{0in}
\setlength{\parskip}{1ex}

\setlength\belowcaptionskip{10pt}

\newcommand{\Chapter}[1]{\chapter{#1}\setcounter{figure}{0}\setcounter{table}{0}\setcounter{footnote}{0}}

% Numérotation des figures et des tableaux selon les critères de l'École.
\renewcommand{\thefigure}{\thechapter.\arabic{figure}}
\renewcommand{\thetable}{\thechapter.\arabic{table}}

% Affichage des entrées dans la table des matières qui
% correspondent aux chapitres.
\renewcommand\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      CHAPITRE #1\nobreak\leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfill \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}


% Affichage des entrées dans la table des matières qui ne
% sont pas numérotées (par ex. Dédicace)
\newcommand\l@compteur[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \advance\leftskip\@tempdima
      \hskip -\leftskip
      #1\nobreak\leaders\hbox{$\m@th
        \mkern \@dotsep mu\hbox{.}\mkern \@dotsep
        mu$}\hfill \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}


\renewcommand\listoffigures{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listfigurename}%
      \addcontentsline{toc}{compteur}{\listfigurename}%
      \@mkboth{\MakeUppercase\listfigurename}%
              {\MakeUppercase\listfigurename}%
    \@starttoc{lof}%
    \if@restonecol\twocolumn\fi
    }

\renewcommand\listoftables{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\listtablename}%
      \addcontentsline{toc}{compteur}{\listtablename}%
      \@mkboth{%
          \MakeUppercase\listtablename}%
         {\MakeUppercase\listtablename}%
    \@starttoc{lot}%
    \if@restonecol\twocolumn\fi
    }

\renewcommand\tableofcontents{%
    \if@twocolumn
      \@restonecoltrue\onecolumn
    \else
      \@restonecolfalse
    \fi
    \chapter*{\contentsname
        \@mkboth{%
           \MakeUppercase\contentsname}{\MakeUppercase\contentsname}}%
       \addcontentsline{toc}{compteur}{\contentsname}%
    \@starttoc{toc}%
    \if@restonecol\twocolumn\fi
    }

\def\l@table{\@dottedtocline{1}{0em}{7em}}
\def\l@figure{\@dottedtocline{1}{0em}{7em}}
\def\l@annexe{\@dottedtocline{1}{0em}{7em}}

\endinput

最后是 Makefile:

TEXINPUTS += :./dia:./gnuplot:./images:./modules
export TEXINPUTS

SRC = Document.tex
LATEX   = latex -output-format=dvi
PDFLATEX= pdflatex
BIBTEX  = bibtex
XDVI    = xdvi -paper us
DVIPDF  = dvipdfm -p letter

COPY     = if test -r $(<:%.tex=%.toc); then cp $(<:%.tex=%.toc) $(<:%.tex=%.toc.bak); fi
RERUN    = "(There were undefined (references|citations)|Rerun to get (cross-references|the bars) right)"
RERUNBIB = "No file.*\.bbl|Citation.*undefined"


$(SRC:%.tex=%.pdf): $(SRC) $(SRC:%.tex=%.bib) images $(shell ls -1 images/*.eps 2> /dev/null)
    $(COPY); $(PDFLATEX) $(SRC)
    @egrep -c $(RERUNBIB) $(SRC:%.tex=%.log) && ($(BIBTEX) $(SRC:%.tex=%); $(COPY); $(PDFLATEX) $(SRC)); true
    @egrep -q $(RERUN) $(SRC:%.tex=%.log) && ($(COPY);$(PDFLATEX) $(SRC)); true
    @egrep -q $(RERUN) $(SRC:%.tex=%.log) && ($(COPY);$(PDFLATEX) $(SRC)); true
    @if cmp -s $(SRC:%.tex=%.toc) $(SRC:%.tex=%.toc.bak); then true; else $(PDFLATEX) $(SRC); fi
    @rm -f $(SRC:%.tex=%.toc.bak)
    @egrep -i "(Reference|Citation).*undefined" $(SRC:%.tex=%.log); true

pdf: $(SRC:%.tex=%.pdf)

clean:
    @rm -f *.aux *~ $(SRC:%tex=%){dvi,pdf,bbl,blg,log,out,lof,lot,loa,toc,app}


.PHONY  : clean pdf draft help images

答案1

longtable有自己的字幕创建方式。您必须像自定义常规字幕一样对其进行自定义。在这里,您需要更改的宏是\LT@c@ption

将以下代码添加到您的CustomStyleSheet.sty。这是来自包的原始宏,longtable但有一处更改: 的内容\addcontentsline已设置为自定义包中使用的内容。

\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
    {\let\\\space
    \addcontentsline{lot}{table}{\protect\numberline{\fnum@table}{\ignorespaces #2}}}%
  \fi}

然后你应该得到期望的输出:

表格列表

同样地,您可能想要更改\LT@makecaption

\def\LT@makecaption#1#2#3{%
  \LT@mcol\LT@cols c{\hbox to\z@{\hss\parbox[t]\LTcapwidth{%
    \sbox\@tempboxa{#1{#2 }#3}%
    \ifdim\wd\@tempboxa>\hsize
      #1{#2 }#3%
    \else
      \hbox to\hsize{\hfil\box\@tempboxa\hfil}%
    \fi
    \endgraf\vskip\baselineskip}%
  \hss}}}

但是,我无法保证这些更改(包括您自定义包中的更改和我添加的更改)不会与其他包冲突。相反,您可能会失去诸如 之类的包中的有用功能caption,这些包的目的正是自定义字幕。

相关内容