![如何在表格列表页面中添加标题?](https://linux22.com/image/346789/%E5%A6%82%E4%BD%95%E5%9C%A8%E8%A1%A8%E6%A0%BC%E5%88%97%E8%A1%A8%E9%A1%B5%E9%9D%A2%E4%B8%AD%E6%B7%BB%E5%8A%A0%E6%A0%87%E9%A2%98%EF%BC%9F.png)
我是 LaTex 新手,所以如果这是一个新手问题,请多多包涵。我使用的模板\listoftables
定义如下:
\def\listoftables{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
\fi\chapter*{List of Tables\@mkboth
{LIST OF TABLES}{LIST OF TABLES}}
\addcontentsline{toc}{chapter}{List of Tables}\@starttoc{lot}\if@restonecol
\twocolumn\fi}
当我添加\listoftables
到我的文档时,我得到如下内容:
我想补充的是这样的:
如何在表格列表的每一列顶部添加标题行? 提前感谢您的回答和建议!
答案1
的一个版本book.cls
,其中有一些棘手的语句写入.lot
文件
\documentclass{book}
\usepackage{tocloft}
\makeatletter
\newlength{\latexpnumwidth}
\setlength{\latexpnumwidth}{\@pnumwidth}
\renewcommand{\cfttabpresnum}{\textbf{\tablename}~}
\addtolength{\cfttabnumwidth}{25pt}
\let\origcftdot\cftdot
\addtocontents{lot}{\protect\cftsetpnumwidth{25pt}}
\addtocontents{lot}{\protect\renewcommand{\protect\cftdot}{}} % Remove the dots
\addtocontents{lot}{\protect\contentsline{table}{\numberline{\textbf{\tablename}~}\textbf{Title}}{\textbf{Page}}} % Write the header line
\addtocontents{lot}{\protect\renewcommand{\protect\cftdot}{\origcftdot}}% Can be written 'expanded' and enable the dots again
\addtocontents{lot}{\vskip0.5\baselineskip\par}% Some vertical spacing
\makeatother
\begin{document}
\tableofcontents
\listoftables
\chapter{A chapter}
\begin{table}
\caption{Foo stuff table}
\end{table}
\end{document}
更新时Table
删除了前缀。
\documentclass{book}
\usepackage{tocloft}
\makeatletter
\newlength{\latexpnumwidth}
\setlength{\latexpnumwidth}{\@pnumwidth}
\addtolength{\cfttabnumwidth}{25pt}
\let\origcftdot\cftdot
\addtocontents{lot}{\protect\cftsetpnumwidth{25pt}}
\addtocontents{lot}{\protect\renewcommand{\protect\cftdot}{}} % Remove the dots
\addtocontents{lot}{\protect\contentsline{table}{\numberline{\textbf{\tablename}~}\textbf{Title}}{\textbf{Page}}} % Write the header line
\addtocontents{lot}{\protect\renewcommand{\protect\cftdot}{\origcftdot}}% Can be written 'expanded' and enable the dots again
\addtocontents{lot}{\vskip0.5\baselineskip\par}% Some vertical spacing
\makeatother
\begin{document}
\tableofcontents
\listoftables
\chapter{A chapter}
\begin{table}
\caption{Foo stuff table}
\end{table}
\end{document}
答案2
抱歉,评论框不够长,无法填写我的所有问题和评论。所以我把它放在了这个答案框里。如果它对你没有帮助,请原谅。
我不确定是否了解您的具体问题。
您说,您必须使用您部门创建的 LaTeX 样式(您将其命名为“模板”)。所呈现的代码是否取自该模板?
如果是这样,我想说,这种风格符合你们部门的建议。
如果您正在使用它,没有人会抱怨错误的布局。
例如:我确信您不必在表格列表中添加“示例”字样,对吗?因此我猜想,这只是一个抽象的示例,不必逐字复制。
我认为,您在该图像中绘制的第一个红色框是给您的一个抽象示例。我相信您不必逐字复制它。至少,它描述了每列的功能。但这微不足道,因此不值得一提。如果不是微不足道的话,您还必须在目录、图表列表等中添加类似的标题。那会读起来很奇怪,不是吗?
更糟糕的是,我认为在每行前面添加“表格”一词不会为这一行条目添加任何有用的信息。老实说:您指望一个标有“表格列表”的表格包含什么?如果您不想欺骗您的读者,它除了包含此文档中的表格列表外什么也不会包含。重复这个无用的单词会让读者昏昏欲睡,这是相反的!
就您的示例而言,您应该使用-command[]
中的可选括号\caption
来插入稍短的表格标题。如果这样做,括号中的内容将插入到表格列表部分。您应该输入完整内容:
\caption[Common challenges that high school students face]{Common challenges, that high school students face, which we collected from student participatory design workgroup}
所以我的简短回答是:使用你给出的样式/模板。它运行完美,并能给出合适的结果。
答案3
感谢 Christian 的回答和上述评论,我已经非常接近工作,如下面的代码和图片所示,但我注意到
%%%% This is in the main tex file %%%%
\documentclass[11pt]{report}
\usepackage{urcs-thesis}
%\linespread{1} % Use 1.2 for final version
% Add bibliograph to TOC
\usepackage[nottoc]{tocbibind}
% Allow \includegraphics[scale=•]{•}
\usepackage{graphicx}
%\usepackage[font={small, it}]{caption}
%\usepackage{caption}
\usepackage{comment}
\usepackage{textcomp}
% Change spacing for chapter headings
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\large\bfseries}{\chaptertitlename\ \thechapter}{5pt}{\LARGE}
\titlespacing*{\chapter}{0pt}{0pt}{30pt}
% Add numbers/TOC entries for subsubparagraphs
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{hyperref}
% my hack
\usepackage{setspace}
\doublespacing
\usepackage[toc,page]{appendix} % for appendix
\usepackage{color}
\def\bsq#1{%both single quotes
\lq{#1}\rq}
\usepackage[normalem]{ulem} % to strike the underline in journal titles
\usepackage{caption}
\usepackage{subcaption}
\usepackage{float} % for forcing figure placement
\DeclareRobustCommand{\rchi}{{\mathpalette\irchi\relax}} % to raise chi symbol above the line
\newcommand{\irchi}[2]{\raisebox{\depth}{$#1\chi$}} % inner command, used by \rchi
\usepackage{array} % to align left inside table http://texblog.org/2008/05/07/fwd-equal-cell-width-right-and-centre-aligned-content/
\newcolumntype{x}[1]{
>{\raggedright\hspace{0pt}}p{#1}}
\usepackage{tocloft}
\makeatletter
\newlength{\latexpnumwidth}
\setlength{\latexpnumwidth}{\@pnumwidth}
\addtolength{\cfttabnumwidth}{0.3in}
\addtocontents{lot}{\protect\cftsetpnumwidth{0.5in}}
\let\origcftdot\cftdot
\addtocontents{lot}{\protect\renewcommand{\protect\cftdot}{}} % Remove the dots
\addtocontents{lot}{\protect\contentsline{table}{\numberline{\textbf{\tablename}~}\textbf{Title}}{\textbf{Page}}} % Write the header line
\addtocontents{lot}{\protect\renewcommand{\protect\cftdot}{\origcftdot}}% Can be written 'expanded' and enable the dots again
\makeatother
\begin{document}
\title{Thesis title}
\author{Author Name}%$^\ast$}
\thesissupervisor{Professor X^\ast$ and Professor Y$^\dagger$}
\maketitle
\tableofcontents
\include{abstract}
\listoftables
\listoffigures
\pagenumbering{arabic}
\include{introduction}
\end{document}
%%%% End of the main tex file %%%%
%%%% This is in a separate file called 'introduction.tex' %%%%
\chapter{Introduction}
\label{chap:intro}
Hello World!
%%%% End of 'introduction.tex'%%%%%
%%%% This is in a separate file called 'urcs-thesis.sty' %%%%
\typeout{Document Style `urcsthesis' <14 April 1993> (modified).}
%
% margin settings
%
\textwidth 6.00in
\textheight 8.5in
\usepackage[letterpaper, margin=1.25in]{geometry}
\headheight 12pt
\headsep 30pt
\footskip 30pt
%
% paragraph settings
%
\parskip 4pt plus 1.5pt minus 1.5pt
\clubpenalty 500
\widowpenalty 500
\displaywidowpenalty=500
%
% more spacing between text and footnote
%
\def\footnoterule{\kern 2pt% extra space
\kern-3\p@\hrule width .4\columnwidth\kern 2.6\p@}
\footnotesep 10pt % more space between footnotes
%
% These changes to the defaults set in urcsmargin.sty are necessary to
% make the page number come out as requred by the thesis manual.
%
%\topmargin -.5in
%\headheight 12pt
%\headsep 42pt
%
% get UR macros
%
\newlength{\chaptitlewidth}
\newlength{\chapnowidth}
\input{urcsmacros}
%
% Space and a half. Required because the committee designing the
% standards was confused. Cannot be changed because it is a rule.
% (NGM)
%
\renewcommand{\baselinestretch}{1.5}
\newcommand{\singlespacethesis}{\def\baselinestretch{1}}
%
% year date format. Required by new manual 1992
%
\dateY
%
% thesisby
%
\def\thesisby#1{\gdef\@thesisby{#1}}
\def\@thesisby{\vskip 1ex by\vskip 1ex}
%
% thesissubmit
%
\def\thesissubmit#1{\gdef\@thesissubmit{#1}}
\def\@thesissubmit{\vskip 5ex Submitted in Partial Fulfillment of the\\~\\
Requirements for the Degree\vskip 1ex}
%
% thesisproposal
%
\def\thesisproposal{\thesissubmit{\vskip 5ex
Thesis\\~\\for the Degree\vskip 1ex}}
%
% thesisdegree
%
\def\thesisdegree#1{\gdef\@thesisdegree{#1}}
\def\@thesisdegree{{Degree name here}}
%
% thesissupervisor. Changed 1992
%
\def\thesissupervisor#1{\gdef\@thesissupervisor{#1}}
\def\@thesissupervisor{UNKNOWN}
%
% thesissupervise
%
\def\thesissupervise#1{\gdef\@thesissupervise{#1}}
\def\@thesissupervise{\vskip 5ex Supervised by\\~\\
\@thesissupervisor\vskip 1ex}
%
% thesisdepartment Changed 1992
%
%
\def\thesisdepartmentone#1{\gdef\@thesisdepartmentone{#1}}
\def\@thesisdepartmentone{$^\ast$ Department Name\\
School of Engineering \& Applied Sciences}
\def\thesisdepartmenttwo#1{\gdef\@thesisdepartmenttwo{#1}}
\def\@thesisdepartmenttwo{$^\dagger$ Department Name\\School Name}
% thesisuniversity Changed 1992 (NGM)
%
\def\thesisuniversity#1{\gdef\@thesisuniversity{#1}}
\def\@thesisuniversity{
\\University Name\\City, State\\}
%
% redefine maketitle to use the empty page style
%
\def\maketitle{\par
\begingroup
\def\thefootnote{\fnsymbol{footnote}}
\def\@makefnmark{\hbox
to 0pt{$^{\@thefnmark}$\hss}}
\newpage
\global\@topnum\z@ % Prevents figures from going at top of page.
\@maketitle\thispagestyle{empty}\@thanks
\endgroup
\setcounter{footnote}{0}
\let\maketitle\relax
\let\@maketitle\relax
\gdef\@thanks{}\gdef\@author{}\gdef\@title{}\let\thanks\relax}
%
% redefine @maketitle to box the information appropriately
% added parbox and hskip before it
% added techrepdept and techrepnum
% changed vertical space after date
%
\def\@maketitle{
%
% Turn off space and a half for title page (NGM)
%
\renewcommand{\baselinestretch}{1}
\newpage
\thispagestyle{empty} % So we get no page number on the title page
\null
\vspace{0.25in} % Vertical space above title.
\begin{center}
{\huge \@title \par} % Title set in \huge size.
{\large \@thesisby % Author set in \large size
\@author \par}
{\large \@thesissubmit \@thesisdegree}
{\large \@thesissupervise}
{\large \@thesisdepartmentone \vskip 0.5em}
{\large \@thesisdepartmenttwo \vskip 1.5em}
{\large \@thesisuniversity \vskip 1.5em \@date}
\end{center}
\pagenumbering{roman}
\clearpage
}
%
% curriculumvitaehead
%
\def\curriculumvitaehead#1{\gdef\@curriculumvitaehead{#1}}
\def\@curriculumvitaehead{\thispagestyle{plain}
\chapter*{Biographical Sketch\@mkboth{BIOGRAPHICAL SKETCH}{BIOGRAPHICAL SKETCH}}
\addcontentsline{toc}{chapter}{Biographical Sketch}}
%
% curriculumvitae
%
\newenvironment{curriculumvitae}{\@curriculumvitaehead}{\clearpage}
%
% acknowledgmentshead
%
\def\acknowledgmentshead#1{\gdef\@acknowledgmentshead{#1}}
\def\@acknowledgmentshead{\thispagestyle{plain}
\chapter*{Acknowledgments\@mkboth{ACKNOWLEDGEMENTS}{ACKNOWLEDGEMENTS}}
\addcontentsline{toc}{chapter}{Acknowledgments}}
%
% acknowledgments
%
\newenvironment{acknowledgments}{\@acknowledgmentshead}{\clearpage}
%
% abstracthead
%
\def\abstracthead#1{\gdef\@abstracthead{#1}}
\def\@abstracthead{\thispagestyle{plain}
\chapter*{Abstract\@mkboth{ABSTRACT}{ABSTRACT}}
\addcontentsline{toc}{chapter}{Abstract}}
%
% use narrow text width for abstract to center under window
% vfil before abstract
%
\renewenvironment{abstract}{\@abstracthead}{\clearpage}
%
% contributorsandfundinghead
%
\def\contributorsandfundinghead#1{\gdef\@contributorsandfundinghead{#1}}
\def\@contributorsandfundinghead{\thispagestyle{plain}
\chapter*{Contributors and Funding Sources\@mkboth{CONTRIBUTORS AND FUNDING
SOURCES}{CONTRIBUTORS AND FUNDING SOURCES}}
\addcontentsline{toc}{chapter}{Contributors and Funding Sources}}
%
% contributors and funding
%
\newenvironment{contributorsandfunding}{\@contributorsandfundinghead}{\clearpage}
%
% count chapters and sections two levels deep
%
\setcounter{secnumdepth}{2}
%
% enter only chapters and top sections are in the table of contents
%
\setcounter{tocdepth}{1}
%
% redefine plain page to put page numbers towards outside.
%
\def\ps@plain{\let\@mkboth\@gobbletwo
\def\@oddhead{\rm\hfil\thepage}\def\@oddfoot{}%
\def\@evenhead{\rm\thepage\hfil}\def\@evenfoot{}}
\pagestyle{plain}
%
% chapter redefinitions
%
\def\@chapapp{Chapter}
\def\thechapter{\arabic{chapter}}
\def\firstchapter{0} % for starting page numbers in arabic
%
% \@makechapterhead {TEXT} : Makes the heading for the \chapter command.
%
\def\@makechapterhead#1{ % Heading for \chapter command
\cleardoublepage
\ifcase\firstchapter
\pagenumbering{arabic}
\def\firstchapter{1} % do not do this again
\fi
\vspace*{50pt} % Space at top of text page.
{ \parindent 0pt \raggedright
\par
% Print chapter number and title.
\huge\bf\thechapter\hspace{1em}%
\settowidth{\chapnowidth}{\huge\bf\thechapter\hspace{1em}}%
\setlength{\chaptitlewidth}{\textwidth}%
\addtolength{\chaptitlewidth}{-\chapnowidth}%
\parbox[t]{\chaptitlewidth}{\raggedright#1}
\nobreak % TeX penalty to prevent page break.
\vskip 40pt % Space between title and text.
}
}
%
% \tableofcontents gets the title changed
%
\def\tableofcontents{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
\fi\chapter*{Table of Contents\@mkboth{TABLE OF CONTENTS}{TABLE OF CONTENTS}}
\@starttoc{toc}\if@restonecol\twocolumn\fi}
%
% \listoffigures gets table of contents entry
%
\def\listoffigures{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
\fi\chapter*{List of Figures\@mkboth
{LIST OF FIGURES}{LIST OF FIGURES}}
\addcontentsline{toc}{chapter}{List of Figures}\@starttoc{lof}\if@restonecol
\twocolumn\fi}
%
% \listoffigures gets table of contents entry
%
\def\listoftables{\@restonecolfalse\if@twocolumn\@restonecoltrue\onecolumn
\fi\chapter*{List of Tables\@mkboth
{LIST OF TABLES}{LIST OF TABLES}}
\addcontentsline{toc}{chapter}{List of Tables}\@starttoc{lot}\if@restonecol
\twocolumn\fi}
%
% \@makeschapterhead {TEXT} : Makes the heading for the \chapter* command.
%
\def\@makeschapterhead#1{ % Heading for \chapter* command
\vspace*{50pt} % Space at top of page.
\begin{center}
{\huge #1} % Print title.
\end{center}
\nobreak % TeX penalty to prevent page break.
\vskip 40pt % Space between title and text.
}
%
% place bibliography in table of contents
%
\def\thebibliography#1{\cleardoublepage\chapter*{Bibliography\@mkboth
{BIBLIOGRAPHY}{BIBLIOGRAPHY}}\addcontentsline{toc}{chapter}{Bibliography}\list
{[\arabic{enumi}]}{\settowidth\labelwidth{[#1]}\leftmargin\labelwidth
\advance\leftmargin\labelsep
\usecounter{enumi}}
\def\newblock{\hskip .11em plus .33em minus .07em}
\sloppy\clubpenalty4000\widowpenalty4000
\sfcode`\.=1000\relax}
%
% \clearpage added to start of appendicies
%
\def\appendix{\par
\setcounter{chapter}{0}
\setcounter{section}{0}
\setcounter{subsection}{0}
\def\@chapapp{Appendix}
\def\thechapter{\Alph{chapter}}}
%%%% End of 'urcs-thesis.sty' %%%%
%%%% This is in a separate file called 'urcsmacros.tex' %%%%
%
% urcsmacros
%
% author: Lawrence A. Crowl
% last updated: 28 April 1990
%
% BibTeX
%
\newcommand{\BibTeX}{{B\kern-.0833em{\sc ib}\kern-.1667em%
T\kern-.1667em\lower.5ex\hbox{E}\kern-.125emX}}
%
% SLiTeX
%
\newcommand{\SliTeX}{{\rm S\kern-.06em{\sc l\kern-.035emi}\kern-.06em
T\kern -.1667em\lower.7ex\hbox{E}\kern-.125emX}}
%
% UNIX
%
\newcommand{\UNIX}{{\sc Unix}}
%
% trademark
%
\newcommand{\trademark}{$^{\rm TM}$}
%
% singlespacing (for use in doublespaced documents)
%
\def\doublespacefactor#1#2{%
\newenvironment{singlespace}{\baselineskip #2\baselineskip}%
{\par \baselineskip #1\baselineskip}%
\par \baselineskip #1\baselineskip}
%
% various latin abbreviations
%
\def\adhoc{{\em ad hoc}}
\def\aposteriori{{\em a posteriori}}
\def\apriori{{\em a priori}}
\def\Cf{{\em Cf.}}
\def\cf{{\em cf.}}
\def\Eg{{\em E.g.}}
\def\eg{{\em e.g.}}
\def\etal{{et al.}}
\def\etc{{etc.\ }}
\def\Ibid{{\em Ibid.}}
\def\ibid{{\em ibid.}}
\def\Id{{\em Id.}}
\def\id{{\em id.}}
\def\Ie{{\em I.e.}}
\def\ie{{\em i.e.}}
\def\Loccit{{\em Loc.\ cit.}}
\def\loccit{{\em loc.\ cit.}}
\def\Opcit{{\em Op.\ cit.}}
\def\opcit{{\em op.\ cit.}}
\def\qv{{\em q.v.}}
\def\Qv{{\em Q.v.}}
\def\viz{{\em viz.}}
%
% andbreak (for breaking author lists)
%
\def\andbreak{%% \begin{tabular}
\end{tabular}\\\begin{tabular}[t]{c}%% \end{tabular}
}
%
% titlequote
%
\def\titlequote#1{\hfill
\parbox{4in}{\begin{flushright}{\small\it #1}\end{flushright}}}
%
% weekdaystring
%
% Dump the day of the week in string form.
% This macro is only valid from 1901 A.D. through 2099 A.D.
%
\def\weekdaystring#1#2#3{{% extra brace saves enclosing register state
%
% days through the end of the year
% days := current year * 365
\count10=#3%
\multiply\count10 by 365%
% leap years := year / 4
\count11=#3%
\divide\count11 by 4%
% days := days + leap years
\advance\count10 by \count11
%
% find out if the current year is a leap year
% last leap year := leap years * 4
\count12=\count11%
\multiply\count12 by 4
% years since last leap year := current year - last leap year
\count13=#3%
\advance\count13 by -\count12%
% years since last leap year equals zero when current year is a leap year
%
% subtract off those days in this month and the following months
% days = days - following days [ is leap ] [ current month ]
\ifcase#2%
\or\ifcase\count13\advance\count10 by -366% leap January
\else\advance\count10 by -365% normal January
\fi%
\or\ifcase\count13\advance\count10 by -335% leap February
\else\advance\count10 by -334% normal February
\fi%
\or\advance\count10 by -306% March
\or\advance\count10 by -275% April
\or\advance\count10 by -245% May
\or\advance\count10 by -214% June
\or\advance\count10 by -184% July
\or\advance\count10 by -153% August
\or\advance\count10 by -122% September
\or\advance\count10 by -92% October
\or\advance\count10 by -61% November
\or\advance\count10 by -31% December
\fi%
%
% update days by day of month
% days := days + current day
\advance\count10 by #1%
%
% find weekday number
% offset for initial day of the week
\advance\count10 by 5
% last monday := (current day / 7) * 7
\count14=\count10%
\divide\count14 by 7%
\multiply\count14 by 7
% weekday number := current day - last monday
\count15=\count10%
\advance\count15 by -\count14
%
% now dump out appropriate string
\ifcase\count15 Monday\or Tuesday\or Wednesday%
\or Thursday\or Friday\or Saturday\or Sunday\fi%
}}
%
% monthstring
%
% Dump the month in string form.
%
\def\monthstring#1{\ifcase#1\or January\or February\or March\or April\or May%
\or June\or July\or August\or September\or October\or November\or December\fi}
%
% dateWDMY
%
% Redefine \today as "weekdaystring daynumber monthstring yearnumber" format.
%
\def\dateWDMY{\def\today{\weekdaystring{\day}{\month}{\year}\space%
\number\day\space\monthstring{\month}\space\number\year}}
%
% dateDMY
%
% Redefine \today as "daynumber monthstring yearnumber" format.
%
\def\dateDMY{\def\today{\number\day\space\monthstring{\month}%
\space\number\year}}
%
% dateWMDY
%
% Redefine \today as "weekdaystring monthstring daynumber, yearnumber" format.
%
\def\dateWMDY{\def\today{\weekdaystring{\day}{\month}{\year}\space%
\monthstring{\month}\space\number\day,\space\number\year}}
%
% dateMDY
%
% Redefine \today as "monthstring daynumber, yearnumber" format.
%
\def\dateMDY{\def\today{\monthstring{\month}\space\number\day,%
\space\number\year}}
%
% dateMY
%
% Redefine \today as "monthstring yearnumber" format.
%
\def\dateMY{\def\today{\monthstring{\month}\space\number\year}}
%
% dateY
%
% Redefine \today as "yearnumber" format.
%
\def\dateY{\def\today{\number\year}}
%%%% End of 'urcsmacros.tex' %%%%
1)列标题行末尾有一个尾随“点”(如何删除它?)
2)我无法在表格行中再次打开“点”(可能我不明白 Christian 的评论“可以写入‘扩展’并再次启用点”是什么意思
任何人(包括 Christian)都可以提出答案,如果其他用户尝试完成我在这里尝试做的事情,我会根据需要更新此帖子。非常感谢!