我正在尝试interfaces-tocloft
从我的文档中删除该包,但它在某些情况下会导致问题,并且在某些情况下会加载我不想要的包,所以我尝试使用titletoc
(这对我来说更熟悉tocloft
),但我无法获得相同的结果。这是我使用该interfaces-tocloft
包的示例文件:
% toctest.tex
\listfiles
\documentclass[10pt]{ltxdoc}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage[showframe]{geometry}
\usepackage{lipsum,xcolor,multicol,hyperref,blindtext}
%\usepackage{titletoc}
\setlength{\parindent}{0pt}
\usepackage{tocloft}
\usepackage{interfaces-tocloft}
% Config hyperref
\hypersetup{
linkcolor = blue!50,
colorlinks = true,%
}
% Table of contents
\def\rulecolor{\color{gray}}
\tocsetup{%
title=Contents\quad{\rulecolor\leaders\vrule height4.4pt depth-4pt\hfill\null},
title/after= \vspace{3pt},
title/font= \sffamily\bfseries\Large,%
title/top=10pt,%
title/bottom=0pt,%
twocolumns,
section/skip=4pt plus2pt minus2pt,%
subsection/skip=0pt plus2pt minus2pt,
section/leaders,section/dotsep,%
after=\vspace{-3pt}\noindent{\rulecolor\hrule height4.4pt depth-4pt\relax},
}
\begin{document}
\tableofcontents
\section{Introduction}
\subsection{A introduction subsection I}
\lipsum[1-10]
\subsection{A introduction subsection II}
\lipsum[11-20]
\section{Other Section}
\subsection{A other subsection I}
\subsection{A other subsection II}
\lipsum[21-28]
\subsection{A other subsection II}
\lipsum[29-36]
\section{New Section}
\subsection{A New subsection I}
\subsubsection{A New subsubsection I}
\subsubsection{A New subsubsection II}
\lipsum[37-39]
\subsubsection{A New subsubsection I}
\lipsum[40-42]
\section{Final Section}
\subsection{A Final subsection I}
\lipsum[43-45]
\subsubsection{A Final subsubsection II}
\lipsum[46-48]
\end{document}
这是我使用该titletoc
包的尝试:
% toctest.tex
\listfiles
\documentclass[10pt]{ltxdoc}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage[showframe]{geometry}
\usepackage{lipsum,xcolor,multicol,hyperref,blindtext}
\usepackage{titletoc}
\setlength{\parindent}{0pt}
%\usepackage{tocloft}
%\usepackage{interfaces-tocloft}
% Config hyperref
\hypersetup{
linkcolor = blue!50,
colorlinks = true,%
}
\titlecontents{section}[15pt]{\addvspace{1em}\bfseries}%
{\contentslabel[\thecontentslabel]{15pt}}%
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%
\titlecontents{subsection}[30pt]{}%
{\contentslabel[\thecontentslabel]{15pt}}% numbered
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%
\titlecontents{subsubsection}[45pt]{}%
{\contentslabel[\thecontentslabel]{15pt}}% numbered
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]
% Table of contents
\def\rulecolor{\color{gray}}
\makeatletter
\renewcommand\tableofcontents{%
\begingroup%
\noindent{\sffamily\bfseries\Large\contentsname\quad\rulecolor\leaders\vrule height4.4pt depth-4pt\hfill}\null%
\vspace*{-10pt}
\setlength{\columnsep}{10pt}%
\begin{multicols}{2}%
\@starttoc{toc}%
\end{multicols}%
\vspace*{-10pt}
\rulecolor\hrule height4.4pt depth-4pt\relax\null%
\endgroup
}
\makeatother
\begin{document}
\tableofcontents
\section{Introduction}
\subsection{A introduction subsection I}
\lipsum[1-10]
\subsection{A introduction subsection II}
\lipsum[11-20]
\section{Other Section}
\subsection{A other subsection I}
\subsection{A other subsection II}
\lipsum[21-28]
\subsection{A other subsection II}
\lipsum[29-36]
\section{New Section}
\subsection{A New subsection I}
\subsubsection{A New subsubsection I}
\subsubsection{A New subsubsection II}
\lipsum[37-39]
\subsubsection{A New subsubsection I}
\lipsum[40-42]
\section{Final Section}
\subsection{A Final subsection I}
\lipsum[43-45]
\subsubsection{A Final subsubsection II}
\lipsum[46-48]
\end{document}
我找不到合适的措施来让它看起来合适(因此我没有添加numberless
部分)。想法是这样的:
1 Section ......................
1.1 Subsection I .............
1.1.1 Subsubsection I ....
1.1.2 Subsubsection II ...
1.1.3 Subsubsection III ..
我如何使用来实现这一点titletoc
?
问候
答案1
这是你想要的吗?
为了实现这一点,只需要对 s 的代码进行以下微小的调整subsubsection
:
\titlecontents{subsubsection}[45pt]{}%
{\hspace{1.00em}\contentslabel[\thecontentslabel]{25pt}}% numbered
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]
为了完整起见,这里是完整的代码:
% toctest.tex
\listfiles
\documentclass[10pt]{ltxdoc}
\usepackage[sf,bf,compact,medium,pagestyles]{titlesec}
\usepackage[showframe]{geometry}
\usepackage{lipsum,xcolor,multicol,hyperref,blindtext}
\usepackage{titletoc}
\setlength{\parindent}{0pt}
%\usepackage{tocloft}
%\usepackage{interfaces-tocloft}
% Config hyperref
\hypersetup{
linkcolor = blue!50,
colorlinks = true,%
}
\titlecontents{section}[15pt]{\addvspace{1em}\bfseries}%
{\contentslabel[\thecontentslabel]{15pt}}%
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%
\titlecontents{subsection}[30pt]{}%
{\contentslabel[\thecontentslabel]{15pt}}% numbered
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]%
\titlecontents{subsubsection}[45pt]{}%
{\hspace{1.00em}\contentslabel[\thecontentslabel]{25pt}}% numbered
{}% numberless
{\hspace{0.25em}\titlerule*[6pt]{.}\contentspage}[\smallskip]
% Table of contents
\def\rulecolor{\color{gray}}
\makeatletter
\renewcommand\tableofcontents{%
\begingroup%
\noindent{\sffamily\bfseries\Large\contentsname\quad\rulecolor\leaders\vrule height4.4pt depth-4pt\hfill}\null%
\vspace*{-10pt}
\setlength{\columnsep}{10pt}%
\begin{multicols}{2}%
\@starttoc{toc}%
\end{multicols}%
\vspace*{-10pt}
\rulecolor\hrule height4.4pt depth-4pt\relax\null%
\endgroup
}
\makeatother
\begin{document}
\tableofcontents
\section{Introduction}
\subsection{A introduction subsection I}
\lipsum[1-10]
\subsection{A introduction subsection II}
\lipsum[11-20]
\section{Other Section}
\subsection{A other subsection I}
\subsection{A other subsection II}
\lipsum[21-28]
\subsection{A other subsection II}
\lipsum[29-36]
\section{New Section}
\subsection{A New subsection I}
\subsubsection{A New subsubsection I}
\subsubsection{A New subsubsection II}
\lipsum[37-39]
\subsubsection{A New subsubsection I}
\lipsum[40-42]
\section{Final Section}
\subsection{A Final subsection I}
\lipsum[43-45]
\subsubsection{A Final subsubsection II}
\lipsum[46-48]
\end{document}