只想在章节号前添加单词“CHAPTER”,但在节和小节号前出现单词“CHAPTER”

只想在章节号前添加单词“CHAPTER”,但在节和小节号前出现单词“CHAPTER”

我想在目录的章节号前添加单词“CHAPTER”,但不希望“CHAPTER”出现在节和小节号之前。这是我的代码

\documentclass{book}
\begin{document}
    \let\oldnumberline\numberline%
    \renewcommand{\numberline}{\chaptername~\oldnumberline}%
    \tableofcontents

    \chapter{PENDAHULUAN}
    contents...
    \section{Latar Belakang}
    contents...
    \subsection{ABCD}
    contents..
    \subsection{EFGH}
    ...
    \section{Rumusan Masalah}
    \vspace{0.3cm}
    blablabla

    \section{Tujuan Penulisan}
    \vspace{0.25cm}
    blablabla..

    \chapter{DASAR TEORI}
    contents...
    \chapter{PEMBAHASAN}
    contents...
    \chapter{PENUTUP}
    contents...
    \chapter*{DAFTAR PUSTAKA}
    contents...
\end{document}

此代码给我 在此处输入图片描述

如何删除章节和小节编号前的单词“CHAPTER”?谢谢。

答案1

不要chaptername使用\numberline

像这样使用

\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
     Chapter #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

\makeatother

你的代码:

\documentclass{book}
\begin{document}
%    %
%    %

\makeatletter
\renewcommand*\l@chapter[2]{%
  \ifnum \c@tocdepth >\m@ne
    \addpenalty{-\@highpenalty}%
    \vskip 1.0em \@plus\p@
    \setlength\@tempdima{1.5em}%
    \begingroup
      \parindent \z@ \rightskip \@pnumwidth
      \parfillskip -\@pnumwidth
      \leavevmode \bfseries
      \advance\leftskip\@tempdima
      \hskip -\leftskip
     Chapter #1\nobreak\hfil \nobreak\hb@xt@\@pnumwidth{\hss #2}\par
      \penalty\@highpenalty
    \endgroup
  \fi}

\makeatother

    \tableofcontents

    \chapter{PENDAHULUAN}
    contents...
    \section{Latar Belakang}
    contents...
    \subsection{ABCD}
    contents..
    \subsection{EFGH}
    ...
    \section{Rumusan Masalah}
    \vspace{0.3cm}
    blablabla

    \section{Tujuan Penulisan}
    \vspace{0.25cm}
    blablabla..

    \chapter{DASAR TEORI}
    contents...
    \chapter{PEMBAHASAN}
    contents...
    \chapter{PENUTUP}
    contents...
    \chapter*{DAFTAR PUSTAKA}
    contents...
\end{document}

输出: 在此处输入图片描述

答案2

使用软件包非常简单 titletoc,它包含以下内容titlesec

\documentclass{book}

\usepackage{titletoc}

          \titlecontents{chapter}[6em]{\bigskip\bfseries}%\vspace{1cm}%
          {\contentslabel[ \chaptername~\thecontentslabel]{5.5em}}%
          {}%numberless chapters%
          {\hfill\contentspage}[\medskip]%

\begin{document}

    \tableofcontents

    \chapter{PENDAHULUAN}
    contents...
    \section{Latar Belakang}
    contents...
    \subsection{ABCD}
    contents..
    \subsection{EFGH}
    ...
    \section{Rumusan Masalah}
    \vspace{0.3cm}
    blablabla

    \section{Tujuan Penulisan}
    \vspace{0.25cm}
    blablabla..

    \chapter{DASAR TEORI}
    contents...
    \chapter{PEMBAHASAN}
    contents...
    \chapter{PENUTUP}
    contents...
    \chapter*{DAFTAR PUSTAKA}
    contents...

\end{document} 

在此处输入图片描述

答案3

带包的示例tocbasic

\documentclass{book}

\usepackage{tocbasic}
\DeclareTOCStyleEntry[
  entrynumberformat=\chapterprefixintoc,
  dynnumwidth
]{tocline}{chapter}
\newcommand*\chapterprefixintoc[1]
  {\MakeUppercase{\chaptername}~#1\enskip}


\begin{document}
\tableofcontents

\chapter{PENDAHULUAN}
contents...
\section{Latar Belakang}
contents...
\subsection{ABCD}
contents..
\subsection{EFGH}
...
\section{Rumusan Masalah}
\vspace{0.3cm}
blablabla

\section{Tujuan Penulisan}
\vspace{0.25cm}
blablabla..

\chapter{DASAR TEORI}
contents...
\chapter{PEMBAHASAN}
contents...
\chapter{PENUTUP}
contents...
\chapter*{DAFTAR PUSTAKA}
contents...
\end{document}

运行三次得到:

在此处输入图片描述

相关内容