在我的支持信息中chapter
,我将其subsections
定义为
\renewcommand{\thesubsection}{\thechapter-\Roman{section}.\arabic{subsection}}
这是我的教授要求我的格式。
一旦我进入第 3 节(因为罗马数字),这会使我的子节编号变得非常宽。这只是toc
我使用titletoc
包生成的内部第 2 节中的一个问题。按照答案这里使用:
\makeatletter
\renewcommand{\l@subsection}{\@dottedtocline{2}{4.0em}{3.9em}}
\makeatother
我按照相同的方法改变了我的中section number
和 之间的间距,但发现它改变了我的主要和内部的和之间的间距。title
toc
section number
subsection title
toc
toc
我只希望它能将我章节中第二个的间距改得更小一些。
我使用了之前向我展示的其他技巧(例如将命令添加到toc
with中protect
),addtocontents
但没有成功。
这是我的 MWE:
\documentclass{memoir}
\setlength{\parskip}{12pt plus2pt}
\def\baselinestretch{1.6}
\linespread{1.3}
\usepackage{titletoc}
\usepackage{lipsum}
\setpnumwidth{2.5em}
\setrmarg{3.5em}
\makeatletter
\renewcommand{\l@subsection}{\@dottedtocline{2}{4.0em}{3.9em}}
\makeatother
\begin{document}
\addtocontents{toc}{\protect\setlength{\parskip}{0pt}\protect\OnehalfSpacing}
\frontmatter
\tableofcontents
\setsecnumdepth{subsection}
\maxsecnumdepth{subsection}
\settocdepth{subsection}
\mainmatter
\DoubleSpacing
\chapter{Chap1}
\section{Chap1Sec1}
\section{Chap1Sec2}
\chapter{Chap2}
\section{Chap2Sec1}
\section{Chap2Sec2}
\subsection{Chap2Sec2Subsec1}
\SingleSpacing
\chapter{Chap3}
\settocdepth{section}
\renewcommand{\thesection}{\thechapter-\Roman{section}}
\renewcommand{\thesubsection}{\thechapter-\Roman{section}.\arabic{subsection}}
\renewcommand{\thepage}{S-\arabic{page}}
\section{Chap3Sec1}
\clearpage
\section{Chap3Sec2}
\bigskip
\startcontents
\printcontents{}{2}{\addtocontents{ptc}{\setcounter{tocdepth}{2}}}
\lipsum[1-2]
\subsection{Chap3Sec2Subsec1}\clearpage
\subsection{Chap3Sec2Subsec2}\clearpage
\subsection{Chap3Sec2Subsec3}\lipsum[1]
\subsection{Chap3Sec2Subsec4}
\stopcontents
\section{Chap3Sec3}\clearpage
\section{Chap3Sec4}\clearpage
\section{Chap3Sec5}\clearpage
\section{Chap3Sec6}\clearpage
\renewcommand{\thepage}{A-\arabic{page}}
\setcounter{page}{9}
\chapter{Chap4}
\settocdepth{subsection}
\section{Chap4Sec1}\clearpage
\section{Chap4Sec2}\clearpage
\subsection{Chap4Sec2Subsec1}
\end{document}
答案1
我已将重新定义插入到\l@subsection
需要的位置和组内。这使重新定义成为本地定义,在关闭组后恢复到之前的状态:
%...
\section{Chap3Sec2}
\bigskip
\startcontents
\printcontents{}{2}{\addtocontents{ptc}{\setcounter{tocdepth}{2}}}
\lipsum[1-2]
\makeatletter
\addtocontents{toc}{%
\protect\begingroup%
\protect\makeatletter
\protect\def\protect\l@subsection{\protect\@dottedtocline{2}{4.0em}{3.9em}}
\protect\makeatother
}
\makeatother
\subsection{Chap3Sec2Subsec1}\clearpage
\subsection{Chap3Sec2Subsec2}\clearpage
\subsection{Chap3Sec2Subsec3}\lipsum[1]
\subsection{Chap3Sec2Subsec4}
\addtocontents{toc}{%
\protect\endgroup%
}
%...
您仍然拥有主目录中的原始小节间距:
然而,支持章节中的迷你目录间距要宽得多:
以下是原始的(现已更新)MWE:
\documentclass{memoir}% http://ctan.org/pkg/memoir
\setlength{\parskip}{12pt plus2pt}
\def\baselinestretch{1.6}\linespread{1.3}
\usepackage{titletoc}% http://ctan.org/pkg/titletoc
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\setpnumwidth{2.5em}
\setrmarg{3.5em}
\begin{document}
\addtocontents{toc}{\protect\setlength{\parskip}{0pt}\protect\OnehalfSpacing}
\frontmatter
\tableofcontents
\setsecnumdepth{subsection}
\maxsecnumdepth{subsection}
\settocdepth{subsection}
\mainmatter
\DoubleSpacing
\chapter{Chap1}
\section{Chap1Sec1}
\section{Chap1Sec2}
\chapter{Chap2}
\section{Chap2Sec1}
\section{Chap2Sec2}
\subsection{Chap2Sec2Subsec1}
\SingleSpacing
\chapter{Chap3}
\settocdepth{section}
\renewcommand{\thesection}{\thechapter-\Roman{section}}
\renewcommand{\thesubsection}{\thechapter-\Roman{section}.\arabic{subsection}}
\renewcommand{\thepage}{S-\arabic{page}}
\section{Chap3Sec1}
\clearpage
\section{Chap3Sec2}
\bigskip
\startcontents
\printcontents{}{2}{\addtocontents{ptc}{\setcounter{tocdepth}{2}}}
\lipsum[1-2]
\makeatletter
\addtocontents{toc}{%
\protect\begingroup%
\protect\makeatletter
\protect\def\protect\l@subsection{\protect\@dottedtocline{2}{4.0em}{3.9em}}
\protect\makeatother
}
\makeatother
\subsection{Chap3Sec2Subsec1}\clearpage
\subsection{Chap3Sec2Subsec2}\clearpage
\subsection{Chap3Sec2Subsec3}\lipsum[1]
\subsection{Chap3Sec2Subsec4}
\addtocontents{toc}{%
\protect\endgroup%
}
\stopcontents
\section{Chap3Sec3}\clearpage
\section{Chap3Sec4}\clearpage
\section{Chap3Sec5}\clearpage
\section{Chap3Sec6}\clearpage
\renewcommand{\thepage}{A-\arabic{page}}
\setcounter{page}{9}
\chapter{Chap4}
\settocdepth{subsection}
\section{Chap4Sec1}\clearpage
\section{Chap4Sec2}\clearpage
\subsection{Chap4Sec2Subsec1}
\end{document}