summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/oberdiek/atveryend.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/source/latex/oberdiek/atveryend.dtx')
-rw-r--r--Master/texmf-dist/source/latex/oberdiek/atveryend.dtx265
1 files changed, 209 insertions, 56 deletions
diff --git a/Master/texmf-dist/source/latex/oberdiek/atveryend.dtx b/Master/texmf-dist/source/latex/oberdiek/atveryend.dtx
index a08a5bd6e10..f5415033cdd 100644
--- a/Master/texmf-dist/source/latex/oberdiek/atveryend.dtx
+++ b/Master/texmf-dist/source/latex/oberdiek/atveryend.dtx
@@ -1,7 +1,7 @@
% \iffalse meta-comment
-%
+%
% Copyright (C) 2009 by Heiko Oberdiek <oberdiek@uni-freiburg.de>
-%
+%
% 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
@@ -9,20 +9,20 @@
% 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".
-%
+%
% This Current Maintainer of this work is Heiko Oberdiek.
-%
+%
% This work consists of the main source file atveryend.dtx
% and the derived files
% atveryend.sty, atveryend.pdf, atveryend.ins, atveryend.drv,
% atveryend-test1.tex.
-%
+%
% Distribution:
% CTAN:macros/latex/contrib/oberdiek/atveryend.dtx
% CTAN:macros/latex/contrib/oberdiek/atveryend.pdf
-%
+%
% Unpacking:
% (a) If atveryend.ins is present:
% tex atveryend.ins
@@ -31,7 +31,7 @@
% (c) If you insist on using LaTeX
% latex \let\install=y\input{atveryend.dtx}
% (quote the arguments according to the demands of your shell)
-%
+%
% Documentation:
% (a) If atveryend.drv is present:
% latex atveryend.drv
@@ -41,14 +41,14 @@
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
-%
+%
% Programm calls to get the documentation (example):
% pdflatex atveryend.dtx
% makeindex -s gind.ist atveryend.idx
% pdflatex atveryend.dtx
% makeindex -s gind.ist atveryend.idx
% pdflatex atveryend.dtx
-%
+%
% Installation:
% TDS:tex/generic/oberdiek/atveryend.sty
% TDS:doc/latex/oberdiek/atveryend.pdf
@@ -68,7 +68,7 @@
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
-\Msg{* Package: atveryend 2009/12/09 v1.2 Hooks at very end of document (HO)}
+\Msg{* Package: atveryend 2009/12/11 v1.3 Hooks at very end of document (HO)}
\Msg{************************************************************************}
\keepsilent
@@ -137,7 +137,7 @@ and the derived files
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{atveryend.drv}%
- [2009/12/09 v1.2 Hooks at very end of document (HO)]%
+ [2009/12/11 v1.3 Hooks at very end of document (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2008/08/11]
\begin{document}
@@ -146,7 +146,7 @@ and the derived files
%</driver>
% \fi
%
-% \CheckSum{791}
+% \CheckSum{966}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
@@ -167,7 +167,7 @@ and the derived files
% \GetFileInfo{atveryend.drv}
%
% \title{The \xpackage{atveryend} package}
-% \date{2009/12/09 v1.2}
+% \date{2009/12/11 v1.3}
% \author{Heiko Oberdiek\\\xemail{oberdiek@uni-freiburg.de}}
%
% \maketitle
@@ -201,8 +201,16 @@ and the derived files
% that only work properly if they can reach the point after the
% last shipout.
%
-% Therefore the task of this package is to provide two hooks
-% that are called after the last page is shipped out:
+% Therefore the task of this package is to provide additional
+% hooks for |\end{document}|. All hooks are called after
+% the hook of \cs{AtEndDocument}.
+% \begin{declcs}{BeforeClearDocument} \M{code}
+% \end{declcs}
+% The code is called before the final \cs{clearpage} in
+% \cs{enddocument}. However it is unknown, whether the last
+% page is already shipped out or if this will be triggered by the
+% final \cs{clearpage}.
+%
% \begin{declcs}{AfterLastShipout} \M{code}
% \end{declcs}
% The code is called after the final \cs{clearpage} of \cs{enddocument}
@@ -317,7 +325,7 @@ and the derived files
\fi
\expandafter\x\csname ver@atveryend.sty\endcsname
\ProvidesPackage{atveryend}%
- [2009/12/09 v1.2 Hooks at very end of document (HO)]
+ [2009/12/11 v1.3 Hooks at very end of document (HO)]
% \end{macrocode}
%
% \begin{macrocode}
@@ -355,10 +363,16 @@ and the derived files
\TMP@EnsureCode{61}{12}% =
\TMP@EnsureCode{62}{12}% >
\TMP@EnsureCode{96}{12}% `
+\g@addto@macro{\AtVeryEnd@AtEnd}{\endinput}%
% \end{macrocode}
%
% \subsection{Hooks}
%
+% \begin{macro}{\AtVeryEnd@BeforeClearDocumentHook}
+% \begin{macrocode}
+\let\AtVeryEnd@BeforeClearDocumentHook\@empty
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\AtVeryEnd@AfterLastShipoutHook}
% \begin{macrocode}
\let\AtVeryEnd@AfterLastShipoutHook\@empty
@@ -369,6 +383,13 @@ and the derived files
\let\AtVeryEnd@AtVeryEndDocumentHook\@empty
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\BeforeClearDocument}
+% \begin{macrocode}
+\newcommand*{\BeforeClearDocument}{%
+ \g@addto@macro\AtVeryEnd@BeforeClearDocumentHook
+}
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\AfterLastShipout}
% \begin{macrocode}
\newcommand*{\AfterLastShipout}{%
@@ -383,6 +404,21 @@ and the derived files
}
% \end{macrocode}
% \end{macro}
+% \begin{macro}{\Call@BeforeClearDocument}
+% \begin{macrocode}
+\newcommand*{\Call@BeforeClearDocument}{%
+ \let\BeforeClearDocument\@firstofone
+ \ifx\AtVeryEnd@BeforeClearDocumentHook\@empty
+ \PackageInfo{atveryend}{Empty hook `BeforeClearDocument'}%
+ \else
+ \PackageInfo{atveryend}{Executing hook `BeforeClearDocument'}%
+ \AtVeryEnd@AfterLastShipoutHook
+ \fi
+ \global\let\AtVeryEnd@BeforeClearDocumentHook\@undefined
+ \global\let\Call@BeforeClearDocument\relax
+}
+% \end{macrocode}
+% \end{macro}
% \begin{macro}{\Call@AfterLastShipout}
% \begin{macrocode}
\newcommand*{\Call@AfterLastShipout}{%
@@ -468,6 +504,7 @@ and the derived files
\let\AtEndDocument\@firstofone
\@enddocumenthook
\@checkend{document}%
+ \Call@BeforeClearDocument
\clearpage
\Call@AfterLastShipout
\begingroup
@@ -550,6 +587,7 @@ and the derived files
% \begin{macrocode}
\def\AtVeryEnd@enddocument@dinbrief{%
\@checkend{document}%
+ \Call@BeforeClearDocument
\newpage
\Call@AfterLastShipout
\begingroup
@@ -600,6 +638,7 @@ and the derived files
\def\AtVeryEnd@enddocument@combine{%
\@enddocumenthook
\@checkend{document}%
+ \Call@BeforeClearDocument
\clearpage
\Call@AfterLastShipout
\begingroup
@@ -660,6 +699,7 @@ and the derived files
\global\let\@outputdblcol=\balancing@outputdblcol
\fi
\@checkend{document}%
+ \Call@BeforeClearDocument
\clearpage
\Call@AfterLastShipout
\begingroup
@@ -762,44 +802,37 @@ and the derived files
% \subsubsection{Package \xpackage{etoolbox}}
%
% \begin{macrocode}
-\AtBeginDocument{%
\@ifpackageloaded{etoolbox}{%
\@ifundefined{AfterEndDocument}{}{%
\AfterEndDocument{\Call@AtVeryEndDocument}%
}%
}{}%
-}
% \end{macrocode}
%
% \subsection{Hack into \cs{enddocument}}
%
-% Class \xclass{revtex} provides ``hook'' \cs{clear@document}.
% \begin{macrocode}
- \begingroup\expandafter\expandafter\expandafter\endgroup
- \expandafter\ifx\csname clear@document\endcsname\relax
- \def\AtVeryEnd@document{document}%
- \def\AtVeryEnd@RedefCheckend{%
- \expandafter\def\expandafter\@checkend
- \expandafter##\expandafter1\expandafter{%
- \@checkend{##1}%
- \def\AtVeryEnd@temp{##1}%
- \ifx\AtVeryEnd@temp\AtVeryEnd@document
- \let\AtVeryEnd@OrgClearpage\clearpage
- \def\clearpage{%
- \let\clearpage\AtVeryEnd@OrgClearpage
- \clearpage
- \Call@AfterLastShipout
- }%
- \fi
- }%
- \aftergroup\AtVeryEnd@RedefCheckend
- }%
- \AtEndDocument{%
- \AtVeryEnd@RedefCheckend
+ \def\AtVeryEnd@document{document}%
+ \def\AtVeryEnd@RedefCheckEnd{%
+ \expandafter\def\expandafter\@checkend
+ \expandafter##\expandafter1\expandafter{%
+ \@checkend{##1}%
+ \def\AtVeryEnd@temp{##1}%
+ \ifx\AtVeryEnd@temp\AtVeryEnd@document
+ \let\AtVeryEnd@OrgClearpage\clearpage
+ \def\clearpage{%
+ \let\clearpage\AtVeryEnd@OrgClearpage
+ \Call@BeforeClearDocument
+ \clearpage
+ \Call@AfterLastShipout
+ }%
+ \fi
}%
- \else
- \g@addto@macro\clear@document{\Call@AfterLastShipout}%
- \fi
+ \aftergroup\AtVeryEnd@RedefCheckEnd
+ }%
+ \AtEndDocument{%
+ \AtVeryEnd@RedefCheckEnd
+ }%
}
% \end{macrocode}
%
@@ -819,6 +852,116 @@ and the derived files
}
% \end{macrocode}
%
+% \subsection{Class \xclass{letter}}
+%
+% The class \xclass{letter} and some similar classes
+% insert material (\cs{@startlabels}) at the end of the document.
+% However, this method violates
+% a precondition of this package that the \cs{clearpage} in
+% \cs{enddocument} is the final call with no material at
+% later times. Therefore we move the label making
+% from the \xext{.aux} file to \cs{AtEndDocument}.
+% \begin{macrocode}
+\def\AtVeryEnd@temp{%
+ \AtBeginDocument{%
+ \let\@startlabels\startlabels
+ \let\@mlabel\mlabel
+ \if@filesw
+ \immediate\write\@mainaux{\string\@startlabels}%
+ \fi
+ }%
+ \AtEndDocument{%
+ \if@filesw
+ \immediate\write\@mainaux{\string\clearpage}%
+ \fi
+ }%
+}
+\ifx\makelabels\AtVeryEnd@temp
+\else
+ \expandafter\AtVeryEnd@AtEnd
+\fi
+\let\AtVeryEnd@PatchLetter=N%
+\begingroup\expandafter\expandafter\expandafter\endgroup
+\expandafter\ifx\csname endletter\endcsname\relax
+\else
+ \long\def\AtVeryEnd@TestEndLetter#1\@auxout#2#3\AtVeryEnd@Nil{%
+ \def\AtVeryEnd@temp{#2}%
+ \ifx\AtVeryEnd@temp\@empty
+ \else
+ \@onelevel@sanitize\AtVeryEnd@temp
+ \edef\AtVeryEnd@StringMlabel{%
+ \string\string
+ \string\@mlabel
+ \expandafter\@gobble\string\{%
+ }%
+ \def\AtVeryEnd@CatchFirst##1##2##3##4##5##6##7##8{%
+ ##1##2##3##4##5##6##7##8\AtVeryEnd@CatchSecond
+ }%
+ \def\AtVeryEnd@CatchSecond##1##2##3##4##5##6##7##8##9\@nil{%
+ ##1##2##3##4##5##6##7##8%
+ }%
+ \edef\AtVeryEnd@temp{%
+ \expandafter\AtVeryEnd@CatchFirst\AtVeryEnd@temp
+ {}{}{}{}{}{}{}{}%
+ {}{}{}{}{}{}{}{}%
+ \@nil
+ }%
+ \ifx\AtVeryEnd@temp\AtVeryEnd@StringMlabel
+ \expandafter\def\expandafter\endletter\expandafter{%
+ \endletter
+ \begingroup
+ \let\\=\relax
+ \let\protect\@unexpandable@protect
+ \let\@mlabel=\relax
+ \edef\x{\endgroup
+ \noexpand\AtEndDocument{%
+ \@gobble#2%
+ }%
+ }%
+ \x
+ }%
+ \let\AtVeryEnd@PatchLetter=Y%
+ \fi
+ \fi
+ }%
+ \expandafter\AtVeryEnd@TestEndLetter\endletter
+ \@auxout{}\AtVeryEnd@Nil
+\fi
+\ifx\AtVeryEnd@PatchLetter Y%
+ \begingroup
+ \let\on@line\@empty
+ \PackageInfo{atveryend}{%
+ \@backslashchar makelabels detected. %
+ Moving labels\MessageBreak
+ from `.aux' file to \@backslashchar AtEndDocument%
+ }%
+ \endgroup
+ \def\makelabels{%
+ \AtBeginDocument{%
+ \let\@startlabels\startlabels
+ \let\@mlabel\mlabel
+ }%
+ }%
+ \AtEndDocument{%
+ \@ifundefined{@startlabels}{%
+ }{%
+ \clearpage
+ \@startlabels
+ }%
+ }%
+ \AfterLastShipout{%
+ \let\@startlabels\relax
+ \let\@mlabel\@gobbletwo
+ }%
+\else
+ \PackageWarningNoLine{atveryend}{%
+ \@backslashchar makelabels detected, but labels cannot\MessageBreak
+ be moved to \@backslashchar AtEndDocument, because\MessageBreak
+ \@backslashchar endletter is not in expected form%
+ }%
+\fi
+% \end{macrocode}
+%
% \begin{macrocode}
\AtVeryEnd@AtEnd
%</package>
@@ -1096,57 +1239,57 @@ and the derived files
% \end{quote}
%
% \section{Acknowledgement}
-%
+%
% \begin{description}
-% \item[Arthur Ogawa:] He proposed the new API with \cs{AfterLastShipout}.
-% For version 1.2 he provided a comprehensive class/package list that
-% deal with \cs{enddocument}.
+% \item[Arthur Ogawa:] He proposed the new API with \cs{AfterLastShipout}
+% and gave me much feedback, comprehensive class/package lists, many
+% suggestions and comments.
% \end{description}
%
% \begin{thebibliography}{9}
-%
+%
% \bibitem{clsguide}
% The \LaTeX3 Project:
% \textit{\LaTeX2e\ for class and package writers}
% 2006/02/15;
% \CTAN{macros/latex/doc/clsguide.pdf}.
-%
+%
% \bibitem{endfloat}
% James Darrell McCauley, Jeff Goldberg:
% \textit{The \xpackage{endfloat} package};
% 1995/10/11 v2.4i;
% \CTAN{macros/latex/contrib/endfloat/endfloat.pdf}.
-%
+%
% \bibitem{etoolbox}
% Philipp Lehmann:
% \textit{The \xpackage{etoolbox} package};
% 2009/08/06 v1.8;
% \CTAN{macros/latex/contrib/etoolbox/etoolbox.pdf}.
-%
+%
% \bibitem{hyperref}
% Sebastian Rahtz, Heiko Oberdiek:
% \textit{The \xpackage{hyperref} package};
% 2009/12/05 v6.79l;
% \CTAN{macros/latex/contrib/hyperref/}.
-%
+%
% \bibitem{koma}
% Markus Kohm:
% \textit{KOMA-Script};
% 2009/07/24 v3.04a;
% \url{http://www.komascript.de/}.
-%
+%
% \bibitem{lastpage}
% Jeff Goldberg:
% \textit{The \xpackage{lastpage} package};
% 1994/07/20 v0.1b;
% \CTAN{macros/latex/contrib/lastpage/lastpage.pdf}.
-%
+%
% \bibitem{revtex}
% APS, AIP, Arthur Orgawa;
% ReVTeX 4.1;
% 2009/10/13 v4.1;
% \url{http://authors.aps.org/revtex4/}.
-%
+%
% \end{thebibliography}
%
% \begin{History}
@@ -1162,6 +1305,16 @@ and the derived files
% \item
% Additional support of classes and packages.
% \end{Version}
+% \begin{Version}{2009/12/11 v1.3}
+% \item
+% Patch for letter like classes that puts label into the `.aux' file.
+% \item
+% Hook \cs{BeforeClearDocument} added (request from Arthur Ogawa).
+% \item
+% Patch of \cs{clear@document} removed (Arthur Ogawa).
+% \item
+% A nested \cs{AtBeginDocument} removed.
+% \end{Version}
% \end{History}
%
% \PrintIndex