目錄:章節標籤中沒有章節編號

目錄:章節標籤中沒有章節編號

我的目錄如下圖所示:

 I        Chapter I
 I.1      Section I.1
 I.2      Section I.2

 II       Chapter II
 II.1     Section II.1
 II.2     Section II.2

我怎麼才能讓它看起來像這樣:

 I        Chapter I
 1        Section I.1
 2        Section I.2

 II       Chapter II
 1        Section II.1
 2        Section II.2

微量元素:

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{titletoc}

\titleclass{\part}{top}
\titleformat{\part}[display]
{\centering\normalfont}
{\itshape \partname~\thepart}{1.0em}
{\bfseries\MakeUppercase}
\titlespacing*{\part}{0pt}{0pt}{20pt}

\renewcommand{\thechapter}{\Roman{chapter}}

\dottedcontents{chapter}[3.0em]{\scshape\bfseries\vspace{1.0em}}{2.5em}{0pc}
\dottedcontents{section}[3.0em]{}{3.5em}{0.75pc}

\begin{document}

\startcontents[parts]
\part{Part I}

\printcontents[parts]{}{0}{}

\chapter{Chapter I}
\section{Section I.1}
\section{Section I.2}

\chapter{Chapter II}
\section{Section II.1}
\section{Section II.2}

\stopcontents[parts]

\end{document}

答案1

這就是您所需要的。

  • \renewcommand{\thesection}{\arabic{section}}
  • \titleformat{\section} {\normalfont\Large\bfseries}{\thechapter.\thesection}{1em}{}對於標題
  • \renewcommand{\p@section}{\thechapter.}以供交叉參考。

當然,您需要調整目錄條目中的間距。

例子

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{titletoc}

\titleclass{\part}{top}
\titleformat{\part}[display]
{\centering\normalfont}
{\itshape \partname~\thepart}{1.0em}
{\bfseries\MakeUppercase}
\titlespacing*{\part}{0pt}{0pt}{20pt}

\renewcommand{\thechapter}{\Roman{chapter}}

\titleformat{\section}
{\normalfont\Large\bfseries}{\thechapter.\thesection}{1em}{}
\renewcommand{\thesection}{\arabic{section}}
\makeatletter 
\renewcommand{\p@section}{\thechapter.}
\makeatother

\dottedcontents{chapter}[3.0em]{\scshape\bfseries\vspace{1.0em}}{2.5em}{0pc}
\dottedcontents{section}[3.0em]{}{3.5em}{0.75pc}

\begin{document}

\startcontents[parts]
\part{Part I}

\printcontents[parts]{}{0}{}

\chapter{Chapter I}
\section{Section I.1}
\section{Section I.2}

\chapter{Chapter II}
\section{Section II.1}
\section{Section II.2}

\stopcontents[parts]

\end{document}

答案2

可能不是最好和更簡單的答案...我重新定義了這些部分以顯示不同的 edry 到 toc 並在正文中具有不同的外觀:

\documentclass{report}
\usepackage[T1]{fontenc}
\usepackage{titlesec}
\usepackage{titletoc}

\titleclass{\part}{top}
\titleformat{\part}[display]
{\centering\normalfont}
{\itshape \partname~\thepart}{1.0em}
{\bfseries\MakeUppercase}
\titlespacing*{\part}{0pt}{0pt}{20pt}


\titleformat{\section}{\large\bf}{}{0pt}{}

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\dottedcontents{chapter}[3.0em]{\scshape\bfseries\vspace{1.0em}}{2.5em}{0pc}
\dottedcontents{section}[3.35em]{}{3.5em}{0.75pc}

\let\oldsection\section
    \makeatletter
    \def\section{%
    \@ifstar{\@Starred}{\@nonStarred}%
    }
    \def\@Starred{%
    \@ifnextchar[%
    {\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
    {\@StarredWithout}%
    }      
    \def\@StarredWith[#1]#2{%
    \oldsection*[\thesection]{\thechapter.\thesection\space#2}%
    }
    \def\@StarredWithout#1{
    \oldsection*{\thechapter.\thesection\space#1}%
    }
    \def\@nonStarred{%
    \@ifnextchar[%
    {\@nonStarredWith}%
    {\@nonStarredWithout}%
    }
    \def\@nonStarredWith[#1]#2{%
    \oldsection[#1]{\thechapter.\thesection\space#2}%
    }
    \def\@nonStarredWithout#1{%
    \oldsection[#1]{\thechapter.\thesection\space#1}%
    }
    \makeatother




\begin{document}

\startcontents[parts]
\part{Part I}

\printcontents[parts]{}{0}{}

\chapter{Chapter I}
\section{Section I.1}
\section{Section I.2}

\chapter{Chapter II}
\section{Section II.1}
\section{Section II.2}


\stopcontents[parts]

\end{document}

您可以在 def 命令的新部分中執行任何您想要的操作。我剛剛製作了原始的無星號且沒有目錄選項的目錄選項。

結果內容:

在此輸入影像描述

並在體內:

在此輸入影像描述

相關內容