我有以下 LaTeX 文档正在 Windows 7 上的 TeXstudio 2.3 中编译(模式为 PdfLatex + PdfViewer):
\documentclass[a4paper,12pt]{report}
% Modified \part and \chapter from report.cls
\makeatletter
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\addcontentsline{toc}{part}{#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
\markboth{}{}%
{\centering
\interlinepenalty \@M
\normalfont
\Huge \bfseries #2\par}%
\@endpart}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}\makeatother
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\renewcommand{\thesection}{\arabic{section}}% Remove \thechapter from \thesection}
\makeatother
\begin{document}
\tableofcontents
\part{Part One}
\chapter[Chapter Other One]{Chapter One}
\section{Section First}
\subsection{Subsection X}
Djigurda is here.
\subsection{Castles with Penguins}
Castles with penguins here.
\end{document}
问题是,\chapter
命令在生成的 PDF 中生成两行:
那么我该如何关闭编号标题?我只希望Chapter One
显示。
答案1
以下是对部门单位的重新定义report.cls
。它删除了要打印在 ToC 以及主报告正文中的\part
和的数量。但是,计数器仍会递增,以便在必要时重置其他从属计数器。\chapter
\documentclass[a4paper,12pt]{report}
%\usepackage[T2A]{fontenc}% http://ctan.org/pkg/fontenc
%\usepackage[utf8]{inputenc}% http://ctan.org/pkg/inputenc
%\usepackage[english]{babel}% http://ctan.org/pkg/babel
% Modified \part and \chapter from report.cls
\makeatletter
\def\@part[#1]#2{%
\ifnum \c@secnumdepth >-2\relax
\refstepcounter{part}%
\addcontentsline{toc}{part}{#1}%
\else
\addcontentsline{toc}{part}{#1}%
\fi
\markboth{}{}%
{\centering
\interlinepenalty \@M
\normalfont
\Huge \bfseries #2\par}%
\@endpart}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}%
\typeout{\@chapapp\space\thechapter.}%
\addcontentsline{toc}{chapter}%
{#1}%
\else
\addcontentsline{toc}{chapter}{#1}%
\fi
\chaptermark{#1}%
\addtocontents{lof}{\protect\addvspace{10\p@}}%
\addtocontents{lot}{\protect\addvspace{10\p@}}%
\if@twocolumn
\@topnewpage[\@makechapterhead{#2}]%
\else
\@makechapterhead{#2}%
\@afterheading
\fi}
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\interlinepenalty\@M
\Huge \bfseries #1\par\nobreak
\vskip 40\p@
}}
\renewcommand{\thesection}{\arabic{section}}% Remove \thechapter from \thesection}
\makeatother
\begin{document}
\tableofcontents
\part{Part One}
\chapter[Chapter Other One]{Chapter One}
\section{Section First}
\subsection{Subsection X}
Djigurda is here.
\subsection{Castles with Penguins}
Castles with penguins here.
\end{document}
受影响的宏是
\@part
(删除打印内容Part \thepart
并包含\thepart
在目录中);\@chapter
(删除了\thechapter
目录中的打印内容);\@makechapterhead
(删除了Chapter \thechapter
章节标题中的印刷内容);以及\thesection
(删除了\thechapter
计数器的一部分的打印)。