From 8b5866024fec68c13a91973cc6cfc2cb5697baba Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 8 May 2020 03:02:15 +0000 Subject: CTAN sync 202005080302 --- macros/latex/contrib/marginfix/marginfix.dtx | 98 +++++++++++++++------------- 1 file changed, 54 insertions(+), 44 deletions(-) (limited to 'macros/latex/contrib/marginfix/marginfix.dtx') diff --git a/macros/latex/contrib/marginfix/marginfix.dtx b/macros/latex/contrib/marginfix/marginfix.dtx index 1e7b43ea06..914f95b96d 100644 --- a/macros/latex/contrib/marginfix/marginfix.dtx +++ b/macros/latex/contrib/marginfix/marginfix.dtx @@ -12,10 +12,10 @@ % %\NeedsTeXFormat{LaTeX2e} %\ProvidesPackage{marginfix}% - [2013/09/08 v1.1 Fix Margin Paragraphs] + [2020/05/06 v1.2 Fix Margin Paragraphs] %<*driver> \documentclass{ltxdoc} -\CheckSum{1197} +\CheckSum{1159} %\OnlyDescription % (un)comment this line to show (hide) source code \RecordChanges \EnableCrossrefs @@ -70,6 +70,9 @@ % {(SDH) Globally calculate margin phantoms over 4 passes.} % \changes{v1.1}{2013/09/08} % {(SDH) Add \cs{topskip} to notes at the top of the margin.} +% \changes{v1.2}{2020/05/06} +% {(SDH) Fix long-standing bug where margin notes called out in +% the last few points of a page were being entirely dropped.} % % \GetFileInfo{marginfix.dtx} % \title{\Lopt{marginfix} package documentation} @@ -225,8 +228,7 @@ % \begin{macros}{\MFX@debug} % We have some optionally-included code for debugging. \cs{MFX@debug} % prints a new line followed by ``|MFX: |'' and then the message. -% The newline can be suppressed with a |*|. We'll also ask for more -% error context in the debug mode. +% We'll also ask for more error context in the debug mode. % \begin{macrocode} %<*debug> \def\MFX@debug{\message{^^JMFX:}\message} @@ -234,8 +236,6 @@ \def\MFX@mac#1{\expandafter\MFX@@mac\meaning#1>>>} \def\MFX@@mac#1->{<<<} \def\MFX@htdp#1{\ht#1=\the\ht#1, \dp#1=\the\dp#1} -\showboxbreadth=100 -\showboxdepth=10 % % \end{macrocode} % \end{macros} @@ -511,11 +511,11 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@cons,\MFX@snoc,\MFX@run@clear} +% \begin{macros}{\MFX@cons,\MFX@snoc} % In passing we'll define the cons macro, which fully-expands % its second argument, but makes sure to only expand the first % one once, so that any fragile control sequences in it are -% corectly protected. We also define snoc, which prepends. +% correctly protected. We also define snoc, which prepends. % Note that we could put the \cs{temp@} definition into a group % if it was really gonna matter\ldots % \begin{macrocode} @@ -533,6 +533,9 @@ \expandafter\expandafter\expandafter{\expandafter\temp@#1}% } % \end{macrocode} +% \end{macros} +% +% \begin{macros}{\MFX@run@clear} % Finally, \cs{MFX@run@clear} is a quick trick to expand the % contents of a macro and then clear it (to \cs{@empty}) before % any of its tokens are consumed. @@ -602,7 +605,7 @@ % \end{macros} % % \section{Shipout-time patches} -% \begin{macros}{\@combinefloats,\MFX@combinefloats@before} +% \begin{macros}{\@combinefloats} % We need to patch in somewhere before \cs{@combinefloats} at the latest, % so that any heights calculated from \cs{@pageht} are correct---otherwise % the top figures will confuse us. So we'll start by simply adding our @@ -611,7 +614,9 @@ \expandafter\def\expandafter\@combinefloats\expandafter{\expandafter \MFX@combinefloats@before\@combinefloats} % \end{macrocode} -% +% \end{macros} +% +% \begin{macros}{\MFX@combinefloats@before} % \cs{MFX@combinefloats@before} is then responsible for picking the % needed notes from \cs{mfx@marginlist}, building them into a box, and % attaching that box onto the correct side of \cs{@outputbox}. We also @@ -636,25 +641,11 @@ \def\MFX@attachmargin{% %\MFX@debug{attachmargin}% % \end{macrocode} -% First, we need to make sure that the boxes we're combining are the -% same size. +% We start by moving the reference point of \cs{Mfx@marginbox} to the top. % \begin{macrocode} %\MFX@debug{attachmargin: \MFX@htdp\@outputbox, \MFX@htdp\Mfx@marginbox}% - %\showbox\@outputbox - %\showbox\Mfx@marginbox \setbox\Mfx@marginbox\vtop{% \vskip\z@\unvbox\Mfx@marginbox}% - %% \ifdim\ht\@outputbox<\ht\Mfx@marginbox - %% \setbox\Mfx@marginbox\vbox to \ht\@outputbox{% - %% \unvbox\Mfx@marginbox - %% \vskip\z@ shrink 1filll\relax - %% }% - %% \else - %% \setbox\Mfx@marginbox\vbox to \ht\@outputbox{% - %% \unvbox\Mfx@marginbox - %% \vfill - %% }% - %% \fi % \end{macrocode} % Next we need to figure out which side of \cs{@outputbox} to attach % the \cs{Mfx@marginbox} on. We now use \cs{columnwidth} instead of @@ -665,10 +656,10 @@ % might have unintended consequences w.r.t. any glue being retained that % should have been swallowed. This will require further investigation. % \begin{macrocode} - \setbox\@outputbox\vbox{% to \ht\@outputbox{% + \setbox\@outputbox\vbox{% \begingroup - \setbox\@tempboxa\vbox{% to \ht\@outputbox{% - \hbox{% to \wd\@outputbox{% + \setbox\@tempboxa\vbox{% + \hbox{% \if\MFX@leftmargin \llap{\box\Mfx@marginbox\hskip\marginparsep}% \else @@ -683,7 +674,6 @@ \unskip \unvbox\@outputbox }% - %\showbox\@outputbox } % \end{macrocode} % \end{macros} @@ -704,7 +694,7 @@ % line up the notes with their callouts). This procedure happens in % four passes. But first, we initialize \cs{Mfx@marginheight} to % \cs{@colroom}, which is the height of the page minus any floats that -% have been added to the top of bottom (these floats may extend into the +% have been added to the top or bottom (these floats may extend into the % margins: in the future we may look into detecting this and using the % whole page, with overwide floats blocked off as phantoms). We add % \cs{@colroom} rather than assigning it because any global or per-page @@ -794,12 +784,10 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@margin@note@down,\MFX@margin@skip@down, -% \MFX@margin@clear@down} % We now define the various |\MFX@margin@...@down| macros. % At this stage in the game, the only difference between notes % and skips is that we ignore skips before any notes by setting -% \cs{mfx@build@note} initially to \cs{@gobble}. Once we've +% \cs{mfx@build@skip} initially to \cs{@gobble}. Once we've % seen the first note, skips are treated exactly the same: as % fixed-height material. If there is room in the current piece % for the given height, then we prepend it to \cs{mfx@marginout}, @@ -808,6 +796,7 @@ % \cs{mfx@pieceheights} and try again, until \cs{mfx@pieceheights} % is empty and we simply defer everything to later pages. % +% \begin{macros}{\MFX@margin@note@down} % Upon seeing a note, we must do several things: % \begin{enumerate} % \item determine which box (left or right) is needed for the @@ -836,7 +825,9 @@ \fi } % \end{macrocode} +% \end{macros} % +% \begin{macros}{\MFX@margin@skip@down} % Skips are similar. A skip needs only to save itself back into % \cs{mfx@marginout}, provided it fits. If not, there is no need % to defer it because it will just get gobbled at the top of the @@ -851,7 +842,9 @@ \fi } % \end{macrocode} +% \end{macros} % +% \begin{macros}{\MFX@margin@clear@down} % Finally, \cs{MFX@margin@clear@down} is the only place we actually % need to handle full-margin clears, since the downward pass does not % ever push \cs{mfx@build@clear} onto \cs{mfx@marginout}. When we @@ -870,7 +863,7 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@check@fit,\MFX@popdimen} +% \begin{macros}{\MFX@check@fit} % We factored out some of the common functionality between the % note and skip routines, so that must now be defined. The % \cs{MFX@check@fit} macro acts as a conditional and should be @@ -901,6 +894,8 @@ \if@tempswa % start a new \if } % \end{macrocode} +% \end{macros} +% \begin{macros}{\MFX@popdimen} % Here is a quick convenience routine. \cs{MFX@popdimen}\marg{dimen}% % \marg{list} removes the first dimension from \emph{list} and stores % it into \emph{dimen}. @@ -917,7 +912,7 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@whichbox,\MFX@leftmargin} +% \begin{macros}{\MFX@whichbox} % We also need to determine which box should be used, since they % may have different heights. The macro \cs{MFX@whichbox}% % \marg{target-box}\marg{left-box}\marg{right-box} checks which margin @@ -933,9 +928,11 @@ %\MFX@debug{whichbox: \@marbox (\the\dimexpr\ht#1+\dp#1)}% } % \end{macrocode} +% \end{macros} % -% And here is the logic to figure out which margin were in, based -% on the page number and other flags. This is another conditional-like +% \begin{macros}{\MFX@leftmargin} +% And here is the logic to figure out which margin we're in, based on +% the page number and other flags. This is another conditional-like % macro, and should be used after an \cs{if}, as in % \cs{if}\cs{MFX@leftmargin}\ldots\cs{else}\ldots\cs{fi}. % @@ -1022,7 +1019,7 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@margin@note@up,\MFX@margin@skip@up} +% \begin{macros}{\MFX@margin@note@up} % We must again define the specific behavior of each build command. % These macros simply reuse \cs{MFX@check@fit}, but ask it to % decrement the piece counter when a piece runs out of space. @@ -1045,7 +1042,7 @@ % look for a piece that can fit this note, making sure to decrement % the piece count and pop off a phantom for each new piece we check. % Once it's found, we add the note back to \cs{mfx@marginout} with -% the corect piece. +% the correct piece. % \begin{macrocode} \if\MFX@check@fit{\advance\Mfx@piece@count\m@ne \MFX@popdimen\dimen@\mfx@phantomheights}{\ht#1+\dp#1}% @@ -1055,6 +1052,9 @@ \else\MFX@AssertionError\fi } % \end{macrocode} +% \end{macros} +% +% \begin{macros}{\MFX@margin@skip@up} % Skips are similar, but we have the added complication of handling % margin phantoms. When we cross between phantom and piece, we split % the skip so that we can use the simplest recursion possible. @@ -1095,7 +1095,7 @@ % \end{macros} % % \subsection{Margin pieces} -% \begin{macros}{\MFX@buildmargin@pieces,\MFX@buildmargin@piece} +% \begin{macros}{\MFX@buildmargin@pieces} % Before we can start the third and fourth passes, we need to set up % a loop over the pieces so that each piece can do these passes at % one time. In case we didn't use up all the pieces in the second @@ -1114,10 +1114,12 @@ \let\@elt\MFX@buildmargin@piece \MFX@run@clear\mfx@marginpieces \let\@elt\relax - \Mfx@piece@count\z@ + \global\Mfx@piece@count\z@ } % \end{macrocode} +% \end{macros} % +% \begin{macros}{\MFX@buildmargin@piece} % The \cs{MFX@buildmargin@piece} macro is called for each piece of % the margin, and is passed the top and bottom positions of the piece. % Here we need to do a few things. First, if the output so far is @@ -1185,7 +1187,7 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@piece@note@down,\MFX@piece@skip@down,\MFX@piece@clear} +% \begin{macros}{\MFX@piece@note@down} % We again define each of our building macros. First, the note builder. % When we encounter a note, we first zero out \cs{Mfx@marginspace}. Then % we need to decide whether to put it in the current piece, or whether @@ -1261,7 +1263,9 @@ \fi } % \end{macrocode} +% \end{macros} % +% \begin{macros}{\MFX@piece@skip@down} % Skips are a bit more complicated now. We no longer gobble the % initial skips (since the skips at the top and bottom of the page % have already been eaten). Instead, we need to look at @@ -1301,7 +1305,9 @@ \fi } % \end{macrocode} +% \end{macros} % +% \begin{macros}{\MFX@piece@clear} % Finally, we need to handle the case of deferring material. By % analogy with the previous two passes, we'll continue to refer to % this as clearing. In this case, we need to redefine the note and @@ -1365,7 +1371,7 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\MFX@piece@note@up,\MFX@piece@skip@up} +% \begin{macros}{\MFX@piece@note@up} % Now that we've taken care of late deferrals, we can define the % standard behavior without worrying as much about that. % These macros finally set their contents into \cs{Mfx@piece@content}, @@ -1379,6 +1385,8 @@ \let\mfx@build@skip\MFX@piece@skip@up } % \end{macrocode} +% \end{macros} +% \begin{macros}{\MFX@piece@skip@up} % Skips are also straightforward. % \begin{macrocode} \def\MFX@piece@skip@up#1#2{% @@ -1451,13 +1459,15 @@ % \end{macrocode} % \end{macros} % -% \begin{macros}{\clearmargin,\softclearmargin} +% \begin{macros}{\clearmargin} % Likewise, \cs{clearmargin} is easy too. % \begin{macrocode} \def\clearmargin{% \MFX@cons\mfx@marginlist{\noexpand\mfx@build@clear}% } % \end{macrocode} +% \end{macros} +% \begin{macros}{\softclearmargin} % While we call \cs{softclearmargin} a ``clear margin'', it's % actually just a big \cs{marginskip}. This allows us to stack % multiple copies without backing them all up. -- cgit v1.2.3