summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/versonotes/versonotes.dtx
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2015-12-11 23:19:37 +0000
committerKarl Berry <karl@freefriends.org>2015-12-11 23:19:37 +0000
commit816ecdfa1109529b3f0be1c5cbfdca2c6cf647c3 (patch)
tree33507403ce93f743c8f4cdf85bbbc27d82da2ce2 /Master/texmf-dist/source/latex/versonotes/versonotes.dtx
parenta6451a5b29813f32c1fb91745c853c23fc2722a3 (diff)
versonotes (11dec15)
git-svn-id: svn://tug.org/texlive/trunk@39084 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/versonotes/versonotes.dtx')
-rw-r--r--Master/texmf-dist/source/latex/versonotes/versonotes.dtx174
1 files changed, 132 insertions, 42 deletions
diff --git a/Master/texmf-dist/source/latex/versonotes/versonotes.dtx b/Master/texmf-dist/source/latex/versonotes/versonotes.dtx
index 7ee6b20abe5..8711ded03f7 100644
--- a/Master/texmf-dist/source/latex/versonotes/versonotes.dtx
+++ b/Master/texmf-dist/source/latex/versonotes/versonotes.dtx
@@ -2,10 +2,10 @@
% This is versonotes.dtx, which supports adding notes on verso pages,
% opposite annotation on the recto pages. Still sketchy
%%
-%% Release version 0.2, 2015 February 16.
+%% Release version 0.3, 2015 December 8.
%%
%% Copyright 2014, 2015 Norman Gray <http://nxg.me.uk>
-%%
+%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
@@ -13,26 +13,26 @@
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
-%%
+%%
%% This work has the LPPL maintenance status `maintained'.
-%%
+%%
%% The Current Maintainer of this work is Norman Gray
-%%
+%%
%% This work consists of the files versonotes.dtx and versonotes.ins
%% and the derived file versonotes.sty.
%%
%%%% File: versonotes.dtx
-%<+package|driver|example>%%%% Source: c64b7a550082, 2015-02-16T18:33:46+00:00
+%<+package|driver|example>%%%% Source: 1ce01fd3d4fc, 2015-09-16T13:05:15+01:00
%%
%<+package>\NeedsTeXFormat{LaTeX2e}
-%<+package>\ProvidesPackage{versonotes}[2015/02/16 v0.2]
+%<+package>\ProvidesPackage{versonotes}[2015/12/08 v0.3]
%
%<*driver>
\documentclass{ltxdoc}
\title{versonotes: Notes on verso pages}
\author{Norman Gray\\\url{http://nxg.me.uk}}
-\date{Release 0.2}
+\date{Release 0.3, 2015 December 8}
\usepackage{url}
\newcommand\Lopt[1]{\textsf {#1}} % options
\newcommand\file[1]{\texttt {#1}}
@@ -64,8 +64,7 @@
\def\bs{$\backslash$}
-% Uncomment \OnlyDescription to skip the implementation
-\OnlyDescription
+%\OnlyDescription
\begin{document}
\maketitle
%\tableofcontents
@@ -94,19 +93,6 @@
%
% To invoke the package, use the command |\usepackage{versonotes}|.
%
-% The dimensions |\versoleftmargin| and |\versotextwidth| specify the
-% position of the text block on the verso page. The defaults for
-% these are based on the |\textwidth| and |\evensidemargin| of the
-% document at the time the package is loaded.
-% By default, verso paragraphs are set ragged-left; with the
-% declarations in |\versolayout| setting the paragraph parameters.
-% You may reset the first two dimensions with for example
-% |\versoleftmargin=4cm|, and use |\renewcommand\versolayout{...}| to
-% override the paragraph formatting (this will typically require
-% changing |\rightskip|, |\leftskip| and |\parfillskip|). For more
-% elaborate effects (for example changing the note font size and
-% spacing), you will need to redefine |\versolayout|.
-%
% If two notes come too close after one another, the second would
% overprint the first if we did not take steps to avoid this. By
% default, they are separated from each other by a short horizontal
@@ -123,17 +109,56 @@
% \Lpackage{eledmac}
% package.\footnote{\texttt{http://www.ctan.org/pkg/eledmac}}
%
+% The dimensions |\versoleftmargin| and |\versotextwidth| specify the
+% position of the text block on the verso page. The defaults for
+% these are based on the |\textwidth| and |\evensidemargin| of the
+% document at the time the package is loaded.
+% By default, verso paragraphs are set ragged-left; with the
+% declarations in |\versolayout| setting the paragraph parameters.
+% You may reset the first two dimensions with for example
+% |\versoleftmargin=4cm|, and use |\renewcommand\versolayout{...}| to
+% override the paragraph formatting (this will typically require
+% changing |\rightskip|, |\leftskip| and |\parfillskip|). For more
+% elaborate effects (for example changing the note font size and
+% spacing), you will need to redefine |\versolayout|.
+%
+% \subsection*{Recto notes}
+%
+% If the package is invoked with the \Lopt{rectonotes} option, then it
+% runs in a complementary mode in which the notes are placed on the
+% recto page (the right-hand one) instead of the verso. The default
+% |\versolayout| in this case (which of course is really a recto
+% layout) is slightly different, and is based on the preexisting
+% document |\oddsidemargin|. All the pages in the document (apart
+% from the front page) are then formatted as verso pages, though still
+% only the non-note pages are numbered.
+%
+% In this mode, the `add a note' command is still called
+% |\versonote|. You may find it convenient to rename that with
+% |\let\rectonote = \versonote| or |\let\sidenote = \versonote|.
+%
% \subsection*{Notes}
% \begin{itemize}
% \item The package uses the |\pdfsavepos| primitive, and so requires
-% \texttt{pdflatex} or \texttt{xelatex} (and \texttt{luatex}?).
+% \texttt{pdflatex}, \texttt{xelatex}, or \texttt{luatex}.
%
% \item The notes are handled using the |.aux| file, and so (i) they will
% only appear on the second and subsequent runs; and (ii) they will be
% located opposite the position where the |\versonote| macro was
% called on the \emph{previous} run.
%
+% \item The package is available on CTAN at
+% \texttt{macros/latex/contrib/versonotes/}. The source is hosted at
+% \url{https://bitbucket.org/nxg/versonotes}, where you can also find
+% an issues list.
+%
% \end{itemize}
+%
+% \subsection*{Acknowledgements}
+%
+% Thanks to Thomas H.\ Luxon for permission to include the `Paradise
+% Lost' notes in the sample text, and to Axel Berger for suggesting the `rectonotes' option.
+%
% \StopEventually{}
% \newpage
@@ -146,10 +171,18 @@
% The package contains a single user-visible command, and three
% configuration parameters.
%
+% The normal behaviour of this package is to place notes on the verso
+% page (ahem, hence the name). But we can swap that around.
+% \begin{macrocode}
+\newif\if@verso@notesonleft
+\@verso@notesonlefttrue
+% \end{macrocode}
+%
% Configuration options:
% \begin{macrocode}
\def\verso@resetmergestate{\verso@mergestate=2}
\DeclareOption{mergecollisions}{\def\verso@resetmergestate{\verso@mergestate=0}}
+\DeclareOption{rectonotes}{\@verso@notesonleftfalse}
\ProcessOptions
% \end{macrocode}
%
@@ -173,16 +206,26 @@
\newdimen\versoleftmargin
\versoleftmargin=\paperwidth
\advance\versoleftmargin -\textwidth
- \advance\versoleftmargin -\evensidemargin
\advance\versoleftmargin -\hoffset
\advance\versoleftmargin -1in
-\def\versolayout{
- \leftskip=0pt plus 1fil
- \rightskip=0pt
- \parfillskip=0pt
- \parindent=0pt
- \parskip=\medskipamount
-}
+\if@verso@notesonleft
+ \advance\versoleftmargin -\evensidemargin
+ \def\versolayout{
+ \leftskip=0pt plus 1fil
+ \rightskip=0pt
+ \parfillskip=0pt
+ \parindent=0pt
+ \parskip=\medskipamount
+ }
+\else
+ \advance\versoleftmargin -\oddsidemargin
+ \def\versolayout{
+ \leftskip=0pt
+ \rightskip=0pt plus 4em
+ \parindent=0pt
+ \parskip=\medskipamount
+ }
+\fi
% \end{macrocode}
%
% Add a sentinel at the end of the document
@@ -193,8 +236,21 @@
% \end{macrocode}
%
% Define various bits of working storage.
+%
+% The |\verso@pages| token list needs to have an extra leading `page'
+% since the logic in |\verso@processonepage@| can skip it.
% \begin{macrocode}
\newtoks\verso@pages
+ \if@verso@notesonleft
+ \verso@pages={}
+ \else
+ \verso@pages={{}}
+ \fi
+% \end{macrocode}
+% Notes on a single page (which is kept track of by
+% |\verso@currentpagenum| are assembled into |\verso@currentpage|
+% before being transferred as a unit into |\verso@pages|.
+% \begin{macrocode}
\newtoks\verso@currentpage
\newcount\verso@currentpagenum
\verso@currentpagenum=1
@@ -259,8 +315,13 @@
\@tempdima=#2 % #2 < 0pt is the end-of-document flag
\loop
\@tempswafalse
- \ifnum\@tempcnta>\verso@currentpagenum \@tempswatrue \fi
- \ifdim\@tempdima < 0pt \@tempswatrue \@tempdima=0pt \fi
+ \ifnum\@tempcnta > \verso@currentpagenum
+ \@tempswatrue
+ \fi
+ \ifdim\@tempdima < 0pt
+ \@tempswatrue
+ \@tempdima=0pt
+ \fi
\if@tempswa
\edef\@tempa{\the\verso@pages {\the\verso@currentpage}}
\global\verso@pages=\expandafter{\@tempa}
@@ -268,6 +329,14 @@
\verso@currentpage={}
\repeat
\verso@currentpage=\expandafter{\the\verso@currentpage \\{{#1}{#2}{#3}}}
+% \end{macrocode}
+% The last time around, add an extra pair of tokens at the end of the
+% |\verso@pages| list. These provide the arguments to
+% |\verso@processonepage@| on the last time it's called.
+% \begin{macrocode}
+ \ifdim\@tempdima=0pt
+ \global\verso@pages=\expandafter{\the\verso@pages {}{}}
+ \fi
}
% \end{macrocode}
%
@@ -353,7 +422,7 @@
% \begin{macrocode}
\setbox0=\vtop{
\versolayout
- \the\verso@accumulatenote
+ \the\verso@accumulatenote
#3\par}
\verso@accumulatenote={}
% \end{macrocode}
@@ -433,16 +502,36 @@
%
%
% Process a single page of verso-notes.
+%
% Macro |\verso@processonepage@| consumes the next group in the
-% |\verso@pages| list. This is invoked as part of the redefined |\shipout|.
+% |\verso@pages| list. This is invoked as part of the redefined
+% |\shipout|.
+%
+% Macro |\verso@processonepage| is called just before each shipout of
+% a `real' page. If we are putting notes on verso pages (the usual
+% case), then \emph{before} we ship out page~2, we must construct and
+% ship out the notes for page~2; we will have a set of notes for
+% page~1 (which we expect will be empty), which we must discard; we
+% achieve this by simply doing nothing if the current page is page~1.
+% If, on the other hand, we are putting notes on recto pages, then we
+% must instead ship out the notes for page~2 just before shipping out page~3, and
+% must similarly do nothing on pages~1 and~2. This works because
+% in the latter case we have initialised |\verso@pages| with an extra
+% leading |{{}}|.
% \begin{macrocode}
\long\def\verso@processonepage@#1#2\@nil{
\def\@tempa{#1}
% \end{macrocode}
-% We can't have verso-notes opposite the first page. Any notes
-% which would appear in such a position are silently discarded.
+% Do nothing on page~1 (in the verso case), or pages~1 and~2 (in the
+% recto case). Any notes which would appear in such a position are
+% silently discarded.
% \begin{macrocode}
- \ifnum\c@page>1
+ \if@verso@notesonleft
+ \@tempcnta=1
+ \else
+ \@tempcnta=2
+ \fi
+ \ifnum\c@page>\@tempcnta
% \end{macrocode}
% If there are no verso-notes on this page, then ship out an empty box.
% \begin{macrocode}
@@ -497,9 +586,11 @@
% \begin{macrocode}
\def\verso@processonepage{
\if@verso@processversonotes
- \expandafter\verso@processonepage@\the\verso@pages{}{}\@nil
+ \expandafter\verso@processonepage@\the\verso@pages\@nil
\else
- % we don't seem to have any versonotes in this file: don't come here again
+% \end{macrocode}
+% We don't seem to have any versonotes in this file, so don't come here again.
+% \begin{macrocode}
\global\let\verso@processonepage\relax
\fi
}
@@ -510,7 +601,6 @@
\def\shipout{\verso@processonepage \verso@orig@shipout}
% \end{macrocode}
%
-% That's all.
% \begin{macrocode}
%</package>
% \end{macrocode}