我如何为两种不同类型的章节定制目录?

我如何为两种不同类型的章节定制目录?

我已经 ((重新) 定义了) 第二种类型的宏,\chapter因为我有两种不同类型的章节。但它们有一个计数器,它出现在 ToC 中的每个章节中。这是一个 MWE:

\documentclass{report}\usepackage{lipsum}
\makeatletter
\newcounter {uberschrift}
\renewcommand \theuberschrift {\@arabic\c@uberschrift}
\makeatother

\makeatletter
\newcommand\uberschrift{\if@openright\cleardoublepage\else\clearpage\fi % Typ I
                                    \thispagestyle{fancy}%
                                    \global\@topnum\z@
                                    \@afterindentfalse
                                    \secdef\@uberschrift\@suberschrift}
\def\@uberschrift[#1]#2{\ifnum \c@secnumdepth >\m@ne
                                             \refstepcounter{chapter}%
                                             \refstepcounter{uberschrift}%
                                             \addcontentsline{toc}{chapter}%
                             {\protect\numberline{\thechapter}#1}%
                                    \else
        \addcontentsline{toc}{chapter}{#1}
                                    \fi
                                    \chaptermark{#1}%
                                    \addtocontents{lof}{\protect\addvspace{3\p@}}%
                                    \addtocontents{lot}{\protect\addvspace{2\p@}}%
                                    \if@twocolumn
                                        \@topnewpage[\@makeuberschrifthead{#2}]%
                                    \else
                                        \@makeuberschrifthead{#2}%
                                        \@afterheading
                                    \fi}
\def\@makeuberschrifthead#1{%
\vspace*{-20\p@}%
{\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
    \fi
    \interlinepenalty\@M
    \Huge \bfseries \thechapter\space   #1\par\nobreak
    \vskip 20\p@
}}
\def\@suberschrift#1{\if@twocolumn
                             \@topnewpage[\@makesuberschrifthead{#1}]%
                             \else
                                 \@makesuberschrifthead{#1}%
                                 \@afterheading
                             \fi}
\def\@makesuberschrifthead#1{%
\vspace*{-20\p@}%
{\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries \thechapter\space   #1\par\nobreak
    \vskip 20\p@
}}
\makeatother
\makeatletter
\renewcommand\chapter{\if@openright\cleardoublepage\else\clearpage\fi
                                    \thispagestyle{fancy}
                                    \global\@topnum\z@
                                    \@afterindentfalse
                                    \secdef\@chapter\@schapter}
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
\refstepcounter{chapter}
\typeout{\@chapapp   \thechapter.}      \addcontentsline{toc}{chapter}
         {\protect\numberline{\thechapter}#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*{0\p@}%
{\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
            \huge\bfseries \@chapapp \space \thechapter
            \par\nobreak
            \vskip 20\p@
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 20\p@
}}
\def\@schapter#1{\if@twocolumn
                                 \@topnewpage[\@makeschapterhead{#1}]%
                             \else
                                 \@makeschapterhead{#1}%
                                 \@afterheading
                             \fi}
\def\@makeschapterhead#1{%
\vspace*{-10\p@}%
{\parindent \z@ \raggedright
    \normalfont
    \interlinepenalty\@M
    \Huge \bfseries  #1\par\nobreak
    \vskip 20\p@
}}
\makeatother
\begin{document}
 \tableofcontent
\chapter{One}
 \lipsum[1]
\uberschrift{Two}
 \lipsum[2]
\end{document}

因此我重新定义了\chapter以两种不同方式表现的行为(“chapter”和“uberschrift”)。- \chapterchapter 应该出现没有我的目录中有一个数字,而\uberschrift章节应该出现在一个号码。

相关内容