summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/memoir
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2010-02-17 01:03:49 +0000
committerKarl Berry <karl@freefriends.org>2010-02-17 01:03:49 +0000
commiteb531211a9347605eb2e38bd483e0698f2f3c30b (patch)
treec29125d024d27dd4e788de455c1221641b42cc9a /Master/texmf-dist/source/latex/memoir
parent80f8b8d7c5431f27d221b670d2fbb51f37cdbdff (diff)
memoir v1.618033988 (16feb10)
git-svn-id: svn://tug.org/texlive/trunk@17061 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/memoir')
-rw-r--r--Master/texmf-dist/source/latex/memoir/memoir.dtx1383
1 files changed, 1259 insertions, 124 deletions
diff --git a/Master/texmf-dist/source/latex/memoir/memoir.dtx b/Master/texmf-dist/source/latex/memoir/memoir.dtx
index 0be3c499d98..7e0ea5e2a69 100644
--- a/Master/texmf-dist/source/latex/memoir/memoir.dtx
+++ b/Master/texmf-dist/source/latex/memoir/memoir.dtx
@@ -18,12 +18,12 @@
% This work consists of the files listed in the README file.
%
% \fi
-% \CheckSum{28463}
+% \CheckSum{29391}
%
% \changes{v0.1}{2001/05/20}{First public alpha release}
% \changes{v0.2}{2001/06/03}{First beta release}
% \changes{v0.3}{2001/07/09}{Bug fixing}
-% \changes{v0.31}{2001/07/09}{Bug fixing}
+% \changes{v0.31}{2001/07/09}{Bug fixing}
% \changes{v0.32}{2001/08/03}{Fix for old versions of amsmath package}
% \changes{v0.33}{2001/08/03}{Added controllable chapter/LoF spacing}
% \changes{v0.33}{2001/08/03}{Fixed bug in \cs{appendixpage}}
@@ -87,6 +87,11 @@
% \changes{v1.61803398}{2009/09/10}{fixed bug with upquote}
% \changes{v1.61803398b}{2009/09/21}{fixed typo}
% \changes{v1.61803398c}{2009/11/13}{fixed typo}
+% \changes{v1.61803398d}{2009/11/13}{fixed infelicity with \cs{@starttoc}}
+% \changes{v1.61803398d}{2009/12/01}{fixed bug in ifxetex, ifpdf,...}
+% \changes{v1.61803398d}{2009/12/18}{made \cs{subcaptionref} robust}
+% \changes{v1.61803398d}{2010/xx/xx}{several changes}
+% \changes{v1.618033988}{2010/02/16}{bumped version to v1.618033988}
%
% \def\dtxfile{memoir.dtx}
%
@@ -122,6 +127,8 @@
% \def\fileversion{v1.61803398} \def\filedate{2009/09/10}
% \def\fileversion{v1.61803398b} \def\filedate{2009/09/21}
% \def\fileversion{v1.61803398c} \def\filedate{2009/11/17}
+% \def\fileversion{v1.61803398d} \def\filedate{2009/11/23}
+% \def\fileversion{v1.618033988} \def\filedate{2010/02/16}
% \title{The LaTeX \Lpack{memoir} class for configurable book
% typesetting: Source code\thanks{This
% file (\texttt{\dtxfile}) has version number \fileversion, last revised
@@ -345,7 +352,7 @@
% Announce the name, option files and version for LaTeX2e files:
% \begin{macrocode}
%<class>\ProvidesClass{memoir}%
-%<class> [2009/11/17 v1.61803398c configurable book, report, article document class]
+%<class> [2010/02/16 v1.618033988 configurable book, report, article document class]
%<9pt>\ProvidesFile{mem9.clo}%
%<9pt> [2008/01/30 v0.4 memoir class 9pt size option]
%<10pt>\ProvidesFile{mem10.clo}%
@@ -515,17 +522,19 @@
% and \meta{name2} must both be either macro names (including the backslash)
% or must both not be macro names. That is, you cannot do
% \verb?\nametest{\cs}{cs}?.
+% \changes{v1.61803398d}{2010/02/13}{added some \% because the macro
+% was leaking spaces}
% \begin{macrocode}
\newif\ifsamename
\newcommand{\nametest}[2]{%
- \samenamefalse
- \begingroup
- \def\@memtempa{#1} \def\@memtempb{#2}
- \ifx \@memtempa\@memtempb
- \endgroup
- \samenametrue
- \else
- \endgroup
+ \samenamefalse%
+ \begingroup%
+ \def\@memtempa{#1}\def\@memtempb{#2}%
+ \ifx \@memtempa\@memtempb%
+ \endgroup%
+ \samenametrue%
+ \else%
+ \endgroup%
\fi}
% \end{macrocode}
@@ -1051,6 +1060,10 @@
% \changes{v1.618}{2005/09/03}{Prohibit loading the ifpdf package (mempatch v3.9)}
% \changes{v1.618033}{2008/06/02}{Further improved pdf checking}
% \changes{v1.6180339}{2008/07/23}{Use ifpdf package if available}
+% \changes{v1.61803398d}{2009/12/01}{if \cs{ifpdf} is already
+% defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
+% then using \cs{newif}\cs{ifpdf} will cause TeX to eat up a lot of
+% code. We fix this using a hint by Will Robertson.}
% \begin{macrocode}
\newif\ifm@mifpdf
\m@mifpdffalse
@@ -1059,7 +1072,7 @@
Package `ifpdf' is not installed.\MessageBreak
The package is being emulated}%
\m@mifpdftrue
-\newif\ifpdf
+\expandafter\newif\csname ifpdf\endcsname
\pdffalse
\ifx\pdfoutput\undefined
\else
@@ -1130,6 +1143,10 @@
% Checks if XeTeX is being used.
% \changes{v1.61803}{2008/01/30}{Added checks for XeTeX (mempatch v4.9)}
% \changes{v1.6180339}{2008/07/23}{Use ifxetex package if available}
+% \changes{v1.61803398d}{2009/12/01}{if \cs{ifxetex} is already
+% defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
+% then using \cs{newif}\cs{ifxetex} will cause TeX to eat up a lot of
+% code. We fix this using a hint by Will Robertson.}
% \begin{macrocode}
\newif\ifm@mifxetex
\m@mifxetexfalse
@@ -1137,14 +1154,16 @@
\ClassWarningNoLine{memoir}{%
The `ifxetex' package is not installed.\MessageBreak
The package is being emulated}%
-\newif\ifxetex
+\expandafter\newif\csname ifxetex\endcsname
\@ifundefined{XeTeXrevision}{\xetexfalse}{\xetextrue}
+\m@mifxetextrue%
% \end{macrocode}
% Check for XeTeX from the \Lpack{ifxetex} package.
% \begin{macrocode}
%%\EmulatedPackage{ifxetex}[2008/07/23]
}
-\ifm@mifxetex
+\ifm@mifxetex%
+% ifxetex package not found, emulate \RequireXeTeX
\def\RequireXeTeX{%
\ifxetex\else
\@memerror{XeTeX is required to process this document}%
@@ -1169,6 +1188,10 @@
% \changes{v1.6180339}{2008/07/23}{Use an ifluatex package if available}
% \changes{v1.6180339c}{2008/12/31}{It seems that Heiko Oberdiek has created an
% ifluatex package.}
+% \changes{v1.61803398d}{2009/12/01}{if \cs{ifluatex} is already
+% defined, e.g. using \cs{RequirePackage} before \cs{documentclass},
+% then using \cs{newif}\cs{ifluatex} will cause TeX to eat up a lot of
+% code. We fix this using a hint by Will Robertson.}
% \begin{macrocode}
\newif\ifm@mifluatex
\m@mifluatexfalse
@@ -1177,7 +1200,7 @@
The `ifluatex' package is not installed.\MessageBreak
The package is being emulated}%
\m@mifluatextrue
-\newif\ifluatex
+\expandafter\newif\csname ifluatex\endcsname
\luatexfalse
\ifx\luatexversion\@undefined
\else
@@ -4770,6 +4793,7 @@
% \changes{v1.0a}{2002/01/25}{Added column info to \cs{typeoutlayout}}
% \changes{v1.61803}{2008/01/30}{Added sidecap and sidebar data to \cs{typeoutlayout}
% (mempatch v4.6)}
+% \changes{v1.61803398d}{2010/02/04}{Added information about side feet}
% \begin{macrocode}
\newcommand*{\typeoutlayout}{%
\typeout{}
@@ -4802,6 +4826,10 @@
\the\sidebarvsep\space and \the\sidebartopsep}
\typeout{Sidebarheight:
\the\dimen\sideins}
+ \typeout{Sidefoothsep and sidefootwidth:
+ \the\sidefoothsep\space and \the\sidefootwidth}
+ \typeout{Sidefootvsep and sidefootheight:
+ \the\sidefootvsep\space and \the\sidefootheight}
\typeout{******************************************************}
\typeout{}}
@@ -5249,6 +5277,55 @@
%
% In the following \meta{style} is the name of a pagestyle being defined
% (e.g., \verb?ruled?).
+%
+% \changes{v1.61803398d}{2010/02/09}{Added the following three macros}
+% \begin{macro}{\mem@set@ps@xtra@info}
+% \begin{macro}{\mem@ps@find@real}
+% \begin{macro}{\mem@ps@safe@change}
+% The class supports an aliasing feature, where a page style name can
+% actually call the code from another. Quite handy. But There might be
+% problems if a use try to modify an alias page style. We care for
+% this by storing some information about each page style, and throwing
+% an error if the user atempts to alter a page style marked as an
+% alias.
+%
+% \verb?\mem@set@ps@xtra@info? store two things: the name of the style
+% we are an alias for (if we are not an alias it will be blank) and an
+% indicator whether we are an alias (00 if we are and 01 if we are not).
+% \begin{macrocode}
+\newcommand\mem@set@ps@xtra@info[3]{%
+ \@namedef{ps@#1@aliasfor}{#2}%
+ \@namedef{ps@#1@isalias}{#3}}
+
+% \end{macrocode}
+% \verb?\mem@ps@find@real? starts at a given page style, if it is
+% marked as an alias, it will recursively go down the chain of aliases
+% and save the name of the first real page style in \verb?\@tempa?.
+% \begin{macrocode}
+\newcommand\mem@ps@find@real[1]{%
+ \if\@nameuse{ps@#1@isalias}\relax
+ \mem@ps@find@real{\@nameuse{ps@#1@aliasfor}}
+ \else\def\@tempa{#1}\fi}
+
+% \end{macrocode}
+% \verb?\mem@ps@safe@change? takes a page style name, checks to see if
+% it is defined, if it is, it checks to see if it is safe to change it.
+% \begin{macrocode}
+\newcommand\mem@ps@safe@change[1]{%
+ \@ifundefined{ps@#1}{%
+ \@memerror{Undefined pagestyle '#1', so I cannot change it}{}}{}
+ \if\@nameuse{ps@#1@isalias}\relax \mem@ps@find@real{#1}
+ \@memerror{The pagestyle '#1' is marked as an alias page style.^^J
+ Modifying an alias page style may give unexpected results.^^J The
+ alias chain resolves to the real page style '\@tempa', so try
+ issuing^^J \string\copypagestyle{#1}{\@tempa}^^J before before
+ modifying '#1'}{} \fi }
+
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
% \begin{macro}{\makeevenhead}
% The command
@@ -5257,8 +5334,10 @@
% pagestyle \meta{style} are defined as the other three arguments, respectiveley.
% Internally it defines the commands \cs{styleeheadl}, \cs{styleeheadc} and
% \cs{styleeheadr} to be \meta{left}, \meta{center} and \meta{right} respectively.
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeevenhead}[4]{%
+ \mem@ps@safe@change{#1}
\@namedef{#1eheadl}{#2}
\@namedef{#1eheadc}{#3}
\@namedef{#1eheadr}{#4}
@@ -5271,18 +5350,22 @@
% \begin{macro}{\makeoddfoot}
% These three macros are similar to \cs{makeevenhead} except that they are
% for the oddhead, evenfoot and oddfoot.
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeoddhead}[4]{%
+ \mem@ps@safe@change{#1}
\@namedef{#1oheadl}{#2}
\@namedef{#1oheadc}{#3}
\@namedef{#1oheadr}{#4}
}
\newcommand{\makeevenfoot}[4]{%
+ \mem@ps@safe@change{#1}
\@namedef{#1efootl}{#2}
\@namedef{#1efootc}{#3}
\@namedef{#1efootr}{#4}
}
\newcommand{\makeoddfoot}[4]{%
+ \mem@ps@safe@change{#1}
\@namedef{#1ofootl}{#2}
\@namedef{#1ofootc}{#3}
\@namedef{#1ofootr}{#4}
@@ -5313,8 +5396,10 @@
% \changes{v1.6180339c}{2009/01/13}{Added \cs{makerunningheadwidth}
% and \cs{makerunningfootwidth}}.
% \changes{v1.6180339d}{2009/02/04}{Fixed a mental bug, /daleif}
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand*{\makerunningwidth}[1]{%
+ \mem@ps@safe@change{#1}%
\def\m@mhfstyle{#1}%
\m@mopthfwidth}
\newcommand*{\m@mopthfwidth}[2][\@mpty]{%
@@ -5332,10 +5417,12 @@
\newcommand*{\makerunningheadwidth}[2]{%
% \setlength\@tempdima{#2}%
% \expandafter\edef\csname \m@mhfstyle headrunwidth\endcsname{\the\@tempdima}%
+ \mem@ps@safe@change{#1}%
\@namedef{#1headrunwidth}{#2}%
}
\newcommand*{\makerunningfootwidth}[2]{%
% \setlength\@tempdima{#2}%
+ \mem@ps@safe@change{#1}%
\@namedef{#1footrunwidth}{#2}%
% \expandafter\edef\csname \m@mhfstyle footrunwidth\endcsname{\the\@tempdima}%
}
@@ -5376,11 +5463,14 @@
% Similarly
% \cs{makefootrule}\marg{style}\marg{width}\marg{height}\marg{skip}
% specifies the width, height and skip for the footrule.
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeheadrule}[3]{%
+ \mem@ps@safe@change{#1}%
\@namedef{#1headrule}{%
\hrule\@width #2\@height #3 \vskip-#3}}
\newcommand{\makefootrule}[4]{%
+ \mem@ps@safe@change{#1}%
\@namedef{#1footrule}{%
\vskip-#4\vskip-#3
\hrule\@width #2\@height #3 \vskip #4}}
@@ -5399,8 +5489,10 @@
% for the pagestyle \meta{style}. Each of the \meta{...pos} arguments may be
% either \verb?flushleft?, \verb?center? or \verb?flushright?, with the obvious meanings.
% An empty argument (or an unrecognised one) is equivalent to \verb?center?.
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand{\makeheadposition}[5]{%
+ \mem@ps@safe@change{#1}%
% \end{macrocode}
% Do the even head position first.
% \begin{macrocode}
@@ -5464,8 +5556,9 @@
% \changes{v1.0}{2001/11/15}{Added \cs{makepsmarks} and deprecated
% \cs{makepshook}}
% \changes{v1.4}{2003/12/14}{Deleted \cs{makepshook}}
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
-\newcommand{\makepsmarks}[2]{\@namedef{#1pshook}{#2}}
+\newcommand{\makepsmarks}[2]{\mem@ps@safe@change{#1}\@namedef{#1pshook}{#2}}
% \end{macrocode}
% \end{macro}
@@ -5489,9 +5582,11 @@
% default is~b.
% \changes{v1.6180339c}{2009/01/13}{Added support for
% controlling the alignment of the headers and footers}
+% \changes{v1.61803398d}{2010/02/09}{Added safe change test}
% \begin{macrocode}
\newcommand*\makeheadfootvposition[3]{%
- \@namedef{#1headvplacement}{#2}\@namedef{#1footvplacement}{#3}}
+ \mem@ps@safe@change{#1}%
+ \@namedef{#1headvplacement}{#2}\@namedef{#1footvplacement}{#3}}
% \end{macrocode}
% \end{macro}
@@ -5509,8 +5604,13 @@
% \cs{makepagestyle} (from patch 2.1)}
% \changes{v1.61803}{2008/01/30}{Removed extraneous spaces from pagestyle code
% (mempatch v4.6)}
+% \changes{v1.61803398d}{2010/02/09}{Added storing extra information
+% about page styles}
+% We also make sure to specify that this is a `real' page style, and
+% thus sets the empty alias name and the alias test to 01.
% \begin{macrocode}
\newcommand{\makepagestyle}[1]{%
+ \mem@set@ps@xtra@info{#1}{}{01}%
% \end{macrocode}
% First define the macro \cs{ps@style}, which in turn defines the macros
% \cs{@evenhead}, \cs{@oddhead}, \cs{@evenfoot} and \cs{@oddfoot}.
@@ -5642,8 +5742,12 @@
% The command \cs{aliaspagestyle}\marg{alias}\marg{original}
% defines the \meta{alias} pagestyle to be an alias for the
% \meta{original} pagestyle.
+% \changes{v1.61803398d}{2010/02/09}{Added page style storing info}
+% We remember to set the stored alias name, and sets the alias test to
+% true (00).
% \begin{macrocode}
\newcommand{\aliaspagestyle}[2]{%
+ \mem@set@ps@xtra@info{#1}{#2}{00}%
\@namedef{ps@#1}{\@nameuse{ps@#2}}}
% \end{macrocode}
@@ -5823,7 +5927,10 @@
% \cs{createplainmark}\marg{type}\marg{marks}\marg{text} creates a
% \cs{typemark} (\meta{type} is \texttt{toc}, \texttt{bib}, etc)
% with \meta{marks} (left, both, right) whose contents are \meta{text}.
-% For example \verb?\createplainmark{toc}{both}{\contentsname}?.
+% For example \verb?\createplainmark{toc}{both}{\contentsname}?. The
+% difference between plain and regular marks, is that plain marks use
+% a fixed text, whereas regular marks recieve dynamic text and thus
+% is given an argument.
% \begin{macrocode}
\newcommand*{\createplainmark}[3]{%
\nametest{#2}{left}%
@@ -5944,12 +6051,30 @@
% \cs{addtopsmarks}\marg{pagestyle}\marg{prepend}\marg{append} inserts
% \meta{prepend} and \meta{append} at the start and end of the current
% definition of \cs{pagestylepshook}.
+% \changes{v1.61803398d}{2010/02/09}{Added safe to change test}
% \begin{macrocode}
\newcommand\addtopsmarks[3]{%
+ \mem@ps@safe@change{#1}%
\expandafter\addtodef\expandafter{\csname #1pshook\endcsname}{#2}{#3}}
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\clearplainmark}
+% \begin{macro}{\clearmark}
+% For some page styles it is handy to be able to make sure that no
+% section or otherwise add data to the \cs{left-} and
+% \cs{rightmark}. The macros \cs{clearplainmark} and \cs{clearmark}
+% will take one argument specifying which mark to clear, and then
+% redefine this mark to do nothing or to gobble its given argument.
+% \begin{macrocode}
+\newcommand\clearplainmark[1]{%
+ \@namedef{#1mark}{}}
+\newcommand\clearmark[1]{%
+ \@namedef{#1mark}{\@gobble}}
+% \end{macrocode}
+%
+% \end{macro}
+% \end{macro}
%
% \begin{macro}{\ps@headings}
% The \pstyle{headings} pagestyle behaves differently for
@@ -19045,7 +19170,7 @@
% \begin{macro}{\subcaptionref}
% This is a copy of the \cs{subref} macro.
% \begin{macrocode}
-\newcommand*{\subcaptionref}{%
+\DeclareRobustCommand{\subcaptionref}{%
\@ifstar{\ssc@ref}{\sc@ref}}
% \end{macrocode}
% \end{macro}
@@ -20636,13 +20761,19 @@
% \end{macro}
%
% \begin{macro}{\mem@X}
+% \begin{macro}{\cftZbeforelisthook}
+% \begin{macro}{\cftZafterlisthook}
% \changes{v1.61803398}{2009/08/08}{introduced \cs{mem@X} to replace
% \cs{@starZ} and \cs{@plainZ}}
% In earlier version of the class, we used two macros \cs{@starZ}
% and \cs{@plainZ}, to reduce code we now only use one, the argument
% of it takes care of differentiating between the stuff that are
-% different.
+% different. Two hooks is added just before and after importing the
+% list file contents.
+% \changes{v1.61803398d}{2010/02/14}{added the before and after hooks}
% \begin{macrocode}
+ \@namedef{cft#2beforelisthook}{}%
+ \@namedef{cft#2afterlisthook}{}%
\@namedef{mem@#1}##1{%
\ensureonecol
\par
@@ -20655,12 +20786,16 @@
\fi
\fi
\parskip\cftparskip
+ \@nameuse{cft#2beforelisthook}%
\@starttoc{#2}%
+ \@nameuse{cft#2afterlisthook}%
\endgroup
\restorefromonecol}
% \end{macrocode}
%
% \end{macro}
+% \end{macro}
+% \end{macro}
%
% \begin{macro}{\@Zmaketitle}
% This macro typesets the title.
@@ -20754,14 +20889,22 @@
% changed the kernel definition to allow a file to be read multiple times
% by delaying killing the file until the end of the document.
% \changes{v1.3}{2002/11/14}{Changed \cs{@starttoc}}
+% \changes{v1.61803398d}{2009/11/23}{Removed infelicity in \cs{@starttoc}}
% \begin{macrocode}
\renewcommand{\@starttoc}[1]{%
\begingroup\makeatletter
\@input{\jobname.#1}%
\if@filesw
\AtEndDocument{%
- \expandafter\newwrite\csname tf@#1\endcsname
- \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
+% \end{macrocode}
+% If a ToC, or other ListOf, is called more than once then we have to stop
+% opening yet another, redundant, output file. The check against \cs{relax}
+% seems to meet the requirement.
+% \begin{macrocode}
+ \expandafter\ifx\csname tf@#1\endcsname\relax
+ \expandafter\newwrite\csname tf@#1\endcsname
+ \immediate\openout \csname tf@#1\endcsname \jobname.#1\relax
+ \fi
}%
\fi
\@nobreakfalse
@@ -20899,17 +21042,24 @@
% \end{macro}
%
% \begin{macro}{\numberline}
+% \begin{macro}{\numberlinehook}
% The purpose of the \cs{numberline}\marg{secnum} command is to typeset
% \meta{secnum} left justified in a box of width \cs{@tempdima}. I redefine
% it to add three additional parameters, namely \cs{@cftbsnum},
% \cs{@cftasnum} and \cs{@cftasnumb}
% (see \file{ltsect.dtx} for the original
-% definition).
-% \begin{macrocode}
-\renewcommand*{\numberline}[1]{%
+% definition).
+% \changes{v1.61803398d}{2010/02/13}{added \cs{numberlinehook}}
+% We also add a hook, that initially does nothing, but
+% might be redefined to record say withs of \meta{secnum}s.
+% \begin{macrocode}
+\newcommand*\numberlinehook[1]{}
+\renewcommand*{\numberline}[1]{%
+ \numberlinehook{#1}%
\hb@xt@\@tempdima{\@cftn@me\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\@cftbsnum}
% \begin{macro}{\@cftasnum}
@@ -20981,10 +21131,16 @@
% \end{macrocode}
% Start a group to keep paragraphing changes local. Set the \cs{leftskip}
% to the entry's indentation.
+% \begin{macro}{\cftwhatismyname}
+% \changes{v1.61803398d}{2010/02/13}{added \cs{cftwhatismyname}}
+% \cs{cftwhatismyname} locally stores the type of toc entry. Useful
+% for hooks into general macros like \verb?\numberline?.
% \begin{macrocode}
{%\leftskip \@nameuse{cft#2indent}\relax
+ \newcommand*\cftwhatismyname{#2}%
\memRTLleftskip \@nameuse{cft#2indent}\relax
% \end{macrocode}
+% \end{macro}
% Set the \cs{rightskip} to \cs{@tocrmarg} to leave room for the page number.
% \begin{macrocode}
%%% \rightskip \@tocrmarg
@@ -21121,12 +21277,19 @@
% \end{macro}
%
% \begin{macro}{\cftXformatpnum}
+% \begin{macro}{\cftXformatpnumhook}
% \begin{macro}{\cftXfillnum}
-% Typeset the leader and page number.
+% Typeset the leader and page number. We add a hook into the formating
+% of the page number. This might later be used to record the widths of
+% the numbers used. It will be given the page number as its
+% argument. Does nothing by default.
% \changes{v1.61803}{2008/01/30}{Added \cs{cftXformatpnum} (Dan Leucking
% mempatch v4.9)}
+% \changes{v1.61803398d}{2010/02/13}{added hook into page number formatter}
% \begin{macrocode}
+ \@namedef{cft#2formatpnumhook}##1{}
\@namedef{cft#2formatpnum}##1{%
+ \@nameuse{cft#2formatpnumhook}{##1}%
\hb@xt@\@pnumwidth{\hfil\@nameuse{cft#2pagefont}##1}}
\@namedef{cft#2fillnum}##1{%
{\@nameuse{cft#2leader}}\nobreak
@@ -21137,6 +21300,7 @@
% \end{macrocode}
% \end{macro}
% \end{macro}
+% \end{macro}
% This ends the definition of \cs{newlistentry}.
% \begin{macrocode}
} % end \newlistentry
@@ -21169,12 +21333,14 @@
% \begin{macro}{\cftbookbreak}
% \begin{macro}{\l@book}
% \begin{macro}{\booknumberline}
+% \begin{macro}{\booknumberlinehook}
% Now for the ToC entry.
% \changes{v1.61803}{2008/01/30}{Added \cs{l@book} and supports (mempatch v4.4)}
% \changes{v1.6180339}{2008/07/23}{Deleted \cs{space} from \cs{booknumberline}
% and \cs{partnumberline}
% (per Lars Henrik Gam Madsen mempatch v5.1)}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{l@book}}
+% \changes{v1.61803398d}{2010/02/13}{added hook into the book numberline}
% \begin{macrocode}
\newcommand*{\cftbookbreak}{\addpenalty{-\@highpenalty}%
\addvspace{\cftbeforebookskip}}
@@ -21205,7 +21371,9 @@
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
+\newcommand*\booknumberlinehook[1]{}
\newcommand{\booknumberline}[1]{%
+ \booknumberlinehook{#1}%
\hb@xt@\@tempdima{%
\cftbookname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}%%\space}
@@ -21213,6 +21381,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\cftbeforebookskip}
% \begin{macro}{\cftbookindent}
@@ -21227,6 +21396,8 @@
% \begin{macro}{\cftbookafterpnum}
% \begin{macro}{\cftbookfillnum}
% \begin{macro}{\cftbookformatpnum}
+% \begin{macro}{\cftbookformatpnumhook}
+% \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftbookformatpnum}}
% \begin{macrocode}
\newlength{\cftbeforebookskip}
\setlength{\cftbeforebookskip}{2.25em \@plus\p@}
@@ -21248,7 +21419,9 @@
%%%% {\hb@xt@\@pnumwidth{\hss {\cftbookpagefont #1}}}%
\cftbookformatpnum{#1}%
\cftbookafterpnum\par}
+\newcommand{\cftbookformatpnumhook}[1]{}
\newcommand{\cftbookformatpnum}[1]{%
+ \cftbookformatpnumhook{#1}%
\hb@xt@\@pnumwidth{\hss {\cftbookpagefont #1}}}
% \end{macrocode}
@@ -21265,6 +21438,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
%
%
@@ -21330,18 +21504,23 @@
% \end{macro}
%
% \begin{macro}{\partnumberline}
+% \begin{macro}{\partnumberlinehook}
% \cs{partnumberline} is a special version of \cs{numberline} output by \cs{part}.
% Its default definition is identical to \cs{numberline}.
% \changes{v1.3}{2002/11/14}{Added \cs{partnumberline}}
% \changes{v1.61803}{2008/01/30}{Added a space after the number in
% \cs{partnumberline} (mempatch v4.4)}
+% \changes{v1.61803398d}{2010/02/13}{added hook into part numberline}
% \begin{macrocode}
+\newcommand*\partnumberlinehook[1]{}
\newcommand{\partnumberline}[1]{%
+ \partnumberlinehook{#1}%
\hb@xt@\@tempdima{%
\cftpartname\@cftbsnum #1\@cftasnum\hfil}\@cftasnumb}%%\space}
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\cftbeforepartskip}
% \begin{macro}{\cftpartnumwidth}
@@ -21355,12 +21534,14 @@
% \begin{macro}{\cftpartafterpnum}
% \begin{macro}{\cftpartindent}
% \begin{macro}{\cftpartformatpnum}
+% \begin{macro}{\cftpartformatpnumhook}
% \begin{macro}{\cftpartfillnum}
% These are the user commands to control the typesetting of Part entries.
% They are initialised to give the standard appearance.
% \changes{v1.3}{2002/10/10}{Changed \cs{cftpartnumwidth} to cater for
% use of \cs{numberline} in the ToC}
% \changes{v1.61803}{2008/01/30}{Added \cs{cftpartformatpnum} (mempatch v4.9)}
+% \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftpartformatpnum}}
% \begin{macrocode}
\newlength{\cftbeforepartskip}
\setlength{\cftbeforepartskip}{2.25em \@plus\p@}
@@ -21377,7 +21558,9 @@
\newcommand{\cftpartdotsep}{\cftnodots}
\newcommand{\cftpartpagefont}{\large\bfseries}
\newcommand{\cftpartafterpnum}{}
+ \newcommand{\cftpartformatpnumhook}[1]{}
\newcommand*{\cftpartformatpnum}[1]{%
+ \cftpartformatpnumhook{#1}%
\hb@xt@\@pnumwidth{\hss {\cftpartpagefont #1}}}
\newcommand{\cftpartfillnum}[1]{%
{\cftpartleader}%
@@ -21398,6 +21581,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
%
% \begin{macro}{\cftchaptername}
@@ -21497,18 +21681,23 @@
% \end{macro}
%
% \begin{macro}{\chapternumberline}
+% \begin{macro}{\chapternumberlinehook}
% \cs{chapternumberline} is a special version of \cs{numberline} output by
% \cs{chapter}.
% It's default definition is identical to \cs{numberline}.
% \changes{v1.3}{2002/11/14}{Added \cs{chapternumberline}}
% \changes{v1.618}{2005/09/03}{Added \cs{@chapapp@head} to \cs{chapternumberline} (mempatch v3.12)}
+% \changes{v1.61803398d}{2010/02/13}{added hook into chapter numberline}
% \begin{macrocode}
+\newcommand*\chapternumberlinehook[1]{}
\newcommand{\chapternumberline}[1]{%
+ \chapternumberlinehook{#1}%
\hb@xt@\@tempdima{\@chapapp@head\@cftbsnum #1\@cftasnum\hfil}%
\@cftasnumb}
% \end{macrocode}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\cftbeforechapterskip}
% \begin{macro}{\cftchapterindent}
@@ -21522,10 +21711,12 @@
% \begin{macro}{\cftchapterpagefont}
% \begin{macro}{\cftchapterafterpnum}
% \begin{macro}{\cftchapterformatpnum}
+% \begin{macro}{\cftchapterformatpnumhook}
% \begin{macro}{\cftchapterfillnum}
% These are the user commands to control the typesetting of Chapter entries.
% They are initialised to give the standard appearance.
% \changes{v1.61803}{2008/01/30}{Added \cs{cftchapterformatpnum} (mempatch v4.9)}
+% \changes{v1.61803398d}{2010/02/13}{added hook into \cs{cftchapterformatpnum}}
% \begin{macrocode}
\newlength{\cftbeforechapterskip}
\setlength{\cftbeforechapterskip}{1.0em \@plus\p@}
@@ -21542,7 +21733,9 @@
\newcommand{\cftchapterdotsep}{\cftnodots}
\newcommand{\cftchapterpagefont}{\bfseries}
\newcommand{\cftchapterafterpnum}{}
+ \newcommand{\cftchapterformatpnumhook}[1]{}
\newcommand*{\cftchapterformatpnum}[1]{%
+ \cftchapterformatpnumhook{#1}%
\hb@xt@\@pnumwidth{\hfil\cftchapterpagefont #1}}
\newcommand*{\cftchapterfillnum}[1]{%
{\cftchapterleader}\nobreak
@@ -21562,6 +21755,7 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
%
% \begin{macro}{\cftchapterbreak}
% Another parameter for \cs{l@chapter}.
@@ -23370,7 +23564,128 @@
%
%
%
-% \section{Notes}
+% \section{Notes/Marginalia}
+%
+%
+% \subsection{A simple interface for specifying locations}
+%
+% \changes{v1.61803398d}{2010/01/25}{added}
+%
+% The \Lpack{memoir} class as of December 2009 supports \cs{marginpar},
+% \cs{sidepar}, and \cs{sidebar} for placing information in a margin.
+% The means of specifying in which margin the information should be put
+% is different for each of these. Here a consistent location interface
+% is provided for all marginalia.
+%
+%
+% \begin{macro}{\m@msetm@argin}
+% \begin{macro}{\m@mm@argin}
+% A workhorse macro for setting a margin placement code. The argument
+% may be one of: left, right, outer, or inner, with \cs{m@mm@argin} defined
+% as the corresponding codes of 0, 1, 2, or 3. An unkown argument is coded
+% as a negative number.
+% \begin{macrocode}
+\newcommand*{\m@msetm@argin}[1]{%
+ \def\@tempa{#1}\def\@tempb{left}%
+ \ifx\@tempa\@tempb
+ \def\m@mm@argin{0}%
+ \else
+ \def\@tempb{right}%
+ \ifx\@tempa\@tempb
+ \def\m@mm@argin{1}%
+ \else
+ \def\@tempb{outer}%
+ \ifx\@tempa\@tempb
+ \def\m@mm@argin{2}%
+ \else
+ \def\@tempb{inner}%
+ \ifx\@tempa\@tempb
+ \def\m@mm@argin{3}%
+ \else
+ \def\m@mm@argin{-1}%
+ \fi
+ \fi
+ \fi
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\ifmemtortm}
+% \begin{macro}{\memtortmtrue}
+% \begin{macro}{\memtortmfalse}
+% A flag set TRUE if the marginalia is to be moved to the right of the text
+% and FALSE if it is to be moved to the left of the text.
+% \begin{macrocode}
+% MEM-TO-RighT-Margin
+\newif\ifmemtortm
+ \memtortmtrue
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\m@mwhich@margin}
+% \cs{m@mwhich@margin}\marg{code} sets \cs{ifmemtortm} TRUE or FALSE depending
+% on the value of \meta{code} (0 to 3), and other factors.
+% \begin{description}
+% \item[Two column document] If the first column, to the left, otherwise
+% to the right, irrespective the document being
+% one- or two-side.
+% \item[One sided document] If code = 0 (left), to the left, otherwise
+% (code = 1 (right), 2 (outer), 3 (inner)) to the right.
+% \item[Two sided document] depends on whether a recto or verso page:
+% \begin{description}
+% \item[Recto (odd) page] right if code = 1 (right) or 2 (outer), otherwise
+% left.
+% \item[Verso (even) page] left if code = 0 (left) or 2 (outer), otherwise
+% right.
+% \end{description}
+% \end{description}
+%
+%
+% \begin{macrocode}
+\newcommand*{\m@mwhich@margin}[1]{%
+ \memtortmtrue
+ \if@twocolumn
+ \if@firstcolumn% left
+ \memtortmfalse
+ \else% right
+ \memtortmtrue
+ \fi
+ \else
+ \if@twoside
+ \checkoddpage
+ \ifcase #1\relax% 0 left
+ \memtortmfalse
+ \or% 1 right
+ \memtortmtrue
+ \or% 2 outer
+ \ifoddpage
+ \memtortmtrue
+ \else
+ \memtortmfalse
+ \fi
+ \or% 3 inner
+ \ifoddpage
+ \memtortmfalse
+ \else
+ \memtortmtrue
+ \fi
+ \fi% end ifcase
+ \else% oneside
+ \ifnum #1=\z@% 0 left, all else right
+ \memtortmfalse
+ \else
+ \memtortmtrue
+ \fi
+ \fi% end if@twoside
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+%
%
%
% \subsection{Marginpars}
@@ -23452,6 +23767,88 @@
% \end{macrocode}
% \end{macro}
%
+% \subsubsection{Marginpar -- margin interface}
+%
+% The `standard' method of specifying the desired margin for a \cs{marginpar}
+% consists of the two macros \cs{normalmarginpar} and \cs{reversemarginpar},
+% whose effects depend on whether the document is one- or two-sided, whether
+% the page is recto or verso, and if it is set in one- or two-columns.
+%
+% \begin{macro}{\ifm@msetmp}
+% \begin{macro}{m@msetmptrue}
+% \begin{macro}{m@msetmpfalse}
+% TRUE if the macro \cs{marginparmargin} has been called.
+% \begin{macrocode}
+\newif\ifm@msetmp
+ \m@msetmpfalse
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\marginparmargin}
+% \begin{macro}{\m@mmpar@margin}
+% The user command for specifying the desired margin for \cs{marginpar}s.
+% The code is stored as \cs{m@mmpar@margin}, and \cs{setmpbools} is called to
+% convert to the regular \cs{marginpar} booleans.
+% \begin{macrocode}
+\newcommand*{\marginparmargin}[1]{%
+ \m@msetmptrue
+ \m@msetm@argin{#1}%
+ \ifnum\m@mm@argin<\z@
+ \@memwarn{Bad \string\marginparmargin\space argument `#1'\MessageBreak
+ set to `outer'}%
+ \gdef\m@mmpar@margin{2}% set as outer
+ \else
+ \global\let\m@mmpar@margin\m@mm@argin
+ \fi
+ \setmpbools}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\setmpbools}
+% Given \cs{m@mmpar@margin}, \cs{setmpbools} sets the corresponding
+% \cs{marginpar} location booleans.
+% \begin{macrocode}
+\newcommand*{\setmpbools}{%
+ \if@twoside
+ \@mparswitchtrue
+ \else
+ \@mparswitchfalse
+ \fi
+ \ifcase\m@mmpar@margin\relax% 0 left
+ \@reversemargintrue% \sideparswitchfalse \reversesidepartrue
+ \or% 1 right
+ \@reversemarginfalse% \sideparswitchfalse \reversesideparfalse
+ \or% 2 outer
+ \@reversemarginfalse% \sideparswitchtrue \reversesideparfalse
+ \or% 3 inner
+ \@reversemargintrue% \sideparswitchtrue \reversesidepartrue
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macrocode}
+\newcommand*{\m@msetmpcodes}{%
+ \if@mparswitch% 2 sided
+ \if@reversemargin% inner
+ \def\m@mmpar@margin{3}%
+ \else% outer
+ \def\m@mmpar@margin{2}%
+ \fi
+ \else% 1 sided
+ \if@reversemargin% left
+ \def\m@mmpar@margin{0}%
+ \else% right
+ \def\m@mmpar@margin{1}%
+ \fi
+ \fi}
+
+% \end{macrocode}
+%
% \subsection{A fixed marginpar}
%
%
@@ -23480,7 +23877,11 @@
%
% \begin{macro}{\ifreversesidepar}
% \begin{macro}{\ifsideparswitch}
-% Analogues of \cs{marginpar} controls.
+% \changes{v1.61803398d}{2010/01/25}{Added footnote explaining the default}
+% Analogues of \cs{marginpar} controls.\footnote{Note that for some
+% now forgotten reason the default placement of the \cs{sidepar} is
+% reversed in comparison to say \cs{marginpar}. As not to change
+% existing documents, we have left the default like this.}
% \begin{macrocode}
\newif\ifreversesidepar
% \reversesideparfalse
@@ -23493,18 +23894,116 @@
% \end{macro}
% \end{macro}
%
-% \begin{macro}{\sideparvshift}
-% Vertical shift for sidepar to align with text line
+% \changes{v1.61803398d}{2010/01/25}{Added}
+% \begin{macro}{\ifm@msetsp}
+% \begin{macro}{\m@msetsptrue}
+% \begin{macro}{\m@msetspfalse}
% \begin{macrocode}
-\newlength{\sideparvshift}
-%%%% \setlength{\sideparvshift}{-2.08ex}% seems to work for all font sizes
+%% true if \sideparmargin used
+\newif\ifm@msetsp
+ \m@msetspfalse
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \changes{v1.61803398d}{2010/01/25}{Added}
+% \begin{macro}{\sideparmargin}
+% \begin{macro}{\m@mspar@margin}
+% User command for specifing the margin for \cs{sidepar}s.
+% The numeric code is stored in \cs{m@mspar@margin}.
+% \begin{macrocode}
+\newcommand*{\sideparmargin}[1]{%
+ \m@msetsptrue
+ \m@msetm@argin{#1}%
+ \ifnum\m@mm@argin<\z@
+ \@memwarn{Bad \string\sideparmargin\space argument `#1'\MessageBreak
+ set to `outer'}%
+ \gdef\m@mspar@margin{2}% set as outer
+ \else
+ \global\let\m@mspar@margin\m@mm@argin
+ \fi}
% \end{macrocode}
% \end{macro}
-%
+% \end{macro}
+% \changes{v1.61803398d}{2010/01/25}{Added}
+% \begin{macro}{\m@msidepar@left}
+% \begin{macro}{\m@msidepar@right}
+% Move a \cs{sidepar} into the left/right margin.
+% \begin{macrocode}
+\newcommand*{\m@msidepar@left}{%
+ \@tempdimc\marginparwidth
+ \advance\@tempdimc\marginparsep
+ \kern-\@tempdimc}
+\newcommand*{\m@msidepar@right}{%
+ \@tempdimc\columnwidth
+ \advance\@tempdimc\marginparsep
+ \kern\@tempdimc}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \changes{v1.61803398d}{2010/01/25}{Added}
+% \begin{macro}{\setspbools}
+% Given the \cs{m@mspar@margin} code, calculates the corresponding
+% \cs{sidepar} location booleans.
+% \begin{macrocode}
+\newcommand*{\setspbools}{%
+ \ifcase\m@mspar@margin\relax% 0 left
+ \sideparswitchfalse \reversesidepartrue
+ \or% 1 right
+ \sideparswitchfalse \reversesideparfalse
+ \or% 2 outer
+ \sideparswitchtrue \reversesideparfalse
+ \or% 3 inner
+ \sideparswitchtrue \reversesidepartrue
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+% \changes{v1.61803398d}{2010/01/25}{Added}
+% \begin{macro}{\setspcode}
+% Given the \cs{sidepar} location booleans, sets up the corresponding
+% \cs{m@mspar@margin} numeric codes.
+% \begin{macrocode}
+\newcommand*{\setspcode}{%
+ \ifsideparswitch
+ \ifreversesidepar
+ \def\m@mspar@margin{3}% inner
+ \else
+ \def\m@mspar@margin{2}% outer
+ \fi
+ \else
+ \ifreversesidepar
+ \def\m@mspar@margin{0}% left
+ \else
+ \def\m@mspar@margin{1}% right
+ \fi
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+% \changes{v1.61803398d}{2010/01/25}{Added}
+% \begin{macro}{\sideparfont}
+% \begin{macro}{\sideparform}
+% The font to be used for \cs{sidepar}s and the alignment for it.
+% \changes{v1.61803398d}{2010/02/04}{Changed default font}
+% \changes{v1.61803398d}{2010/02/05}{added \cs{sideparform}}
+% The \cs{sideparform} holds code that will set the text flush against
+% the edge of the text.\footnote{One might consider redefining this
+% using the \cs{RaggedRight} and \cs{RaggedLeft} macros from the
+% ragged2e package.}
+% \begin{macrocode}
+\newcommand*{\sideparfont}{\normalfont\normalsize}
+\newcommand*{\sideparform}{\ifmemtortm\raggedright\else\raggedleft\fi}
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+
%
% \begin{macro}{\sidepar}
% \begin{macro}{\@sidepar}
+% \begin{macro}{\sideparvshift}
% \cs{sidepar}\oarg{left}\marg{right} (per \cs{marginpar}).
% Sidepars had a nasty habit of moving up or down depending on whether
% characters in the sidepar and the main text line have ascenders and/or
@@ -23518,55 +24017,48 @@
% (mempatch v4.5)}
% \changes{v1.61803}{2008/01/30}{Normalised font in \cs{@sidepar}
% (mempatch v4.9)}
+% \changes{v1.61803398d}{2010/01/25}{\cs{@sidepar} changed to fit the
+% interface just added}
+% \changes{v1.61803398d}{2010/02/05}{added \cs{sideparform}}
% \begin{macrocode}
\newcommand{\sidepar}{\@dblarg{\@sidepar}}
-\long\def\@sidepar[#1]#2{\@bsphack\strut\vadjust{%
+\long\def\@sidepar[#1]#2{\leavevmode\@bsphack\strut\vadjust{%
\checkoddpage
- \ifsideparswitch
- \ifreversesidepar
- \ifoddpage
- \oddpagefalse
- \else
- \oddpagetrue
- \fi
- \fi
- \else
- \oddpagetrue
- \ifreversesidepar
- \oddpagefalse
- \fi
+ \ifm@msetsp% \sideparmargin used
+%%%% \setspbools
+ \else% \sideparmargin not used, set the \m@mspar@margin code
+ \setspcode
\fi
\rlap{\kern-\parindent
- \if@twocolumn
- \if@firstcolumn% put at left
- \kern -\marginparsep \kern -\marginparwidth
- \else% put at right
- \kern \columnwidth \kern \marginparsep
- \fi
+ \m@mwhich@margin{\m@mspar@margin}% set left or right margin
+ \ifmemtortm
+ \m@msidepar@right
\else
- \ifoddpage% put at right
- \kern \textwidth \kern \marginparsep
- \else% put at left
- \kern -\marginparsep \kern -\marginparwidth
- \fi
+ \m@msidepar@left
\fi
- \setbox0=\vtop to 0pt{%
- \begin{minipage}[t]{\marginparwidth}%
- \normalfont\normalsize
- \ifoddpage #2\else #1\fi%
- \end{minipage}%
- \vss}%
- \vtop to 0pt{\kern\sideparvshift% default should be 0pt
- \kern-\dp\strutbox
- \kern-\ht0
- \box0 \vss}}}%
+ \setbox0=\vtop to 0pt{%
+ \begin{minipage}[t]{\marginparwidth}%
+ \sideparform\sideparfont%
+ \ifmemtortm #2\else #1\fi
+ \end{minipage}%
+ \vss}%
+ \vtop to 0pt{\kern\sideparvshift% default should be 0pt
+ \kern-\dp\strutbox
+ \kern-\ht0
+ \box0 \vss}}}%
\@esphack}
-\setlength{\sideparvshift}{0pt}
% \end{macrocode}
% \end{macro}
% \end{macro}
-%
+% Vertical shift for sidepar to align with text line
+% \begin{macrocode}
+\newlength{\sideparvshift}
+\setlength{\sideparvshift}{0pt}
+%%%% \setlength{\sideparvshift}{-2.08ex}% seems to work for all font sizes
+
+% \end{macrocode}
+% \end{macro}
%
%
% \subsection{Sidebars}
@@ -23692,8 +24184,9 @@
%
% \begin{macro}{\sidebarfont}
% The font for typesetting the contents of a sidebar.
+% \changes{v1.61803398d}{2010/02/05}{Added a default for \cs{sidebarfont}}
% \begin{macrocode}
-\newcommand{\sidebarfont}{}
+\newcommand{\sidebarfont}{\normalfont\normalsize}
% \end{macrocode}
% \end{macro}
%
@@ -23746,9 +24239,14 @@
% \end{verbatim}
% \changes{v1.4}{2003/11/22}{Added \cs{sidebarform} (from patch v1.5)}
% \changes{v1.61803398}{2009/07/18}{Added bidi support to \cs{sidebarform}}
+% \changes{v1.61803398d}{2010/02/05}{changed to make the text flush
+% against the text}
% \begin{macrocode}
\newcommand{\sidebarform}{%\rightskip=\z@ \@plus 2em}
- \memRTLrightskip=\z@ \@plus 2em}
+ %\memRTLrightskip=\z@ \@plus 2em
+ \ifmemtortm\raggedright\else\raggedleft\fi%
+ % \ifmemtortm\memRTLrightskip=\z@ \@plus 2em\else\memRTLleftskip=\z@ \@plus 2em\fi
+}
% \end{macrocode}
% \end{macro}
@@ -23756,6 +24254,9 @@
% \begin{macro}{\ifsidebaroneside}
% Flag for oneside.
% \changes{v1.61}{2004/04/05}{Added \cs{ifsidebaroneside}}
+% \changes{v1.61803398d}{2010/02/07}{flaged as deprecated, the macro
+% is not used at all, kept just to ensure that documents does not
+% crash, TO BE DELETED}
% \begin{macrocode}
\newif\ifsidebaroneside
\if@twoside\sidebaronesidefalse\else\sidebaronesidetrue\fi
@@ -23765,36 +24266,22 @@
%
% \begin{macro}{\sidebarmargin}
% \begin{macro}{\m@msidebar@margin}
+% \changes{v1.61803398d}{2010/02/07}{removed the mention of
+% \cs{sidebaroneside}, as it is deprecated}
% \cs{sidebarmargin}\marg{side} sets the side where sidebars will be printed.
% Valid arguments are: left, right, outer, or inner.
-% The command is only effective for onecolumn documents with
-% \verb?\sidebaronesidefalse?
-% (\verb?\sidebarmargin{right}? is equivalent to \verb?\sidebaronesidetrue?).
%
% \changes{v1.618}{2005/09/03}{Added \cs{sidebarmargin} (mempatch v3.2)}
+% \changes{v1.61803398d}{2010/01/25}{Changed to match new general interface}
% \begin{macrocode}
\newcommand*{\sidebarmargin}[1]{%
- \def\@tempa{#1}\def\@tempb{left}%
- \ifx\@tempa\@tempb
- \gdef\m@msidebar@margin{0}%
+ \m@msetm@argin{#1}%
+ \ifnum\m@mm@argin<\z@
+ \@memwarn{Bad \string\sidebarmargin\space argument `#1'\MessageBreak
+ set to `outer'}%
+ \gdef\m@msidebar@margin{2}% set as outer
\else
- \def\@tempb{right}%
- \ifx\@tempa\@tempb
- \gdef\m@msidebar@margin{1}%
- \else
- \def\@tempb{outer}%
- \ifx\@tempa\@tempb
- \gdef\m@msidebar@margin{2}%
- \else
- \def\@tempb{inner}%
- \ifx\@tempa\@tempb
- \gdef\m@msidebar@margin{3}%
- \else
- \@memwarn{Bad \string\sidebarmargin\space argument}%
- \gdef\m@msidebar@margin{1}%
- \fi
- \fi
- \fi
+ \global\let\m@msidebar@margin\m@mm@argin
\fi}
%%%% default outer
\gdef\m@msidebar@margin{2}
@@ -23833,36 +24320,15 @@
% \changes{v1.61}{2004/04/05}{Changed \cs{sidecontents} for oneside option}
% \changes{v1.618}{2005/09/03}{Changed \cs{sidecontents} for \cs{sidebarmargin}}
% \changes{v1.61803}{2008/01/30}{Modified \cs{sidecontents} (mempatch v4.6)}
+% \changes{v1.61803398d}{2010/01/15}{changed to use
+% \cs{m@mwhich@margin} for determining wheter to move right ot left}
% \begin{macrocode}
\newcommand{\sidecontents}{\hbox to \z@{%
- \if@twocolumn% %% put outside nearest column
- \if@firstcolumn% %% move to left
- \m@sideb@left
- \else% %% move to right
- \m@sideb@right
- \fi
- \else% %% put into foremargin?
- \ifsidebaroneside% %% put into right hand margin
- \m@sideb@right
- \else% %% pick the margin
- \ifcase\m@msidebar@margin% 0 to left
- \m@sideb@left
- \or% 1 to right
- \m@sideb@right
- \or% 2 to outer
- \ifodd\c@page% %% move to right
- \m@sideb@right
- \else% %% move to left
- \m@sideb@left
- \fi
- \or% 3 to inner
- \ifodd\c@page% %% move to left
- \m@sideb@left
- \else% %% move to right
- \m@sideb@right
- \fi
- \fi
- \fi
+ \m@mwhich@margin{\m@msidebar@margin}%
+ \ifmemtortm
+ \m@sideb@right
+ \else
+ \m@sideb@left
\fi
% \end{macrocode}
% DA and I have gone to and fro on the next bit of code trying to get
@@ -23906,10 +24372,21 @@
% (dependant on the font) will determine the top alignment both initially
% and after a page break. The setting for maximum depth does not control
% anything; see the code further on instead.
+% \changes{v1.61803398d}{2010/02/05}{removed
+% \cs{normalfont}\cs{normalsize}, as these are now in the \cs{sidebarfont}}
% \begin{macrocode}
\hsize\sidebarwidth
\@parboxrestore
- \sidebarform \normalsize\normalfont\sidebarfont
+% \end{macrocode}
+% \changes{v1.61803398d}{2010/02/05}{Added margin placement check
+% inside \cs{sidebar}}
+% Even though the margin placement is handled inside
+% \cs{sidecontents}, there are some timming issues such that
+% \cs{ifmemtortm} is executed too late for \cs{sidebar}s internals to
+% make use of it. Fixed by adding the margin check to \cs{sidebar} as well.
+% \begin{macrocode}
+ \m@mwhich@margin{\m@msidebar@margin}%
+ \sidebarform\sidebarfont
\splittopskip=\ht\strutbox
\splitmaxdepth=\dp\strutbox % doesn't do anything useful
% \end{macrocode}
@@ -26084,6 +26561,618 @@
% \end{macrocode}
% \end{macro}
%
+% \changes{v1.61803398d}{2010/01/25}{Added section about side footnotes}
+% \subsection{Side footnotes} \label{sec:sidefootnotes}
+%
+%
+% \subsubsection{Extension to the regular footnote}
+%
+% The code here enables the regular \cs{footnote} to be set in the
+% margin. It is based on Robin Fairbairns' \Lpack{footmisc} package.
+%
+% \begin{macro}{\ifm@mfnmargin}
+% \begin{macro}{\footnotesatfoot}
+% \begin{macro}{\footnotesinmargin}
+% Declarations for regular footnotes to be set as normal at the foot
+% of the page, or in the margin.
+% \begin{macrocode}
+\newif\ifm@mfnmargin
+\newcommand*{\footnotesatfoot}{\m@mfnmarginfalse}
+\newcommand*{\footnotesinmargin}{\m@mfnmargintrue}
+\footnotesatfoot
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \changes{v1.61803398d}{2010/01/25}{Remember that we actually have
+% several \cs{@footnotetext} in memoir, might be an idea to clean this
+% up at some point/daleif}
+% \begin{macro}{\@footnotetext}
+% Change \cs{@footnotetext} to enable footnotes to be put into the margin
+% by using \cs{marginpar}.
+% \begin{macrocode}
+\renewcommand{\@footnotetext}[1]{%
+ \ifm@mfnmargin% use marginpar
+% \end{macrocode}
+% Use \cs{marginpar} for placing the footnote.
+% \begin{macrocode}
+ \marginpar{%
+ \def\baselinestretch{\m@m@singlespace}%
+ \reset@font
+ \foottextfont
+ \protected@edef\@currentlabel{%
+ \csname p@footnote\endcsname\@thefnmark}%
+ \color@begingroup
+ \@makefntext{\ignorespaces#1}%
+ \color@endgroup}%
+ \else% regular feet
+% \end{macrocode}
+% This is the original code for \cs{@footnotetext}.
+% \begin{macrocode}
+ \insert\footins{%
+ \def\baselinestretch{\m@m@singlespace}%
+ \reset@font
+ \foottextfont
+ \@preamfntext
+ \hsize\columnwidth
+ \protected@edef\@currentlabel{%
+ \csname p@footnote\endcsname\@thefnmark}%
+ \color@begingroup
+ \@makefntext{%
+ \rule\z@\footnotesep\ignorespaces{\foottextfont #1}%
+ \@finalstrut\strutbox}%
+ \color@endgroup}
+ \fi
+ \m@mmf@prepare}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \subsection{Bottom aligned side footnotes}
+%
+% The code for the bottom aligned marginal footnotes is based partly on
+% the \cs{sidebar} code and code from David Salomon, 'Output Routines:
+% Examples and Techniques. Part III: Insertions', \textit{TUGboat},
+% 11, 4, pp 588--605, Nov 1990.
+%
+% \begin{macro}{\sidefootmargin}
+% \begin{macro}{\m@msidefoot@margin}
+% \cs{sidefootmargin} is the user command for setting the side for
+% side footnotes (stored as \cs{m@msidefoot@margin}). The default
+% is \texttt{outer}.
+% \begin{macrocode}
+\newcommand*{\sidefootmargin}[1]{%
+ \m@msetm@argin{#1}%
+ \ifnum\m@mm@argin<\z@
+ \@memwarn{Bad \string\sidefootmargin\space argument `#1'\MessageBreak
+ set to `outer'}%
+ \gdef\m@msidefoot@margin{2}% set as outer
+ \else
+ \global\let\m@msidefoot@margin\m@mm@argin
+ \fi}
+\sidefootmargin{outer}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+%
+% \begin{macro}{\sidefootins}
+% As for any non-main text matter we need an insert.
+% \begin{macrocode}
+\newinsert\sidefootins
+ \skip\sidefootins=0pt
+ \count\sidefootins=0\relax
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefootadjust}
+% \begin{macro}{\sidefootheight}
+% \begin{macro}{\setsidefootheight}
+% The length \cs{sidefootadjust} can be used for fine control over the
+% vertivcal position of the base of the column of side footnotes.
+% The length \cs{sidefootheight}
+% is the height of the column and is best set by the \cs{setsidefootheight}
+% macro, which takes the desired height as its argument and sets the height
+% of the \cs{sidefootins} \cs{insert}. The height is
+% initially set to the \cs{textheight}.
+% \begin{macrocode}
+\newlength{\sidefootadjust}
+ \setlength{\sidefootadjust}{0pt}
+\newlength{\sidefootheight}
+\newcommand*{\setsidefootheight}[1]{%
+ \setlength{\dimen\sidefootins}{#1}%
+ \advance\dimen\sidefootins -\topskip
+ \advance\dimen\sidefootins \ht\strutbox
+ \setlength{\sidefootheight}{\dimen\sidefootins}}
+\setsidefootheight{\textheight}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\sidefoothsep}
+% \begin{macro}{\sidefootwidth}
+% \begin{macro}{\sidefootvsep}
+% The horizontal space between the text block and side footnotes
+% (\cs{sidefoothsep}),
+% the width of the column of notes (\cs{sidefootwidth}),
+% and the vertical space between consecutive side footnotes
+% (\cs{sidefootvsep}).
+% \changes{v1.61803398d}{2010/02/05}{removed \cs{sidefootfont}}
+% \begin{macrocode}
+\newlength{\sidefoothsep}
+\newlength{\sidefootvsep}
+\newlength{\sidefootwidth}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\setsidefeet}
+% The macro \cs{setsidefeet}\marg{hsep}\marg{width}\marg{vsep}\marg{adj}\marg{font}\marg{height}
+% sets the specifications for the side footnotes. An `*' means `use
+% the current
+% value'.
+% \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont} to
+% \cs{sidefoottextfont}}
+%
+% \begin{macrocode}
+\newcommand*{\setsidefeet}[6]{%
+ \nametest{#1}{*}\ifsamename\else
+ \setlength{\sidefoothsep}{#1}\@memznegtest{\sidefoothsep}%
+ \fi
+ \nametest{#2}{*}\ifsamename\else
+ \setlength{\sidefootwidth}{#2}\@memznegtest{\sidefootwidth}%
+ \fi
+ \nametest{#3}{*}\ifsamename\else
+ \setlength{\sidefootvsep}{#3}\@memznegtest{\sidefootvsep}%
+ \fi
+ \nametest{#4}{*}\ifsamename\else
+ \setlength{\sidefootadjust}{#4}%
+ \fi
+ \nametest{#5}{*}\ifsamename\else
+ \def\sidefoottextfont{#5}%
+ \fi
+ \nametest{#6}{*}\ifsamename\else
+ \setsidefootheight{#6}%
+ \ifdim\dimen\sidefootins>\z@\else
+ \@memerror{\protect\sidefootheight\space is zero or negative}{\@ehd}%
+ \fi
+ \fi}
+\setsidefeet{\marginparsep}{\marginparwidth}%
+ {\onelineskip}{0pt}%
+ {\normalfont\footnotesize}{\textheight}%
+
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\sidefootform}
+% Set the sidefootnotes raggedy right
+% \begin{macrocode}
+\newcommand*{\sidefootform}{\rightskip=\z@ \@plus 2em}
+
+% \end{macrocode}
+% \end{macro}
+%
+%
+% \begin{macro}{\m@sideft@left}
+% \begin{macro}{\m@sideft@right}
+% Macros placing the sidefootnotes at the left and the right respectively.
+% \begin{macrocode}
+\newcommand*{\m@sideft@left}{%
+ \@tempdimc \sidefootwidth
+ \advance\@tempdimc\sidefoothsep
+ \kern-\@tempdimc}
+\newcommand*{\m@sideft@right}{%
+ \@tempdimc \columnwidth% or \hsize
+ \advance\@tempdimc\sidefoothsep
+ \kern\@tempdimc}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\m@mdownsf}
+% A length used in the vertical positioning of sidefootnotes.
+% (Perhaps one of the \cs{@tempdim} lengths could be used instead?)
+% \begin{macrocode}
+\newlength{\m@mdownsf}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefootcontents}
+% The essence of the sidefootnote task. This first positions the column
+% to the left or the right and then tries to make the bottom of the
+% column align with the bottom of the textblock.
+% \begin{macrocode}
+\newcommand*{\sidefootcontents}{\hbox to \z@{%
+ \m@mwhich@margin{\m@msidefoot@margin}%
+ \ifmemtortm
+ \m@sideft@right
+ \else
+ \m@sideft@left
+ \fi
+% \end{macrocode}
+% Now the fun part. The general idea is to measure the height of the insert's
+% contents, subtract this from the specified height of the insert,
+% and move the contents down by that amount.
+% The code below seems to work except when sidefootnotes
+% spill over to the following page; also, like \cs{sidebar},
+% they are out of vertical alignment when on a \cs{chapter} page.
+% I haven't found a way to automatically
+% adjust for these, which is why the \cs{sidefootadjust} length is
+% there to enable manual adjustment.
+% \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont}
+% to \cs{sidefoottextfont}}
+% \begin{macrocode}
+ \vtop to 0pt{% original
+ \normalsize\normalfont\sidefoottextfont
+ \vskip\topskip \vskip-\ht\strutbox
+ \vskip\sidefootadjust% use this for minor vertical adjustment
+ \m@mdownsf=\dimen\sidefootins
+ \advance\m@mdownsf-\ht\sidefootins
+ \advance\m@mdownsf-\dp\sidefootins
+% \end{macrocode}
+% Here's where the fiddling occurs, arrived at by a mixture of theory and
+% experiment.
+% \begin{macrocode}
+ \ifdim\m@mdownsf>\sidefootvsep
+ \advance\m@mdownsf\sidefootvsep
+ \advance\m@mdownsf 0.5\ht\strutbox
+ \fi
+ \vskip\m@mdownsf% --- basically works
+ \unvbox\sidefootins%
+ \vss}%
+ \hss}}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\m@mopsidefoot}
+% If there are any sidefeet then add them to the output.
+% \begin{macrocode}
+\newcommand*{\m@mopsidefoot}{%
+ \ifvoid\sidefootins\else
+ \setbox\@outputbox \vbox{%
+ \sidefootcontents
+ \unvbox\@outputbox}
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\mem@makecol}
+% \begin{macro}{\mem@makecolbf}
+% \begin{macro}{\@reinserts}
+% \begin{macro}{\@mem@extranofeet}
+% \begin{macro}{@mem@testifnofoot}
+% Revise these to cater for the new sidefoot insert.
+% \begin{macrocode}
+\gdef\mem@makecol{
+ \m@m@makecolintro
+ \ifvoid\footins
+ \setbox\@outputbox \box\@cclv
+ \else
+ \m@mopfootnote
+ \fi
+ \m@mdoextrafeet
+ \m@m@makecolfloats
+ \m@mopsidebar
+ \m@mopsidefoot
+ \m@m@makecoltext
+ \global \maxdepth \@maxdepth}
+
+% \end{macrocode}
+%
+% \begin{macrocode}
+\gdef\mem@makecolbf{
+ \m@m@makecolintro
+ \setbox\@outputbox \box\@cclv
+ \m@m@makecolfloats
+ \ifvoid\footins
+ \else
+ \m@mopfootnote
+ \fi
+ \m@mdoextrafeet
+ \m@mopsidebar
+ \m@mopsidefoot
+ \m@m@makecoltext
+ \global \maxdepth \@maxdepth}
+
+% \end{macrocode}
+%
+% \begin{macrocode}
+\gdef\@reinserts{%
+ \ifvoid\footins\else\insert\footins{\unvbox\footins}\fi
+ \m@mdodoreinextrafeet
+ \ifvbox\@kludgeins\else\insert\@kludgeins{\unvbox\@kludgeins}\fi
+ \ifvoid\sideins\else\insert\sideins{\unvbox\sideins}\fi
+ \ifvoid\sidefootins\else\insert\sidefootins{\unvbox\sidefootins}\fi}
+
+% \end{macrocode}
+%
+% The easy way of extending the \cs{clearpage} code is by:
+% \begin{verbatim}
+% \renewcommand*{\@mem@extranofeet}{%
+% \ifvoid\sidefootins\else\@mem@nofootfalse\fi}
+% \end{verbatim}
+% but as so many other changes have to be made it's probably better to
+% leave that alone and change \cs{@mem@testifnofoot} directly.
+% \begin{macrocode}
+\renewcommand*{\@mem@testifnofoot}{%
+ \@mem@nofoottrue
+ \ifvoid\footins\else\@mem@nofootfalse\fi
+ \ifvoid\footinsv@r\else\@mem@nofootfalse\fi
+ \ifvoid\sideins\else\@mem@nofootfalse\fi
+ \ifvoid\sidefootins\else\@mem@nofootfalse\fi
+ \@mem@extranofeet}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \subsubsection{The sidefootnote macros}
+%
+% The macros here are essentially a copy of the ones for \cs{footnote}.
+% I have not done anything about sidefootnotes in minipages, as I can't
+% imagine a use for them while simultaneously making the final appearance
+% looking good.
+%
+% The usual counter.
+% \begin{macrocode}
+\newcounter{sidefootnote}
+ \renewcommand{\thesidefootnote}{\@arabic\c@sidefootnote}
+\@addtoreset{sidefootnote}{chapter}
+
+% \end{macrocode}
+%
+% By using: \\
+% \verb?\letcountercounter{sidefootnote}{footnote}? \\
+% the same counter will be used for both footnotes and sidefootnotes.
+% This can be reverted to separate counters by; \\
+% \verb?\unletcounter{sidefootnote}?
+%
+% \begin{macro}{\sidefoottextfont}
+% The font for the sidefootnotes.
+% \changes{v1.61803398d}{2010/02/06}{\cs{sidefoottextfont} is already
+% defined by the initial issuing of \cs{setsidefeet}}
+% \begin{macrocode}
+%\newcommand*{\sidefoottextfont}{\normalfont\footnotesize}
+
+% \end{macrocode}
+% \end{macro}
+%
+% The remainder of the code is a copied from that for \cs{footnote}
+% but with the appropriate variables for \cs{sidefootnote}s
+%
+% \begin{macro}{\@sidempfn}
+% \begin{macro}{\thesidempfn}
+% \begin{macrocode}
+\newcommand*{\@sidempfn}{sidefootnote}
+\newcommand*{\thesidempfn}{\thesidefootnote}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\@makesidefnmark}
+% \begin{macrocode}
+\newcommand*{\@makesidefnmark}{\hbox{\@textsuperscript{%
+ \normalfont\@thesidefnmark}}}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@preamsidefntext}
+% \begin{macrocode}
+\newcommand{\@preamsidefntext}{%
+ \interlinepenalty\interfootnotelinepenalty
+ \floatingpenalty \@MM
+ \splittopskip=\footnotesep
+ \splitmaxdepth=\dp\strutbox
+ \@parboxrestore}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@sidefootnotetext}
+% \changes{v1.61803398d}{2010/02/05}{changed \cs{sidefootfont}
+% to \cs{sidefoottextfont}}
+% \begin{macrocode}
+\newcommand{\@sidefootnotetext}[1]{\insert\sidefootins{%
+ \hsize\sidefootwidth
+ \@parboxrestore
+ \def\baselinestretch{\m@m@singlespace}%
+ \sidefootform \normalsize\normalfont\sidefoottextfont
+ \splittopskip=\ht\strutbox
+ \splitmaxdepth=\dp\strutbox
+ \allowbreak
+ \prevdepth=\dp\strutbox
+ \vskip-\parskip
+ \protected@edef\@currentlabel{%
+ \csname p@sidefootnote\endcsname\@thesidefnmark}%
+\color@begingroup
+\@makesidefntext{{\sidefoottextfont #1}}%
+\color@endgroup
+ \ifvmode\else
+ \unskip\@finalstrut\strutbox
+ \fi
+ \par
+ \ifdim\prevdepth>\dp\strutbox \prevdepth=\dp\strutbox\fi
+ \ifdim\prevdepth>99\p@
+ \nobreak
+ \vskip-\prevdepth
+ \allowbreak
+ \vskip\dp\strutbox
+ \fi
+ \vskip\sidefootvsep}%
+ \m@mmf@prepare}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@sidefootnotemark}
+% \begin{macrocode}
+\newcommand*{\@sidefootnotemark}{%
+ \leavevmode
+ \ifhmode
+ \edef\@x@sf{\the\spacefactor}%
+ \m@mmf@check
+ \nobreak
+ \fi
+ \@makesidefnmark
+ \m@mmf@prepare
+ \ifhmode\spacefactor\@x@sf\fi
+ \relax}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefootnote}
+% \begin{macrocode}
+\newcommand*{\sidefootnote}{\@ifnextchar[
+ \@xsidefootnote{\stepcounter\@sidempfn
+ \protected@xdef\@thesidefnmark{\thesidempfn}%
+ \@sidefootnotemark\@sidefootnotetext}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@xsidefootnote}
+% \begin{macrocode}
+\def\@xsidefootnote[#1]{%
+ \begingroup
+ \csname c@\@sidempfn\endcsname #1\relax
+ \unrestored@protected@xdef\@thesidefnmark{\thesidempfn}%
+ \endgroup
+ \@sidefootnotemark\@sidefootnotetext}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefootnotemark}
+% \begin{macrocode}
+\newcommand{\sidefootnotemark}{%
+ \@ifnextchar[
+ \@xsidefootnotemark
+ {\stepcounter{sidefootnote}%
+ \protected@xdef\@thesidefnmark{\thesidefootnote}%
+ \@sidefootnotemark}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@xsidefootnotemark}
+% \begin{macrocode}
+\def\@xsidefootnotemark[#1]{%
+ \begingroup
+ \c@sidefootnote #1\relax
+ \unrestored@protected@xdef\@thesidefnmark{\thesidefootnote}%
+ \endgroup
+ \@sidefootnotemark}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefootnotetext}
+% \begin{macrocode}
+\newcommand*{\sidefootnotetext}{%
+ \@ifnextchar[
+ \@xsidefootnotetext
+ {\protected@xdef\@thesidefnmark{\thesidempfn}%
+ \@sidefootnotetext}}
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@xsidefootnotetext}
+% \begin{macrocode}
+\def\@xsidefootnotetext[#1]{%
+ \begingroup
+ \csname c@\@sidempfn\endcsname #1\relax
+ \unrestored@protected@xdef\@thesidefnmark{\thesidempfn}%
+ \endgroup
+ \@sidefootnotetext}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\sidefootmarkstyle}
+% \begin{macro}{\sidefootscript}
+% \begin{macro}{\makesidefootmarkhook}
+% \begin{macro}{\sidefootfootmark}
+% \begin{macrocode}
+\newcommand*{\sidefootmarkstyle}[1]{\def\sidefootscript##1{#1}}
+\newcommand*{\makesidefootmarkhook}{}
+\newcommand*{\sidefootfootmark}{%
+ \ifdim\sidefootmarkwidth < \z@
+ \llap{\hb@xt@ -\sidefootmarkwidth{%
+ \hss\normalfont\sidefootscript{\@thesidefnmark}}%
+ \hspace*{-\sidefootmarkwidth}}%
+ \else
+ \ifdim\sidefootmarkwidth = \z@
+ {\normalfont\sidefootscript{\@thesidefnmark}}%
+ \else
+ \hb@xt@\sidefootmarkwidth{\hss\normalfont\sidefootscript{\@thesidefnmark}}%
+ \fi
+ \fi}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}{\makesidefootmark}
+% \changes{v1.61803398d}{2010/02/04}{Made \cs{makesidefootmark} long
+% as the similar \cs{footnote} command, otherwise one cannot make side
+% footnotes containign several paragraphs}
+% \begin{macrocode}
+\newcommand{\makesidefootmark}[1]{%
+ \leavevmode
+ \parindent \sidefootparindent\noindent
+ \leftskip\sidefootmarksep\relax
+ \advance\leftskip \sidefootmarkwidth \null\nobreak\hskip -\leftskip\relax
+ \makesidefootmarkhook\relax
+ \sidefootfootmark #1}
+
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\@makesidefntext}
+% \begin{macrocode}
+\newcommand{\@makesidefntext}[1]{\makesidefootmark #1}
+
+% \end{macrocode}
+% \end{macro}
+%
+% Final layout.
+% \begin{macro}{\sidefootmarkwidth}
+% \begin{macro}{\sidefootmarksep}
+% \begin{macro}{\sidefootparindent}
+% \changes{v1.61803398d}{2010/02/04}{changed the defaults for
+% \cs{sidefootmarkwidth} and \cs{sidefootmarksep} to zero, from 1em
+% and -1em, looks better with the narrow margins}
+% \begin{macrocode}
+\newlength{\sidefootmarkwidth}
+ \setlength{\sidefootmarkwidth}{0em}
+\newlength{\sidefootmarksep}
+ \setlength{\sidefootmarksep}{0em}
+\newlength{\sidefootparindent}
+ \setlength{\sidefootparindent}{1em}
+\sidefootmarkstyle{\textsuperscript{#1}}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
%
%
% \subsection{End notes}
@@ -30161,6 +31250,49 @@
% after one of these commands, use \verb?\setcounter{ctr}{...}?, and to change
% the typeseting style use \verb?\renewcommand{\thectr}{...}?.
%
+%
+% \begin{macro}{\letcountercounter}
+% \begin{macro}{\c@m@morig@ctr}
+% \begin{macro}{\unletcounter}
+% At times it is handy to `let' one counter act as if it was a
+% different counter. Say you have two constructions, each with their
+% own counter A and B, now you want them to cooperate, counting in
+% unison. This can be done using the \verb?\letcountercounter?.
+%
+% \medskip
+%
+% \cs{letcountercounter}\marg{counterA}\marg{counterB} \cs{let}s
+% (make the same) \meta{counterA} to \meta{counterB}. The
+% original of \meta{counterA} is kept in \cs{c@m@morig@ctr}\meta{counterA}.
+%
+% \cs{unletcounter}\marg{counterA} restores \meta{counterA} to its un\cs{let}
+% condition.
+%
+% The code is based on Donald Arseneau's `Re: \cs{let}, \cs{csname} and
+% \cs{endcsname}', CTT, 2004/12/08. The long version, where \cs{xp}
+% is actually \cs{expandafter} is along the lines of:
+% \begin{verbatim}
+% \xp\xp\xp\let\xp\csname\xp c@#1\xp\endcsname\csname c@#2\endcsname
+% \end{verbatim}
+% which employs 6 \cs{expandafter}s. DA's version uses only 2. The technique
+% can be applied to other kinds of \cs{let}s.
+%
+% \begin{macrocode}
+\newcommand*{\letcountercounter}[2]{%
+ \expandafter\let\csname c@m@morig@ctr#1\expandafter\endcsname%
+ \csname c@#1\endcsname
+ \expandafter\let\csname c@#1\expandafter\endcsname%
+ \csname c@#2\endcsname}
+\newcommand*{\unletcounter}[1]{%
+ \expandafter\let\csname c@#1\expandafter\endcsname%
+ \csname c@m@morig@ctr#1\endcsname}
+
+% \end{macrocode}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+%
% \subsection{Odd/even page checking}
%
% It is difficult to check robustly if the current page is odd or even.
@@ -32324,6 +33456,8 @@
% class, so I've added it here to prevent it from being loaded. In any case,
% most of the packages are mine.
% \changes{v1.6180339}{2008/07/23}{Added dates to emulated packages}
+% \changes{v1.61803398d}{2010/02/13}{Emulated tocvsec2, used the date
+% from the other lines, tocvsec2 provides the same macros as memoir}
% \begin{macrocode}
\EmulatedPackage{abstract}[2008/07/23]
\EmulatedPackage{appendix}[2008/07/23]
@@ -32362,6 +33496,7 @@
\EmulatedPackage{titling}[2008/07/23]
\EmulatedPackage{tocbibind}[2008/07/23]
\EmulatedPackage{tocloft}[2008/07/23]
+\EmulatedPackage{tocvsec2}[2008/07/23]
\EmulatedPackage{verbatim}[2008/07/23]
\EmulatedPackage{verse}[2008/07/23]