Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{memoir}
- \usepackage{xpatch}
- \renewcommand{\mempreaddchaptertotochook}{%
- \addtocontents{toc}{%
- \protect\settowidth{\protect\cftchapternumwidth}{\cftchapterfont \thechapter.\space}%
- \protect\setlength{\protect\cftsectionindent}{\protect\cftchapternumwidth}%
- }%
- }
- \makeatletter
- \xpatchcmd{\@m@mschapter}% <cmd>
- {\@schapter}% <search>
- {\addtocontents{toc}{\protect\settowidth{\protect\cftsectionindent}{\protect\cftchapterfont \thechapter.\space}}%
- \@schapter}% <replace>
- {}{}% <success><failure>
- \patchcmd{\M@sect}% <cmd>
- {\addcontentsline}% <search>
- {\addtocontents{toc}{%
- \protect\settowidth{\csname cft#1numwidth\endcsname}{\csname cft#1font\endcsname\csname the#1\endcsname.\space}%
- \protect\setlength{\csname cftsub#1indent\endcsname}{\protect\dimexpr\csname cft#1numwidth\endcsname+\csname cft#1indent\endcsname}%
- }%
- \addcontentsline}% <replace>
- {}{}% <success><failure>
- \makeatother
- %% delete boxes
- \renewcommand\numberlinebox[2]{#2} % for sections
- \renewcommand\chapternumberlinebox[2]{#2} % for chapters
- %% set dot and space
- \renewcommand\cftchapteraftersnum{.\space}
- \renewcommand\cftsectionaftersnum{.\space}
- \renewcommand\cftsubsectionaftersnum{.\space}
- \renewcommand\cftsubsubsectionaftersnum{.\space}
- %%enumeration levels in the ToC and text
- \settocdepth{subsection}
- \setsecnumdepth{subsubsection}
- \setrmarg{2.55em plus1fil} %hyphenation is forbidden
- \renewcommand{\cftchapterfont}{}
- \begin{document}
- \tableofcontents
- \chapter*{Introduction}
- \addcontentsline{toc}{chapter}{Introduction}
- \section{First section}
- \chapter{First chapter}
- \section{First section long long long long long long long long long long long long title}
- \subsection{First subsection long long long long long long long long long long long long title}
- \setcounter{chapter}{11}
- \chapter{Another chapter long long long long long long long long long long long long title}
- \section{First section long long long long long long long long long long long long title}
- \subsection{First subsection long long long long long long long long long long long long title}
- \subsection*{Short conclusion with long long long long long long long long long long long long title}
- \addcontentsline{toc}{subsection}{Short conclusion}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment