首先,我有这个代码:
\documentclass[a5paper,11pt]{book}
\usepackage{titletoc}
\usepackage{times}
\usepackage[pdftex,bookmarks=true]{hyperref}
\usepackage[top=1.5cm, bottom=1.5cm, outer=1.5cm, inner=2.5cm]{geometry}
\begin{document}
\newpage\phantomsection\addcontentsline{toc}{chapter}{Contents}
\setcounter{page}{1}
\makeatletter\renewcommand\l@chapter[2]{\ifnum \c@tocdepth >\z@\addpenalty\@secpenalty\addvspace{0em}\setlength\@tempdima{1.4em}\begingroup\parindent \z@ \rightskip \@pnumwidth\parfillskip -\@pnumwidth\leavevmode \bfseries \advance\leftskip\@tempdima\hskip -\leftskip#1\nobreak\ \leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfil\nobreak\hb@xt@\@pnumwidth{\hss #2}\par\endgroup\fi}\makeatother
\makeatletter
\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*{BIBLIOGRAPHY}
contents...\addcontentsline{toc}{chapter}{BIBLIOGRAPHY}
\end{document}
这段代码的结果是
现在,我想在章节号前添加单词“CHAPTER”,代码变为
\documentclass[a5paper,11pt]{book}
\usepackage{titletoc}
\usepackage{times}
\usepackage[pdftex,bookmarks=true]{hyperref}
\usepackage[top=1.5cm, bottom=1.5cm, outer=1.5cm, inner=2.5cm]{geometry}
\begin{document}
\titlecontents{chapter}[6em]{\bigskip\bfseries}%\vspace{1cm}%
{\contentslabel[ \chaptername~\thecontentslabel]{5.5em}}%
{}%numberless chapters%
{\hfill\contentspage}[\medskip]%
\newpage\phantomsection\addcontentsline{toc}{chapter}{Contents}
\setcounter{page}{1}
\makeatletter\renewcommand\l@chapter[2]{\ifnum \c@tocdepth >\z@\addpenalty\@secpenalty\addvspace{0em}\setlength\@tempdima{1.4em}\begingroup\parindent \z@ \rightskip \@pnumwidth\parfillskip -\@pnumwidth\leavevmode \bfseries \advance\leftskip\@tempdima\hskip -\leftskip#1\nobreak\ \leaders\hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfil\nobreak\hb@xt@\@pnumwidth{\hss #2}\par\endgroup\fi}\makeatother
\makeatletter
\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*{BIBLIOGRAPHY}
contents...\addcontentsline{toc}{chapter}{BIBLIOGRAPHY}
\end{document}
这段代码的结果是
我不希望“章节”后面出现空白,就像第一张图片一样。我希望左侧显示“目录”和“参考书目”。我希望出现圆点。就像这张图片一样: 变成这样:
怎么做?
答案1
tocbasic
这里建议使用包tocloft
。 (警告:不要同时加载包tocbasic
和tocloft
!)
\documentclass[a5paper,11pt]{book}
\usepackage{newtxtext,newtxmath}
\usepackage[margin=1.5cm, inner=2.5cm]{geometry}
\usepackage{tocbasic}
\usepackage[bookmarks=true]{hyperref}% load as last package
\DeclareTOCStyleEntry[
linefill=\TOCLineLeaderFill,
beforeskip=0pt,
entrynumberformat=\chapterprefixintoc,
dynnumwidth
]{tocline}{chapter}
\newcommand*\chapterprefixintoc[1]
{\MakeUppercase{\chaptername}~#1\enskip}
\begin{document}
\cleardoublepage
\phantomsection\addcontentsline{toc}{chapter}{CONTENTS}
\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*{BIBLIOGRAPHY}
\addcontentsline{toc}{chapter}{BIBLIOGRAPHY}
contents
\end{document}
运行三次得到:
对于带有粗体点的章节条目,使用:
linefill=\bfseries\TOCLineLeaderFill
结果:
答案2
由于您使用titletoc
这里是使用此包的解决方案:
\documentclass[a5paper, 11pt]{book}
\usepackage{titletoc}
\usepackage{times}
\usepackage[pdftex, bookmarks=true]{hyperref}
\usepackage[top=1.5cm, bottom=1.5cm, outer=1.5cm, inner=2.5cm]{geometry}
\begin{document}
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\vspace{1ex}\bfseries}% <above-code>
{\chaptername\ \thecontentslabel\quad}% <numbered-entry-format>
{}% <numberless-entry-format>
{\titlerule*[0.696pc]{\scriptsize.} \contentspage}% <filler-page-format>
[\vspace{2pt}]
\newpage\phantomsection\addcontentsline{toc}{chapter}{Contents}
\setcounter{page}{1}
\makeatletter
\renewcommand\l@chapter[2]{\ifnum \c@tocdepth >\z@\addpenalty\@secpenalty\addvspace{0em}\setlength\@tempdima{1.4em}\begingroup\parindent \z@ \rightskip \@pnumwidth\parfillskip -\@pnumwidth\leavevmode
\bfseries \advance\leftskip\@tempdima\hskip -\leftskip#1\nobreak\
\leaders \hbox{$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}
\hfil\nobreak\hb@xt@\@pnumwidth{\hss #2}\par\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*{BIBLIOGRAPHY}
contents...\addcontentsline{toc}{chapter}{BIBLIOGRAPHY}
\end{document}