
В моей вспомогательной информации chapter
я определил ее subsections
как
\renewcommand{\thesubsection}{\thechapter-\Roman{section}.\arabic{subsection}}
Именно такой формат попросил меня мой профессор.
Это делает мою нумерацию подразделов довольно широкой, как только я дохожу до 3-го раздела (из-за римских цифр). Это проблема только во внутреннем 2-м, toc
который я генерирую с помощью titletoc
пакета. После ответаздесьс использованием:
\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}