我正在尝试使用当前目录实现以下功能。我想删除特定项目(例如声明、摘要等)的垂直间距。
然后我希望所有内容都左对齐,并且没有编号缩进。 我正在使用标准
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[11pt, oneside]{book} %reminder to add twoside command when printing
\pagestyle{plain}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Packages to use. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{hyperref}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{2212}{-}% support older LaTeX versions
\usepackage[a4paper,left=30mm,right=20mm,top=20mm,bottom=20mm]{geometry}
\usepackage{float}
\usepackage{rotating}
\usepackage{parskip}
\usepackage{rotating}
\usepackage{upgreek}
\usepackage{amsmath}
\usepackage{lipsum}
\usepackage[most]{tcolorbox}%
\usepackage{multirow}
\usepackage{tocbasic}
\usepackage{expl3}
\usepackage{tocbibind}
%%%%%%%%%%%%%%%%%
% Setup line spacing for document %
%%%%%%%%%%%%%%%%%
\usepackage{setspace}
%\singlespacing
\onehalfspacing
%\doublespacing
%\setstretch{1.1}
%%%%%%%%%%%%%%%%%
% THE BEGINNING %
%%%%%%%%%%%%%%%%%
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\addcontentsline{toc}{chapter}{Dedication}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlah}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlahBlah}
\blindtext
\blinddocument
\end{document}
将额外的项目添加到目录和 \tableofcontents 以创建我的目录。
任何帮助都将不胜感激。
答案1
更新
现在问题中有一个 MWE,我知道 TOC、LOF 和 LOT 等的 TOC 条目是必需的。但我不明白评论
编号和标题之间的对齐也需要一致
意思。因此,期望的结果是什么仍是一个猜测。
\documentclass[11pt,a4paper,oneside]{book}
\usepackage{blindtext}% only for dummy text
\pagestyle{plain}
\usepackage[utf8]{inputenc}
\usepackage[margin=20mm,left=30mm]{geometry}
\usepackage{parskip}
\usepackage[onehalfspacing]{setspace}
\usepackage{tocbibind}
\usepackage{tocbasic}
\usepackage{expl3}
\usepackage{hyperref}% <- should be the last package
\ExplSyntaxOn
\clist_map_inline:nn
{chapter,section,subsection,subsubsection,paragraph,subparagraph}
{\DeclareTOCStyleEntry[indent=0pt,numwidth=3.8em]{tocline}{#1}}
\clist_map_inline:nn
{figure,table}
{\DeclareTOCStyleEntry[indent=0pt]{tocline}{#1}}
\ExplSyntaxOff
\DeclareTOCStyleEntry[%
level=\chaptertocdepth,%
beforeskip=0pt plus .2pt,%
indent=0em,%
numwidth=3.8em,%
entryformat=\textbf,%
pagenumberformat=\textbf,%
linefill=\hfill
]{tocline}{fmchapter}
\makeatletter
\let\l@origchapter\l@chapter
\newcommand*\usefmchapter{% define switch to fmchapter entry
\addtocontents{toc}{%
\protect\addvspace{1em plus 1pt}% additional space in TOC before the first fmchapter entry
\protect\let\protect\l@chapter\protect\l@fmchapter
}%
}
\newcommand*\useorigchapter{% define switch to original chapter entry
\addtocontents{toc}{%
\protect\let\protect\l@chapter\protect\l@origchapter
}%
}
\makeatother
\begin{document}
\usefmchapter% <- switch
\tableofcontents
\listoffigures
\listoftables
\addcontentsline{toc}{chapter}{Dedication}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlah}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlahBlah}
\blindtext
\useorigchapter% <- switch
\blinddocument
\usefmchapter% <- switch
\addcontentsline{toc}{chapter}{Conclusion}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlah}
\blindtext
\addcontentsline{toc}{chapter}{BLahBlahBlah}
\blindtext
\end{document}
结果:
请注意,您可以/必须numwidth=3.8em
根据您的需要进行调整。
但如果你想要
那么您必须使用的numwidth
值:indent
fmchapter
\DeclareTOCStyleEntry[%
level=\chaptertocdepth,%
beforeskip=0pt plus .2pt,%
indent=3.8em,% <- changed
numwidth=3.8em,%
entryformat=\textbf,%
pagenumberformat=\textbf,%
linefill=\hfill
]{tocline}{fmchapter}
原始答案
不幸的是,问题中没有 MWE,所以这只是一个猜测。以下建议使用包tocbasic
在 TOC 中声明额外的条目样式:
\documentclass[11pt,oneside]{book}
\pagestyle{plain}
\usepackage{tocbasic}
\usepackage{expl3}
\ExplSyntaxOn
\clist_map_inline:nn
{chapter,section,subsection,subsubsection,paragraph,subparagraph}
{\DeclareTOCStyleEntry[indent=0pt]{tocline}{#1}}
\ExplSyntaxOff
\DeclareTOCStyleEntry[%
level=\chaptertocdepth,%
beforeskip=0pt plus .2pt,%
indent=0pt,%
numwidth=1.5em,%
entryformat=\textbf,%
pagenumberformat=\textbf,%
linefill=\hfill
]{tocline}{fmchapter}
\usepackage{blindtext}% only for dummy text
\begin{document}
\tableofcontents
\chapter*{Declaration}\addcontentsline{toc}{fmchapter}{Declaration}
\blindtext
\chapter*{Abstract}\addcontentsline{toc}{fmchapter}{Abstract}
\blindtext
\chapter*{Dedication}\addcontentsline{toc}{fmchapter}{Dedication}
\blindtext
\blinddocument
\end{document}
结果: