2

I am using LaTeX with a template from my uni. I had to use longtable package for tables displayed on more than one page. Unfortunatly, this gives me problem in with my list of tables: the name (not the title) of the table is not displayed. i.e. for two tables (5.1 and 5.3) and one longtable (5.2), I get the following render:

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

Note that "Tableau" is "Table" in french, which is the langage of my paper. I see understand that "longtable" are not taken in account in the template and I would like to redefine their name.

I was able to use LaTeX with ease but I am pretty lost in the "sty" file. Any idea how to correct my problem?

Here is the main LaTeX file named "Document.tex":

\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}

Here is the content of my paper, in "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}

The stylesheet "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

And finally the 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
3
  • Welcome to TeX.SX!
    – Bobyandbob
    Nov 23, 2017 at 16:35
  • 1
    Please show us a compilable, short, complete tex code that result in your problem. Then we can copy the code and test it on our own computers ...
    – Mensch
    Nov 23, 2017 at 16:41
  • 1
    You are not showing the relevant code. Nov 23, 2017 at 16:41

1 Answer 1

1

longtable has its own way of creating captions. You'll have to customise it the same way you are customising regular captions. Here, the macro you need to change is \LT@c@ption.

Add the following code to your CustomStyleSheet.sty. This is the original macro from the longtable package with one change: the content of the \addcontentsline has been set to what is used in your custom package.

\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}

Then you should get the desired output :

List of tables

Similarly, you might want to change \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}}}

However, I can't guarantee that these changes (both the ones from your custom package and the ones I've added) won't conflict with other packages. On the contrary, you are probably losing useful functionalities from packages such as caption, the purpose of which is precisely to customise captions.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .