Table 和 Longtable 环境在 LOT 中重现不同的间距

Table 和 Longtable 环境在 LOT 中重现不同的间距

我在论文中大量使用了 table 和 longtable 命令,并且观察到它们在表格列表中重现了不同的空间。以下是 MWE:

\documentclass[reqno,12pt,oneside]{report} % right-side equation numbering, 12 point font, print one-sided 

\usepackage{csm}        
\usepackage{amsmath}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs, multicol, multirow}
\usepackage{setspace}    % Allows you to specify the line spacing
\onehalfspacing           % \onehalfspacing for 1.5 spacing, \doublespacing for 2.0 spacing.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}


% Table of contents, list of figures, etc.
\tableofcontents     % Required
\listoftables        % Required if there is more than one table

\startthechapters

\chapter{Examples of using table option}
Here are tables produced by table and tabular commands. 
\begin{table}[!h]
\centering
\caption{Tabular table}
\vspace{1em}
    \begin{tabular}{ | l | l | l | p{5cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.  
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    \end{tabular}
\end{table}

\begin{table}[!h]
\centering
\caption{Colored rows}
\vspace{10pt}
\begin{tabular}{lll}
odd     & odd   & odd \\
even    & even  & even\\
odd     & odd   & odd \\
even    & even  & even\\
\end{tabular}
\end{table}

\chapter{Examples of using longtable option}

\begin{longtabu}{ll}
\caption{Longtabu table} \\ 
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
\end{longtabu}

\begin{longtable}{ll}
\caption{Longtable example} \\ 
\toprule
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
\end{longtable}

\begin{table}[!h]
\centering
\caption{Here again tabular environment}
\vspace{10pt}
\begin{tabular}{lll}
odd     & odd   & odd \\
even    & even  & even\\
odd     & odd   & odd \\
even    & even  & even\\
\end{tabular}
\end{table}
 W
Look at the list of tables. When the longtable or longtabu commands are used, they create the less space between the entries. It is desirable for me to have spaces as in the \textbf{table environment}. 
\end{document}

我使用的样式是根据学校要求修改的 Rackham 样式。它被称为“csm”样式,因此文件应保存为“csm.sty”。

下面我发布的是“csm.sty”文件本身。

% This is an option style (substyle) for writing a dissertation
% in the Rackham required format using reportx.sty.  -- jin ji, 1/88
% Modified on 05/19/88, jj.
% Modified on 12/13/88, for "CHAPTER" in toc and \@makecaption, jj.
% Modified on 01/08/89, for sections in loa (look for \@sect), jj.
% Modified on 89/11/29  by tex
%          Removed the last three lines of file which consisted of
%          <blank line>
%          % Get something else
%          \input indent
% Modified on 07/24/1992 by Roque D. Oliveira.
%          \startappendices was modified to work
%          with the New Font Selection Scheme.
%          Further (similar) changes may be needed for other macros.
% Modified Sep. 2008 by Jason Gilbert: Obsolete code removed or updated to 
%          better conform to LaTeX2e, list of abbreviations added, 
%          made copyright page cleaner, fixed Appendices, Bibliography, 
%          margins, title page, frontispiece, bottom-center page numbers,
%          two-side printing, added in-dissertation abstract and abstract
%          that prints separately at the end.

\typeout{  }
\typeout{Substyle `rac' for Rackham dissertation.}
\typeout{  }

%-- Page styles --

\def\ps@chappage{% The first page of each chapter has bottom-center page numbers -jj.
 \def\@oddhead{}
 \def\@oddfoot{\hfil \rm \thepage \hfil}
 \let\@evenhead\@oddhead 
 \let\@evenfoot\@oddfoot
}

\def\ps@plain{%
% \def\@oddhead{\hfil \rm \thepage \hfil} % These two lines of code make top-center page numbers on other pages -jg
% \def\@oddfoot{}
 \def\@oddhead{} % These two lines of code make bottom-center page numbers on other pages -jg
 \def\@oddfoot{\hfil \rm \thepage \hfil}
 \let\@evenhead\@oddhead 
 \let\@evenfoot\@oddfoot
}

%-- Margins --
\if@twoside \oddsidemargin 0.5in \evensidemargin 0in \marginparwidth .6in \textheight=8.95in
\else \oddsidemargin 0.5in \marginparwidth .9in \textheight=9.0in\fi% left margin=1in + oddsidemargin, marginparwidth: text box for margin notes
\topmargin -0.65in \headheight 0.35in \headsep 0.35in \footskip 0.5in % header and footer margins
\textwidth=6.0in % width of the text body on a page
% The top margin = 1in plus vspace. For some reason, need to subtract 0.35in also. -jg
\def\vertadjust{\vspace{-0.35in}} % Required for proper vertical spacing. -jg
\def\twoinmar{\vertadjust\vspace{0.25in}} % Two inch top margin -jg
\def\twohalfinmar{\vertadjust\vspace{1.5in}} % Two and a half inch top margin -jg


%-- Front pages --

% jj: This \ttlpg is the same as \titlepage in report.sty.
\def\ttlpg{\@restonecolfalse \if@twocolumn \@restonecoltrue \onecolumn
 \else \newpage \fi \thispagestyle{empty} \c@page \z@}

\def\titlepage#1#2{
 \ttlpg
 \begin{singlespace}
 \hbox{ }
 \twohalfinmar
 \begin{center}
 \begin{onehalfspacing} % For the `Large' font size, this will look single spaced. -jg
\vspace{2in}  
  {\Large\MakeUppercase{#1} \mbox{}} \\
 \end{onehalfspacing}
  \vfill
  by \\
  \vspace{2ex} % ex is the height of the lowercase 'x' for the current font. -jg
  #2 \\

 \end{center}

 \end{singlespace}
}

\def\initializefrontsections{

 \setcounter{page}{1}   % -- begins with "ii"
 \pagestyle{chappage}   % -- numbers at bottom
 \renewcommand{\thepage}{\roman{page}}   % roman numeral
}

\def\frontispiece{
 \ttlpg
 \hbox{ }
 \if@twoside \clearpage\hbox{}\thispagestyle{empty} \fi
 \twoinmar
}


%-- Table of contents and lists --

\def\dotfill{\leaders\hbox{$\m@th \mkern \@dotsep mu.\mkern \@dotsep mu$}\hfill}
\def\producetableofcontents{\tableofcontents}
\def\producelistoffigures{\listoffigures}
\def\producelistoftables{\listoftables}
\def\producelistofmaps{\listofmaps}
\def\producelistofappendices{\listofappendices}
\def\producelistofabbreviations{\listofabbreviations}

% jj: The only difference is \dotfill instead of \hfil.
\def\l@chapter#1#2{\pagebreak[3]
 \vskip 1.0em plus 1pt \@tempdima 1.5em \begingroup % em is the width of capital M for the current font.
 \parindent \z@ \rightskip \@pnumwidth
 \parfillskip -\@pnumwidth
 {\leavevmode #1}\dotfill \hbox to\@pnumwidth{\hss #2}\par
 \endgroup
}

\def\l@chap{\@dottedtocline{1}{1.0em}{1.5em}}
\def\l@section{\@dottedtocline{2}{2.5em}{3.0em}}
\def\l@subsection{\@dottedtocline{3}{5.5em}{3.0em}}
\def\l@subsubsection{\@dottedtocline{4}{8.5em}{3.0em}}

\setcounter{tocdepth}{3} % Number of section layers to show in TOC (i.e. section, subsection, subsubsection)
\setcounter{secnumdepth}{3} % Number of subsection layers to allow in document

\def\l@figure{\@dottedtocline{1}{1.0em}{3.5em}}
\let\l@table\l@figure
\let\l@map\l@figure
\let\l@anything\l@figure
\def\l@appendix{\@dottedtocline{1}{1.0em}{2.5em}}
\let\l@abbreviation\l@figure

\def\tableofcontents{%
 \newpage
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf TABLE OF CONTENTS}
 \vspace{0.25in}
 \begin{onehalfspace}
  \@starttoc{toc}\if@restonecol\twocolumn\fi
 \end{onehalfspace} 
}

\def\listoffigures{%
 \newpage
 \addcontentsline{toc}{chapter}{LIST OF FIGURES}
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf LIST OF FIGURES}
 \vspace{0.25in}
 \begin{singlespace}
  \@starttoc{lof}\if@restonecol\twocolumn\fi
  \addtocontents{lof}{\noindent\underline{\bf Figure}\hfill\rm\protect\newline}
 \end{singlespace}
}

\def\listoftables{%
 \newpage
 \addcontentsline{toc}{chapter}{LIST OF TABLES}
 \@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn\fi
 \hbox{ }
 \twoinmar
 \centerline{\large\bf LIST OF TABLES}
 \vspace{0.25in}
 \begin{singlespace}
  \@starttoc{lot}\if@restonecol\twocolumn\fi
  \addtocontents{lot}{\noindent\underline{\bf Table}\hfill\rm\protect\newline}
 \end{singlespace}
}

%-- Start chapters --

\def\thechapter {\@arabic\c@chapter}
\def\thesection {\@arabic\c@chapter.\@arabic\c@section}
\def\thefigure {\@arabic\c@chapter.\@arabic\c@figure}
\def\thetable {\@arabic\c@chapter.\@arabic\c@table}
\def\theequation {\@arabic\c@chapter.\@arabic\c@equation}

\newcounter{map}[chapter]
\def\themap{\@arabic\c@chapter.\@arabic\c@map}
\def\fps@map{tbp}
\def\ftype@map{1}
\def\ext@map{lom}
\def\fnum@map{Map \themap}
\def\map{\@float{map}}
\let\endmap\end@float
\@namedef{map*}{\@dblfloat{map}}
\@namedef{endmap*}{\end@dblfloat}

\def\startthechapters{%
 \def\@chapapp{CHAPTER}
 \addtocontents{toc}{\protect\mbox{ }\protect\newline\noindent{CHAPTER}\protect\newline}
 \addtocontents{toc}{\hbox{ }}
 \clearpage % This has to be before the rest.
 \if@twoside \ifodd\c@page \else \ttlpg \hbox{ }\fi\fi % For two-sided printing, make sure Chapter I starts on right-hand page. jg
 \clearpage
 \setcounter{chapter}{0}
 \setcounter{page}{1} % -- ...always begin with ii.
 \renewcommand{\thepage}{\arabic{page}}
 \pagestyle{plain}
 \def\tocname{toc}
}

\def\@chapter[#1]#2{%
 \ifnum \c@secnumdepth >\m@ne
  \refstepcounter{chapter}
  \typeout{\@chapapp\space\thechapter.}
  \addtocontents{toc}{\hbox{ }}
  \addcontentsline{toc}{chap}{\protect\numberline{\hbox{ }\hfill\thechapter.\hspace{5pt}}{\MakeUppercase{#1}}}
  \addtocontents{toc}{\hbox{ }}
 \else
  \addtocontents{toc}{\hbox{ }}
  \addcontentsline{toc}{chap}{#1}
  \addtocontents{toc}{\hbox{ }}
 \fi
 \if@twocolumn \@topnewpage[\@makechapterhead{#2}]
 \else \@makechapterhead{#2} \@afterheading \fi
}

\def\@makechapterhead#1{%
 \hbox{ }
 \twoinmar
 {\parindent 0pt \raggedright
  \ifnum \c@secnumdepth >\m@ne
  \centerline{\large\bf \@chapapp{} \thechapter} \par
  \vskip 0in \fi
  \begin{center}
   \centerline{\MakeUppercase{\large\bf #1}}
   %\large\bf #1
  \end{center}
  \nobreak
 }
 \@afterindenttrue
}

\def\section{\@startsection{section}{1}{\z@}{3.25ex plus 1ex minus
 .2ex}{2.3ex plus .2ex}{\normalsize\bf}}
\def\subsection{\@startsection{subsection}{2}{\z@}{3.25ex plus 1ex minus
 .2ex}{1.3ex plus .2ex}{\normalsize\bf}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{3.25ex plus
 1ex minus .2ex}{1.3ex plus .2ex}{\normalsize\bf}}

\long\def\@caption#1[#2]#3{%
 \addtocontents{\csname ext@#1\endcsname}{\hbox{ }}
 \addcontentsline{\csname ext@#1\endcsname}{#1}{\protect\numberline{\csname
  the#1\endcsname}{\ignorespaces\protect\small\protect\normalsize\rm #2}}
 \par
 \begingroup
  \@parboxrestore
  \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces\protect\small\normalsize\rm #3}
  \par
 \endgroup
}

\long\def\@makecaption#1#2{
 \vskip 10pt
 \setbox\@tempboxa\hbox{#1: #2}
 \ifdim \wd\@tempboxa >\hsize
  \setbox\@tempboxa\hbox{#1: }
  \def\@tempdimj{\hsize}
  \advance\@tempdimj -\wd\@tempboxa
  \hbox to\hsize{#1: \parbox[t]{\@tempdimj}{#2}}
 \else \hbox to\hsize{\hfill\box\@tempboxa\hfill}
 \fi}

%-- Appendices and bibliography --

\def\startappendices{\par
 \def\thechapter {\Alph{chapter}}
 \def\theappendix{\Alph{chapter}}
 \def\thesection{\theappendix.\arabic{section}}
 \def\theequation{{\rm \theappendix}.\arabic{equation}}
 \def\thefigure{{\rm \theappendix}.\@arabic\c@figure}
 \def\thetable{{\rm \theappendix}.\@arabic\c@table}
 \def\themap{{\rm \theappendix}.\@arabic\c@map}

 \setcounter{chapter}{0}
 \setcounter{section}{0}
 \def\@chapapp{APPENDIX}
 \pagestyle{plain}
 \clearpage
 \hbox{}
 \if@twoside \ifodd\c@page \else\thispagestyle{empty} \clearpage\hbox{}\fi\fi
 \thispagestyle{chappage}
 \addcontentsline{toc}{chapter}{APPENDIX}
 \hbox{ }
 \vertadjust
 \vfill
 \centerline{\large\bf APPENDICES} % The half title page
 \vfill
}

所以我的问题是:为什么如下图所示的表格列表中有不同的空格? 表格列表

我感谢您的帮助。

答案1

.sty这种不一致是由于您的文件在 LoT 中排版表格条目的方式造成的;可以通过重新定义\LT@c@aption(来自 的内部命令longtable)以使用相同的设置来解决这个问题(基本上,放置一个空白框来添加间距(arghhh!)):

\makeatletter
\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
      \addtocontents{lot}{\protect\hbox{ }}
       \addcontentsline{lot}{table}{\protect\numberline{\thetable}{\ignorespaces\protect\small\protect\normalsize\rm #2}}}%
  \fi}
\makeatother

完整代码:\documentclass[reqno,12pt,oneside]{report} % 右侧公式编号,12 号字体,单面打印

\usepackage{csm}        
\usepackage{amsmath}
\usepackage{tabu}
\usepackage{longtable}
\usepackage{booktabs, multicol, multirow}
\usepackage{setspace}    % Allows you to specify the line spacing
\onehalfspacing           % \onehalfspacing for 1.5 spacing, \doublespacing for 2.0 spacing.


\makeatletter
\def\LT@c@ption#1[#2]#3{%
  \LT@makecaption#1\fnum@table{#3}%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else
     {\let\\\space
      \addtocontents{lot}{\protect\hbox{ }}
       \addcontentsline{lot}{table}{\protect\numberline{\thetable}{\ignorespaces\protect\small\protect\normalsize\rm #2}}}%
  \fi}
\makeatother

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}


% Table of contents, list of figures, etc.
\tableofcontents     % Required
\listoftables        % Required if there is more than one table

\startthechapters

\chapter{Examples of using table option}
Here are tables produced by table and tabular commands. 
\begin{table}[!h]
\centering
\caption{Tabular table}
\vspace{1em}
    \begin{tabular}{ | l | l | l | p{5cm} |}
    \hline
    Day & Min Temp & Max Temp & Summary \\ \hline
    Monday & 11C & 22C & A clear day with lots of sunshine.  
    However, the strong breeze will bring down the temperatures. \\ \hline
    Tuesday & 9C & 19C & Cloudy with rain, across many northern regions. Clear spells
    across most of Scotland and Northern Ireland,
    but rain reaching the far northwest. \\ \hline
    Wednesday & 10C & 21C & Rain will still linger for the morning.
    Conditions will improve by early afternoon and continue
    throughout the evening. \\
    \hline
    \end{tabular}
\end{table}

\begin{table}[!h]
\centering
\caption{Colored rows}
\vspace{10pt}
\begin{tabular}{lll}
odd     & odd   & odd \\
even    & even  & even\\
odd     & odd   & odd \\
even    & even  & even\\
\end{tabular}
\end{table}

\chapter{Examples of using longtable option}

\begin{longtabu}{ll}
\caption{Longtabu table} \\ 
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
\end{longtabu}

\begin{longtable}{ll}
\caption{Longtable example} \\ 
\toprule
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
Longtable & Longtable \\
\end{longtable}

\begin{table}[!h]
\centering
\caption{Here again tabular environment}
\vspace{10pt}
\begin{tabular}{lll}
odd     & odd   & odd \\
even    & even  & even\\
odd     & odd   & odd \\
even    & even  & even\\
\end{tabular}
\end{table}
 W
Look at the list of tables. When the longtable or longtabu commands are used, they create the less space between the entries. It is desirable for me to have spaces as in the \textbf{table environment}. 
\end{document}

在此处输入图片描述

答案2

嗯,在 LaTeX 中使用裸元素\hbox几乎总是错误的,而 csm 包使用了很多裸元素。注释掉这个可以解决问题

\long\def\@caption#1[#2]#3{%
% \addtocontents{\csname ext@#1\endcsname}{\hbox{ }}

(第 243 行)

相关内容