12.07.2015 Views

The memoir class - The UK TeX Archive

The memoir class - The UK TeX Archive

The memoir class - The UK TeX Archive

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CONTENTSFirst we create some macros to store information within the .aux file, and retrieve itagain.\makeatletter\newcommand\mem@auxrestore[2]{\csgdef{stored@value@#1}{#2}}\newcommand\memstorevalue[2]{%\@bsphack%\immediate\write\@mainaux{\string\mem@auxrestore{#1}{#2}}%\@esphack}\newcommand\RetrieveStoredLength[1]{%\ifcsdef{stored@value@#1}{\csuse{stored@value@#1}}{0pt}}%\makeatletterHere \RetrieveStoredLength can be used in most \setlength cases, at least when thecalc package is loaded. <strong>The</strong> argument will be the name of the variable one asked to bestored. If no corresponding value has been found for a given name, 0 pt is returned.Next we need to prepare the hooks. In this case we will show how to take care of\chapter, \section and \subsection. \chapter is relatively easy: 1\newlength\tmplen % scratch length\newlength\widestchapter % guess, they are zero by default\renewcommand\chapternumberlinehook[1]{%\settowidth\tmplen{\hbox{\cftchapterfont#1}}%\ifdimgreater\tmplen\widestchapter{%\global\widestchapter=\tmplen}{}}We use an alternative syntax to make the \widestchapter global.Handling \section and \subsection is slightly more tricky, as they both usenumberline. Instead we rely on the local value of the magic macro \cftwhatismyname.\newlength\widestsection\newlength\widestsubsection\renewcommand\numberlinehook[1]{%% use a loop handler to loop over a list of possible% types. \forcsvlist comes from etoolbox\forcsvlist{\ToCHookListHandler{#1}}{section,subsection,subsubsection,%paragraph,subparagraph,figure,table}}% the actual handler.\newcommand\ToCHookListHandler[2]{%\edef\tmpstr{#2}%\ifdefstrequal{\cftwhatismyname}{\tmpstr}{%\settowidth\tmplen{\hbox{\csuse{cft\cftwhatismyname font}#1}}%\ifcslength{widest#2}{% is this length defined?\ifdimgreater\tmplen{\csuse{widest#2}}{%\global\csuse{widest#2}=\tmplen}{}}{}}{}}1 In some cases you may want to use {\@chapapp@head\@cftbsnum #1\@cftasnum}404

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!