我遇到了目录问题。章节的点不起作用。如何修复它。这是我的代码
\documentclass[a5paper,11pt]{book}
\usepackage[a5paper,hmargin={2.5cm,1.5cm},vmargin={1.5cm,1.5cm}]{geometry}
\usepackage{times}
\usepackage[indonesian]{babel}
\usepackage{graphicx}
\usepackage{graphics}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{mathrsfs}
%\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{fancyvrb}
\usepackage{natbib}
\usepackage{titletoc}
\usepackage[titles]{tocloft}
\usepackage{ragged2e}
\usepackage{amsthm}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,arrows}
\usepackage{caption}
\usepackage{lscape}
\usepackage{afterpage}
\usepackage{tocbasic}
\usepackage{setspace}
\usepackage{hyperref}
\usepackage{listings}
%\usepackage[utf8]{inputenc}
\usepackage{placeins}
\allowdisplaybreaks
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\titleformat{\section}
{\normalfont\fontsize{11}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{11}{15}\bfseries}{\thesubsection}{1em}{}
\DeclareTOCStyleEntry[
linefill=\bfseries\TOCLineLeaderFill,beforeskip=2pt,entrynumberformat=\chapterprefixintoc,dynnumwidth
]{tocline}{chapter}
%format daftar isi
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\bfseries}% <above-code>
{\MakeUppercase{\chaptername}
\thecontentslabel \quad}%<numbered-entry-format>
{}% <numberless-entry-format>
{\mdseries\titlerule*[0.75]{.}\bfseries}
\titleformat{\chapter}[hang]{\centering\huge\bfseries}{\thechapter.}{1em}{}
\titlespacing*{\chapter}{0pt}{-3em}{1.1\parskip}
\titlelabel{\thetitle\quad}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
%format daftar lampiran
\newcommand\listappendixname{\centering \normalsize DAFTAR LAMPIRAN}
\newcommand\appcaption[1]{%
\addcontentsline{app}{chapter}{#1}}
\makeatletter
\newcommand\listofappendices{
\chapter*{\listappendixname}\@starttoc{app}}
\makeatother
\theoremstyle{definition}
\newtheorem{lemma}[subsection]{Lemma}
\newtheorem{defn}[subsection]{Definisi}
\newtheorem{prop}[subsection]{Proposisi}
\newtheorem{exmp}[subsection]{Contoh}
\newtheorem{thm}[subsection]{Teorema}
\begin{document}
\tableofcontents
\chapter{tes}
\chapter{a}
\section{b}
\subsection{c}
\end{document}
有什么问题?谢谢。
答案1
tocloft
,titletoc
并且tocbasic
不能很好地协同工作。如果您只使用tocloft
以下代码:
\documentclass[...]{...}
\usepackage{tocloft}
\renewcommand{\cftchapdotsep}{\cftdotsep}
> texdoc tocloft
将在章节目录中生成虚线引线。有关详细信息,请参阅手册 ( )。
答案2
不要在同一文档中使用tocloft
、titletoc
和。tocbasic
建议使用tocbasic
(tocloft
,titletoc
和\titlecontents
被删除):
\documentclass[a5paper,11pt]{book}
\usepackage[a5paper,hmargin={2.5cm,1.5cm},vmargin={1.5cm,1.5cm}]{geometry}
\usepackage{times}
\usepackage[indonesian]{babel}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{indentfirst}
\usepackage{titlesec}
\usepackage{mathrsfs}
%\usepackage{enumitem}
\usepackage{fancyhdr}
\usepackage{fancyvrb}
\usepackage{natbib}
\usepackage{ragged2e}
\usepackage{amsthm}
\usepackage{tikz}% loads also graphicx
\usetikzlibrary{shapes.geometric,arrows}
\usepackage{caption}
\usepackage{lscape}
\usepackage{afterpage}
\usepackage{tocbasic}
\usepackage{setspace}
\usepackage{listings}
%\usepackage[utf8]{inputenc}
\usepackage{placeins}
\usepackage{hyperref}% <- load as last package
\allowdisplaybreaks
\tolerance=1
\emergencystretch=\maxdimen
\hyphenpenalty=10000
\hbadness=10000
\titleformat{\section}
{\normalfont\fontsize{11}{15}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontsize{11}{15}\bfseries}{\thesubsection}{1em}{}
\DeclareTOCStyleEntry[
linefill=\bfseries\TOCLineLeaderFill,beforeskip=2pt,entrynumberformat=\chapterprefixintoc,dynnumwidth
]{tocline}{chapter}
\newcommand\chapterprefixintoc[1]{\MakeUppercase{\chaptername}~#1~}% <- added
\titleformat{\chapter}[hang]{\centering\huge\bfseries}{\thechapter.}{1em}{}
\titlespacing*{\chapter}{0pt}{-3em}{1.1\parskip}
\titlelabel{\thetitle\quad}
\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{chapter}.\arabic{section}}
\renewcommand{\theequation}{\arabic{chapter}.\arabic{equation}}
\renewcommand{\thetable}{\arabic{chapter}.\arabic{table}}
\renewcommand{\thefigure}{\arabic{chapter}.\arabic{figure}}
%format daftar lampiran using package tocbasic
\DeclareNewTOC[
owner=\jobname,
type=appendix,types=appendices,
listname={Daftar Lampiran}
]{app}
\DeclareTOCStyleEntry[
level=\chaptertocdepth,
indent=0pt,numwidth=0pt,dynnumwidth,
entryformat=\textbf,
linefill=\bfseries\TOCLineLeaderFill,
pagenumberformat=\textbf
]{tocline}{appendix}
\newcommand\appcaption[1]{%
\addxcontentsline{app}{appendix}{#1}}
\theoremstyle{definition}
\newtheorem{lemma}[subsection]{Lemma}
\newtheorem{defn}[subsection]{Definisi}
\newtheorem{prop}[subsection]{Proposisi}
\newtheorem{exmp}[subsection]{Contoh}
\newtheorem{thm}[subsection]{Teorema}
\begin{document}
\tableofcontents
\chapter{tes}
\chapter{a}
\section{b}
\subsection{c}
\end{document}
请注意,我tocbasic
也已经定义了附录列表。
答案3
您正在使用该titletoc
包,并且序言包含以下代码块:
\titlecontents{chapter}% <section-type>
[0pt]% <left>
{\bfseries}% <above-code>
{\renewcommand{\chaptername}{BAB}\chaptername\ \thecontentslabel \quad}%<numbered-entry-format>
{}% <numberless-entry-format>
{\hfill\contentspage}
此块最后一行中的指令\hfill
指示 LaTeX 在章节号和名称以及相关页码之间插入尽可能多的空格。要从空格切换到点引线,我建议您将其替换\hfill
为
\mdseries\titlerule*[0.75em]{.}\bfseries
这会将点之间的水平距离设置为0.75em
;请随意修改此设置。
在你这样做的同时,你可能还想改变
\renewcommand{\chaptername}{BAB}\chaptername
到
\MakeUppercase{\chaptername}
完成这些更改后,测试目录应如下所示:
我不得不说,目录的布局看起来相当杂乱。您当前加载了包tocloft
,但实际上并未使用其任何功能。我建议您考虑改进目录的布局。在我看来,使用包的宏tocloft
(并删除titletoc
包及其宏)应该可以让您获得更好的外观。