From ab45728245c1e07608202ff15953b97a9d3232b0 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 17 Feb 2017 22:27:22 +0000 Subject: footnotehyper (17feb17) git-svn-id: svn://tug.org/texlive/trunk@43260 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/doc/latex/footnotehyper/README.md | 42 +- .../doc/latex/footnotehyper/footnotehyper.pdf | Bin 51992 -> 55993 bytes .../doc/latex/footnotehyper/footnotehyper.tex | 10 +- .../source/latex/footnotehyper/footnotehyper.dtx | 903 ++++++++++++--------- .../source/latex/footnotehyper/footnotehyper.ins | 10 +- .../tex/latex/footnotehyper/footnotehyper.sty | 343 ++++---- 6 files changed, 777 insertions(+), 531 deletions(-) (limited to 'Master') diff --git a/Master/texmf-dist/doc/latex/footnotehyper/README.md b/Master/texmf-dist/doc/latex/footnotehyper/README.md index cfde8ea26ae..8df5b6f5a18 100644 --- a/Master/texmf-dist/doc/latex/footnotehyper/README.md +++ b/Master/texmf-dist/doc/latex/footnotehyper/README.md @@ -1,31 +1,35 @@ - Source: footnotehyper.dtx (v0.9f 2016/10/03) + Source: footnotehyper.dtx (v0.99 2017/02/16) Author: Jean-Francois Burnol Info: hyperref aware footnote.sty License: LPPL 1.3c - Copyright (C) 2016 Jean-Francois Burnol . + Copyright (C) 2016-2017 Jean-Francois Burnol . ABSTRACT ======== -The `footnote` package by Mark Wooding (which dates back to 1997) -allows to gather footnotes (`\savenotes`) and later insert them -(`\spewnotes`) at the bottom of the page, even if the intervening -material consists of tabulars, minipages or framed contents for -example. There is a command to patch any given environment to do -the `\savenotes/\spewnotes` commands automatically. Also there is -a `footnote` environment which allows to insert verbatim material. - -The `footnotehyper` package loads `footnote.sty` and rewrites a -number of its commands to add `hyperref` awareness and to fix some -issues, particularly the one of incompatibility with -`color/xcolor`. The incompatibility with `babel-frenchb` is -addressed, too. In case of absence of `hyperref`, `footnotehyper` -limits itself to partially fix some of these issues. - -This package provides no facility dedicated to footnotes from -floating environments. +The `footnote` package by Mark Wooding (`1997/01/28` `1.13`) +allows to gather footnotes (`\begin{savenotes}`) and later insert +them (after `\end{savenotes}`) at the bottom of the page, even +if the intervening material consists of tabulars, minipages or +framed contents for example. One can also use the +`\savenotes/\spewnotes` syntax. + +Also, `footnote.sty` provides a `footnote` environment which +allows to insert verbatim material. + +Earlier releases of the present `footnotehyper` package added +patches for `hyperref` compatibility and some bugfixes, addressing +in particular the incompatibility with `color/xcolor`, and with +`babel-frenchb`, and also fixing the `footnote` environment with +optional argument `[NUM]`. Since `v0.99` all macros are defined +internally and the `footnote` package is not loaded at all. + +The same user interface is kept. In case `hyperref` is absent, or +is loaded with `hyperfootnotes=false` option, `footnotehyper` +deactivates itself. The order of loading of `footnotehyper` +and `hyperref` is inconsequential. INSTALLATION ============ diff --git a/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.pdf b/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.pdf index 72ab33caaf2..80442e5da70 100644 Binary files a/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.pdf and b/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.pdf differ diff --git a/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.tex b/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.tex index f406325276b..a7fca493913 100644 --- a/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.tex +++ b/Master/texmf-dist/doc/latex/footnotehyper/footnotehyper.tex @@ -1,13 +1,13 @@ %% %% Package: footnotehyper -%% Version: 0.9f (2016/10/03) +%% Version: 0.99 (2017/02/16) %% License: LPPL 1.3c -%% Copyright (C) 2016 Jean-Francois Burnol . +%% Copyright (C) 2016-2017 Jean-Francois Burnol . %% \def\pkgname {footnotehyper} -\def\pkgdate {2016/10/03} -\def\docdate {2016/10/03} -\def\pkgversion {v0.9f} +\def\pkgdate {2017/02/16} +\def\docdate {2017/02/16} +\def\pkgversion {v0.99} \def\pkgdescription {hyperref aware footnote.sty (JFB)} %% %% run latex twice on this file footnotehyper.tex then dvipdfmx on diff --git a/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.dtx b/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.dtx index 1af5bf01999..7be238bfe42 100644 --- a/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.dtx +++ b/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.dtx @@ -1,20 +1,20 @@ % -*- coding: utf-8; time-stamp-format: "%02d-%02m-%:y at %02H:%02M:%02S %Z" -*- %<*none> -\def\dtxtimestamp {Time-stamp: <03-10-2016 at 23:00:16 CEST>} +\def\dtxtimestamp {Time-stamp: <16-02-2017 at 20:01:27 CET>} % %<*!readme> %% %% Package: footnotehyper -%% Version: 0.9f (2016/10/03) +%% Version: 0.99 (2017/02/16) %% License: LPPL 1.3c -%% Copyright (C) 2016 Jean-Francois Burnol . +%% Copyright (C) 2016-2017 Jean-Francois Burnol . %% % %<*insfile|tex> \def\pkgname {footnotehyper} -\def\pkgdate {2016/10/03} -\def\docdate {2016/10/03} -\def\pkgversion {v0.9f} +\def\pkgdate {2017/02/16} +\def\docdate {2017/02/16} +\def\pkgversion {v0.99} \def\pkgdescription {hyperref aware footnote.sty (JFB)} % %<*none> @@ -25,9 +25,9 @@ \catcode32=13\catcode`\\=12^^Brelax^^A ^^Bfirstofone{^^Bendgroup^^Bdef^^BpkgLicense^^A {% Package: footnotehyper -% Version: 0.9f (2016/10/03) +% Version: 0.99 (2017/02/16) % License: LPPL 1.3c -% Copyright (C) 2016 Jean-Francois Burnol . +% Copyright (C) 2016-2017 Jean-Francois Burnol . % % This Work may be distributed and/or modified under the conditions % of the LaTeX Project Public License, version 1.3c. This version of @@ -54,33 +54,37 @@ %<*readme> - Source: footnotehyper.dtx (v0.9f 2016/10/03) + Source: footnotehyper.dtx (v0.99 2017/02/16) Author: Jean-Francois Burnol Info: hyperref aware footnote.sty License: LPPL 1.3c - Copyright (C) 2016 Jean-Francois Burnol . + Copyright (C) 2016-2017 Jean-Francois Burnol . ABSTRACT ======== -The `footnote` package by Mark Wooding (which dates back to 1997) -allows to gather footnotes (`\savenotes`) and later insert them -(`\spewnotes`) at the bottom of the page, even if the intervening -material consists of tabulars, minipages or framed contents for -example. There is a command to patch any given environment to do -the `\savenotes/\spewnotes` commands automatically. Also there is -a `footnote` environment which allows to insert verbatim material. +The `footnote` package by Mark Wooding (`1997/01/28` `1.13`) +allows to gather footnotes (`\begin{savenotes}`) and later insert +them (after `\end{savenotes}`) at the bottom of the page, even +if the intervening material consists of tabulars, minipages or +framed contents for example. One can also use the +`\savenotes/\spewnotes` syntax. -The `footnotehyper` package loads `footnote.sty` and rewrites a -number of its commands to add `hyperref` awareness and to fix some -issues, particularly the one of incompatibility with -`color/xcolor`. The incompatibility with `babel-frenchb` is -addressed, too. In case of absence of `hyperref`, `footnotehyper` -limits itself to partially fix some of these issues. +Also, `footnote.sty` provides a `footnote` environment which +allows to insert verbatim material. -This package provides no facility dedicated to footnotes from -floating environments. +Earlier releases of the present `footnotehyper` package added +patches for `hyperref` compatibility and some bugfixes, addressing +in particular the incompatibility with `color/xcolor`, and with +`babel-frenchb`, and also fixing the `footnote` environment with +optional argument `[NUM]`. Since `v0.99` all macros are defined +internally and the `footnote` package is not loaded at all. + +The same user interface is kept. In case `hyperref` is absent, or +is loaded with `hyperfootnotes=false` option, `footnotehyper` +deactivates itself. The order of loading of `footnotehyper` +and `hyperref` is inconsequential. INSTALLATION @@ -184,7 +188,7 @@ footnotehyper.pdf, footnotehyper.dvi. \Msg{* To finish the installation you have to move the following} \Msg{* file into a directory searched by TeX:} \Msg{*} -\Msg{* \pkgname.sty} +\Msg{* \pkgname.sty} \Msg{*} \Msg{* To produce the documentation run latex twice on file \pkgname.tex} \Msg{* and then run dvipdfmx on file \pkgname.dvi.} @@ -210,7 +214,7 @@ footnotehyper.pdf, footnotehyper.dvi. \chardef\Withdvipdfmx 0 % 0 = pdflatex or latex+dvips, 1 = dvipdfmx \chardef\NoSourceCode 0 % 0 = include source code, 1 = do not \NeedsTeXFormat {LaTeX2e}% - \PassOptionsToClass {a4paper,fontsize=11pt,oneside}{scrdoc}% + \PassOptionsToClass {a4paper,fontsize=11pt,oneside}{scrdoc}% \PassOptionsToPackage {english}{babel}% \else % latex run is on \pkgname.tex \chardef\extractfiles 2 % do not extract files, only typeset @@ -307,7 +311,7 @@ footnotehyper.pdf, footnotehyper.dvi. \hypersetup{% linktoc=all,% breaklinks=true,% -colorlinks,% +colorlinks,% linkcolor=RoyalBlue,% urlcolor=OliveGreen,% pdfauthor={Jean-Fran\c cois Burnol},% @@ -317,8 +321,8 @@ pdfkeywords={LaTeX, footnotes},% pdfstartview=FitH,% pdfpagemode=UseNone} % added usage of package bookmark 2013/10/10 -\usepackage{bookmark} - +\usepackage{bookmark} +\usepackage{enumitem} \usepackage{\pkgname} \newcommand\fnh{% @@ -339,7 +343,7 @@ pdfpagemode=UseNone} \begin{center} {\normalfont\LARGE The \fnh package}\\ \textsc{\small Jean-François Burnol}\par - \footnotesize \ttfamily + \footnotesize \ttfamily jfbu (at) free (dot) fr\par Package version: \pkgversion\ (\pkgdate)\par From source file \texttt{\pkgname.dtx} of \dtxtimestamp.\par @@ -347,23 +351,27 @@ pdfpagemode=UseNone} \MakeShortVerb{\`}% \begin{abstract} -The `footnote` package by Mark \textsc{Wooding} (which dates back to 1997) -allows to gather footnotes (`\savenotes`) and later insert them -(`\spewnotes`) at the bottom of the page, even if the intervening -material consists of tabulars, minipages or framed contents for -example. There is a command to patch any given environment to do -the `\savenotes/\spewnotes` commands automatically. Also there is -a `footnote` environment which allows to insert verbatim material. - -The \fnh package loads `footnote.sty` and rewrites a number of its -commands to add `hyperref` awareness and to fix some issues, -particularly the one of incompatibility with `color/xcolor`. The -incompatibility with `babel-frenchb` is addressed, too. In case of -absence of `hyperref`, \fnh limits itself to partially fix some of -these issues. - -This package provides no facility dedicated to footnotes from -floating environments. +The `footnote` package by \textsc{Mark~Wooding} (`1997/01/28` `1.13`) +allows to gather footnotes (`\begin{savenotes}`) and later insert +them (after `\end{savenotes}`) at the bottom of the page, even +if the intervening material consists of tabulars, minipages or +framed contents for example. One can also use the +`\savenotes/\spewnotes` syntax. + +Also, `footnote.sty` provides a `footnote` environment which +allows to insert verbatim material. + +Earlier releases of the present \fnh package added +patches for `hyperref` compatibility and some bugfixes, addressing +in particular the incompatibility with `color/xcolor`, and with +`babel-frenchb`, and also fixing the `footnote` environment with +optional argument `[NUM]`. Since `v0.99` all macros are defined +internally and the `footnote` package is not loaded at all. + +The same user interface is kept. In case `hyperref` is absent, or +is loaded with `hyperfootnotes=false` option, \fnh +deactivates itself. The order of loading of \fnh +and `hyperref` is inconsequential. \end{abstract} \DeleteShortVerb{\`} @@ -376,154 +384,222 @@ floating environments. \section{Usage} -DON'T load |footnote|, leave that job to \fnh. You \emph{must} load -|hyperref|.\footnote{Since |v0.9e| \fnh deactivates itself - gracefully if |hyperref| is not loaded, or under |hyperref| option - |hyperfootnotes=false|.} - -Then you can use |\savenotes/\spewnotes| or the equivalent |savenotes| -environment; there is also a |footnote| environment, but its set-up during -\fnh loading is more delicate and it could well fail depending on how -|\@makefntext| has been customized by the class or other packages; a warning -is issued in that case. A functional |footnote| environment allows footnotes -with verbatim material. - -\savenotes -\begin{framed} -Please refer to the documentation of the |footnote| package.% -\footnote{\url{http://ctan.org/pkg/footnote}} - -Particularly you may check its |\makesavenoteenv| command.% -\footnote{This won't handle floating environments, though.} -\end{framed} -\spewnotes - -We can try some normal footnote.\footnote{Here it is.} +You \emph{must} load |hyperref|\footnote{Since |v0.9e| \fnh + deactivates itself gracefully if |hyperref| is not loaded, or + under |hyperref| option |hyperfootnotes=false|.}, but it does +not matter if before or after \fnh. Since |v0.99|, \fnh does not +load package +|footnote.sty|\footnote{\url{http://ctan.org/pkg/footnote}} +anymore, and is even incompatible with it at it uses the same user +interface. + +The package thus provides: +\begin{itemize} +\item a |savenotes| environment which re-routes footnotes and delivers them at + the end (there is also the |\savenotes/\spewnotes| syntax; it does create a + group like the environment), +\item |footnote| and |footnotetext| environments to allow footnotes + with verbatim material. +\end{itemize} + +But the constructability of the |footnote/footnotetext| environments depends +on how |\@makefntext| has been customized by the class or other packages; a +warning is issued if the situation appears to be desperate.\footnote{original + |footnote.sty| could end up in a low level \TeX\ error.} + +It should be recalled that in case of |\footnotemark[N]| and +|\footnotetext[N]{...}| mark-up |hyperref| creates no hyperlink. This is not +changed by \fnh and applies also to the |\begin{footnotetext}[N]| case. +Without optional argument the link is created, and the link is created also +for |\footnote[N]| or |\begin{footnote}[N]|. + +This package does not handle especially floating environments, except that one +can always surround them in the source in a |savenotes| environment and one +knows that the footnotes will be delivered at the |\end{savenotes}|\dots which +may well be one page earlier than the actual location of the floating material +in the produced document ! + +Environments typesetting multiple times their contents are the most hostile to +footnotes. Currently, \fnh only handles especially the |amsmath| +environments (as in |footnote.sty|.) + +Finally there is a |\makesavenoteenv| command which takes as +argument an environment name and patches it to do the +|\savenotes/\spewnotes| automatically.% +\begin{footnote} + For the +record the syntax is either |\makesavenoteenv{foo}| which patches +environment |foo| or |\makesavenoteenv[bar]{foo}| which defines +environment |bar| as this patched version of |foo|. +\end{footnote} +It is safer to avoid it, as +one never knows what happens with such patches: for example the |[H]| +specifier provided by the |float| package overwrites the |\end{table}| +definition during the execution of |\begin{table}|\dots ! \begin{savenotes} \begin{framed} \DeleteShortVerb{\|}\MakeShortVerb{\*}% {\centering \begin{tabular}{|c|c|} -\hline - \strut The above\footnote{Notice that if the present frame - extended to next page, - the end of the *savenotes* environment would then (try to) deliver its - footnotes to that - page.} was & coded\footnote{Alternatively a savenotes environment - could have been used.} as:\\\hline + \hline + \strut Inside\footnote{Notice that as frame + extended to the next page, + the end of the *savenotes* environment delivered its + footnotes only here.} a & tabular\begin{footnote}Alternatively a + *\savenotes/\spewnotes* pair + could have been used.\end{footnote}\\\hline \end{tabular}\par} \DeleteShortVerb{\*}\MakeShortVerb{\|}% +An example: \begin{verbatim} -\savenotes +\begin{savenotes} \begin{framed} Please refer to the documentation of the |footnote| package.% \footnote{\url{http://ctan.org/pkg/footnote}} - Particularly you may check its |\makesavenoteenv| command.% - \footnote{This won't handle floating environments, though.} + Particularly you may check its |savenotes| environment.% + \footnote{It doesn't bring any + feature to especially handle the issues related to footnotes in floating + environments, though.} \end{framed} -\spewnotes +\end{savenotes} \end{verbatim} and the present frame has \cs{footnote}'s from inside a |tabular| and is -inside a |savenotes| environment.% -% -% plus maintenant, \small pour le \MacroFont utilisé par verbatim -%\footnote{Well, I end up on next page. Not -% much I can do about this, ask why to |framed.sty| and the output routine I -% guess.} -% -\footnote{Here is an issue which has nothing (as I finally figured out) to do - with |footnote|, and only indirectly with \LaTeX: if you embed a - \emph{full-width} minipage (with initial \cs{noindent}) in any environment - not doing \cs{ignorespacesafterend}, be careful to add a \% after the - minipage (or after the surrounding environment; or a \cs{par} immediately), - else the output will have an extra blank line if the source has itself a - blank line there. I hesitated adding that to - \cs{spewnotes}/\cs{endsavenotes}. Finally I left as is.} Let's test an +inside a |savenotes| environment.% +\begin{footnote} + Here is an issue which has nothing (as I finally figured out) to + do with |footnote|, and only indirectly with \LaTeX: if you embed + a \emph{full-width} minipage (with initial \cs{noindent}) in any + environment not doing \cs{ignorespacesafterend}, be careful to add + a \% either immediately after the |\end{minipage}| (or a |\relax| + or a |\par|) or after the surrounding environment |\end{foo}| or + use |\end{minipage}\end{foo}| else the output may have an extra + blank line if the source has a blank line after the |foo| environment. + Here is a typical example, with a |tabular| rather: + \makeatletter + + \medskip\noindent\hspace{1cm}\begin{minipage}{\dimexpr\linewidth-1cm}% + \def\MacroFont{\baselineskip10pt\relax}% +\begin{verbatim} +\newenvironment{foo}{}{} + +\noindent\begin{tabular}{p{\dimexpr\linewidth-2\tabcolsep\relax}} + A\dotfill B +\end{tabular} + +C + +\begin{foo} +\noindent\begin{tabular}{p{\dimexpr\linewidth-2\tabcolsep\relax}} + A\dotfill B +\end{tabular} +\end{foo} + +C +\end{verbatim}\end{minipage}\par\medskip + + If you try it out you will see an extra blank line in PDF output above the + second C. Starting with |v0.99| the |\end{savenotes}| emits an + \cs{ignorespacesafterend} which avoids this generic \TeX/\LaTeX\ + problem. For good measure there is now an \cs{ignorespaces} in + |\begin{savenotes}|. +\end{footnote} +Let's test an |amsmath| environment with |\intertext|. As \begin{align} E&=mc^2\;, -\intertext{was too easy,\footnote{There is also $E=h\nu$.}, let's +\intertext{was too easy\footnote{There is also $E=h\nu$.}, let's try:} - F&=nd^3\;. + a^n + b^n &=c^n\;. \end{align} +And a footnote with some verbatim material% +\begin{footnote} + \verb|&$^%\[}$| +\end{footnote}. \end{framed} \end{savenotes} -Use of the \texttt{footnote} \emph{environment} with some verbatim material% -\begin{footnote} - \verb|&$^%\[}$| -\end{footnote} -which was coded as: +The last one was coded as: \begin{verbatim} -Use of the \texttt{footnote} \emph{environment} with some verbatim material% +And a footnote with some verbatim material% \begin{footnote} \verb|&$^%\[}$| -\end{footnote} -which was coded as: - +\end{footnote}. \end{verbatim} -And here a use of |\footnotemark|\footnotemark\ -followed by a |footnotetext| environment. +Now some use of |\footnotemark|\footnotemark\ followed by a |footnotetext| +environment. \begin{footnotetext} This one uses the normal footnote counter and the hyperlink works. \end{footnotetext} -Now a use of |\footnotemark[N]|\footnotemark[99] followed with a -|footnotetext| environment using the same optional argument |[N]|. -No hyperfootnote link is then inserted by |hyperref|.% +And use of |\footnotemark[99]|\footnotemark[99] in association with a +|footnotetext| environment using the same optional argument |[99]|. +No hyperfootnote link was inserted.% \begin{footnotetext}[99] - |hyperref| puts no hyperlink in this case, which is similar to - the |\footnotemark[N]/\footnotetext[N]{}| context (there is - no such problem with using the |[N]| with a |\footnote| or with - a |footnote| environment.) + |hyperref| creates no hyperlink in this case, or in the + |\footnotemark[N]/\footnotetext[N]{}| case. It does when + the |[N]| is absent or when it is used with a |\footnote| command + (or a |footnote| environment.) + + By the way, \fnh |v0.9f|'s |\footnotetext[N]| and |\begin{footnotetext}[N]| + each had a bug and they were unusable \emph{inside} the |savenotes| + environment. There was no issue \emph{outside}. \end{footnotetext} -And a final footnote, with a |footnote| environment using an -optional argument |[N]|.% -\begin{footnote}[100]\csname @minipagetrue\endcsname % to reduce +And a final footnote, done with |\begin{footnote}[57]|% +\begin{footnote}[57]\csname @minipagetrue\endcsname % to reduce % framed inserted vertical spacing \begin{framed} \noindent\fnh deactivates itself if |hyperfootnotes=false| option to |hyperref| is detected, or if |hyperref| is not loaded at all. - Essentially, it only then fixes some of the incompatibilities - between |footnote.sty| and |color/xcolor/babel-frenchb| - packages. But the bug making the |footnote| environment - optional argument unusable remains unfixed by \fnh if - |hyperref| has not been detected. \end{framed} -\end{footnote} -No problem with the hyperlink, then. +\end{footnote}. +There is no problem with the hyperlink, then. \section{Notes} -The |footnote| environment of |footnote.sty| had various issues -but as \fnh initially focused only on |\savenotes/\spewnotes| I -became aware only at the time of |v0.9f| of the error when this -environment is used with the optional |[N]| parameter; this is a -different bug than the one of incompatibility with |color/xcolor|. -The |v0.9f| release fixes this new problem (no extensive -tests were done.) - -During this I realized (this is unrelated to |footnote| package or -\fnh) that there is a typesetting interference of |hyperref| with -|babel+frenchb| in the case of the |\footnotemark[N]| syntax. \fnh -does not fix that. I reported the problem and perhaps an upstream -fix will come at a later date (tested with |hyperref 6.83q| and -|frenchb 3.2c|). - -The |hyperref| package inserts no hyperlink in case of -|\footnotemark[N]/\footnotetext[N]|. This is not modified by \fnh. - -The |footnote.sty| package patches the \LaTeX\ kernel |\parbox|. I had not -realized that earlier, and starting with \fnh |v0.9f| the patch is undone. -But the re-defined macro is made available as |\fnparbox|. - -\medskip - -At this stage, \fnh rewrites large parts of the original -|footnote.sty| code. Perhaps a later release will not load at all -the original package (but it will keep the |\savenotes/\spewnotes| -interface.) +A few items worth of mention: +\begin{itemize}[nosep] +\item the |footnote| package patches the \LaTeX\ kernel |\parbox|. + \fnh doesn't (but the code can be found commented-out at the + end of the present file). +\item the |footnote| package defines a |minipage*| environment + which is |minipage| patched by |\makesavenoteenv|, \fnh doesn't. +\item the |footnote| environment from |footnote.sty| does a + |\leavevmode\unskip| which \fnh doesn't: hence if one locates + |\begin{footnote}| at start of a line in the \LaTeX\ source, one will + typically need a \% at end of text on previous line to avoid the + end-of-line space. +\item the |hyperref| package inserts no hyperlink in case of + |\footnotemark[N]/\footnotetext[N]|. This is not modified by \fnh. +\item side-note: there is an interference between |hyperref| and |frenchb| + regarding the footnote marker when using the syntax |\footnotemark[NUM]|. + For the record here is a patch (last tested briefly with +% PUTAIN BORDEL ! LaTeX Error: Text for \verb command ended by end of +% line. À CHAQUE FOIS ÇA M'AGAÇE. Bon, je n'ai pas mon patch habituel ici. + |hyperref 2016/06/24 v6.83q| and |frenchb 2017/01/30 v3.2g|): +% pour le cas où mis dans commentaires de code +% \begingroup\makeatletter\let\check@percent\@gobble +\begin{verbatim} + \AtBeginDocument{% + \let\@xfootnotemarkORIFB \@xfootnotemark + \def\@xfootnotemarkFB {\leavevmode\unskip\unkern\,\@xfootnotemarkORIFB }% + \ifHy@hyperfootnotes\ifFBAutoSpaceFootnotes + \let\@xfootnotemark\@xfootnotemarkFB + \fi\fi + }% +\end{verbatim} +% \endgroup +\item some environments typeset multiple times their contents, + which causes issues; \fnh takes provisions only to handle the + |amsmath| measuring step. +\end{itemize} + +% During this I realized (this is unrelated to |footnote| package or +% \fnh) that there is a typesetting interference of |hyperref| with +% |babel+frenchb| in the case of the |\footnotemark[N]| syntax. \fnh +% does not fix that. I reported the problem and perhaps an upstream +% fix will come at a later date (tested with |hyperref 6.83q| and +% |frenchb 3.2c|). \StopEventually{\end{document}\endinput} \makeatletter @@ -570,162 +646,184 @@ interface.) % % %<*package> -% It is surely difficult to understand the code here as its expansion depends on -% some macros whose definitions are still in |footnote.sty| and used with no -% modification here: the most important are |\savenotes|, |\fn@startnote|, and -% |\fn@startfntext| (which is used only for the environment form.) Obviously the -% macros here depend on what these three do. -% -% Surely, next release of \fnh will drop entirely the idea of patching -% |footnote.sty| and will contain all definitions. % \begin{macro}{no options} +% The package has no options. % \begin{macrocode} -\DeclareOption*{\PackageWarning{footnotehyper}{Option `\CurrentOption' is unknown}}% +\DeclareOption*% + {\PackageWarning{footnotehyper}{Option `\CurrentOption' is unknown}}% \ProcessOptions\relax % \end{macrocode} % \end{macro} -% \begin{macro}{\@makefntext} -% \begin{macro}{\footnote} -% \begin{macro}{\footnotetext} -% \begin{macro}{\parbox} -% \begin{macro}{\fn@endnote} -% We load |footnote| but leave to the user to take care of |hyperref|. -% -% As we need to intercept some re-definitions done by -% |footnote.sty| we will first check if it is already loaded. -% -% If \cs{@makefntext} has been customized and its argument is not visible at -% top level in its meaning, then loading |footnote.sty| will fail with a low -% level \TeX\ error. We save its meaning and replace it by an innocuous one -% for the time being. We will come back to this at begin document. -% -% |footnote.sty| modifies |\parbox|. We (|v0.9f|) undo the patch, because -% modifying |\parbox| in any way for no good reason is BAD. -% -% The |\fn@endnote| was |\let| to |\color@endgroup| which is bad as it fails if -% |color/xcolor| is not yet loaded. Besides its presence was missing from some -% needed place (see later). -% -% We postpone to at begin document the redefinitions of \cs{footnote} and -% \cs{footnotetext}. +% Versions up to |v0.9f| loaded |footnote.sty|, with lots of patching +% afterwards. Starting with |v0.99|, \fnh does everything by itself with |FNH@| +% prefix. Brief overview of some of the fixed issues: +% \begin{itemize}[nosep] +% \item there was incompatibility with |hyperref|, +% \item and with |color|, +% \item if the \cs{@makefntext} at the time of loading of |footnote.sty| +% does not have its argument visible at top level in its meaning, or +% is used multiple times there, then the footnote environment will lead to low +% level \TeX\ error, +% \item |footnote.sty| modifies |\parbox|, +% \item |footnote.sty| does some too early |\let|, +% \item the footnote environment from |footnote.sty| does not work if used with +% optional argument |[N]|. +% \end{itemize} % \begin{macrocode} -\@ifpackageloaded{footnote} - {\PackageWarningNoLine{footnotehyper}% - {Please next time do not load package footnote,^^J - but leave that to me. For the time being, I will start by undoing the^^J - modifications it did to \string\parbox. Use \string\fnparbox\space if needed.}% - } - {\let\FNH@@makefntext\@makefntext\let\@makefntext\@firstofone - \RequirePackage{footnote} - \let\@makefntext\FNH@@makefntext - }% -\let\fnparbox\parbox\let\parbox\fn@parbox -\let\FNH@fn@footnote \footnote % footnote.sty's \footnote will get -\let\FNH@fn@footnotetext\footnotetext % redefined later. We preserve also -\let\footnote \fn@latex@@footnote % the meaning of \footnote from prior -\let\footnotetext\fn@latex@@footnotetext % to the loading of footnote.sty -\def\fn@endnote {\color@endgroup}% +\newbox\FNH@notes +\newdimen\FNH@width +\let\FNH@colwidth\columnwidth +\newif\ifFNH@savingnotes +\AtBeginDocument {% + \@ifpackageloaded{hyperref} + {\ifHy@hyperfootnotes + \let\FNH@latex@footnote \footnote + \let\FNH@latex@footnotetext\footnotetext + \newenvironment{savenotes} + {\FNH@savenotes\ignorespaces}{\FNH@spewnotes\ignorespacesafterend}% + \let\spewnotes \FNH@spewnotes + \let\footnote \FNH@footnote + \let\footnotetext \FNH@footnotetext + \let\endfootnote \FNH@endfntext + \let\endfootnotetext\FNH@endfntext + \else + \PackageInfo{footnotehyper}% + {inactive due to hyperfootnotes=false option}% + \fi}% + {\PackageWarning{footnotehyper}{^^J\@spaces\@spaces*************^^J% + \space deactivating myself as hyperref is not detected !^^J}}% +}% % \end{macrocode} -% \end{macro}\end{macro}\end{macro}\end{macro}\end{macro} -% There are some |\let|'s done by |footnote.sty| in what appears to be -% premature ways. +% \begin{macro}{\FNH@hyper@fntext} +% \begin{macro}{\FNH@nohyp@fntext} +% \begin{macro}{\FNH@fntext} +% These are the \fnh replacement for |\@footnotetext| inside the +% |savenotes| environment. There is a version creating an hyperlink +% and another one not creating an hyperlink. The \cs{FNH@fntext} +% macro serves as general dispatch. This may be a place to customize if one +% wants to handle environments doing multiple passes: but the footnote counter +% must have been taken care of elsewhere. The code currently handles only +% the case of |amsmath| environments. % \begin{macrocode} -\AtBeginDocument {% - \let\fn@latex@@footnote \footnote % meaning of \footnote at end of preamble - \let\fn@latex@@footnotetext\footnotetext +\def\FNH@hyper@fntext{\FNH@fntext\FNH@hyper@fntext@i}% +\def\FNH@nohyp@fntext{\FNH@fntext\FNH@nohyp@fntext@i}% +\def\FNH@fntext #1{\ifx\ifmeasuring@\@undefined + \expandafter\@secondoftwo\else\expandafter\@firstofone\fi + {\ifmeasuring@\expandafter\@gobbletwo\fi}#1% }% % \end{macrocode} -% \begin{macro}{\FNH@inactive} -% Apart from fixing some of the bugs with |footnote.sty|'s footnote -% environment, we intervene only if |hyperfootnotes| option of |hyperref| -% applies. +% \end{macro}\end{macro}\end{macro} +% \begin{macro}{\FNH@hyper@fntext@i} +% We do the \cs{ifHy@nesting} test although hyperref's manual +% says ``Allows links to be nested; no drivers currently support this.'' % \begin{macrocode} -\AtBeginDocument{\@ifpackageloaded{hyperref} - {\ifHy@hyperfootnotes - \let\fn@fntext \FNH@hyper@fntext - \let\spewnotes \FNH@hyper@spewnotes - \let\endsavenotes\spewnotes - \let\fn@endfntext\FNH@fixed@endfntext - \let\footnote \FNH@fixed@footnote - \let\footnotetext\FNH@fixed@footnotetext - \else - \FNH@inactive - \fi }{\FNH@inactive}% - \let\endfootnote\fn@endfntext - \let\endfootnotetext\endfootnote +\long\def\FNH@hyper@fntext@i#1{% + \global\setbox\FNH@notes\vbox + {\unvbox\FNH@notes + \FNH@startnote + \@makefntext + {\rule\z@\footnotesep\ignorespaces + \ifHy@nesting\expandafter\ltx@firstoftwo + \else\expandafter\ltx@secondoftwo + \fi + {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}% + {\Hy@raisedlink + {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}% + {\relax}}% + \let\@currentHref\Hy@footnote@currentHref + \let\@currentlabelname\@empty + #1}% + \@finalstrut\strutbox + }% + \FNH@endnote + }% }% % \end{macrocode} -% |v0.9e| did a partial fix of the |footnote| environment from |footnote.sty|, -% |v0.9f| fix is more complete but is applied only if |hyperref| is present with -% option |hyperfootnotes=true|. +% \end{macro} +% \begin{macro}{\FNH@nohyp@fntext@i} +% The original \cs{fn@fntext} had no \cs{long}. % \begin{macrocode} -\def\FNH@fix@endfntext\@finalstrut\strutbox\fn@postfntext - {\@finalstrut\strutbox\fn@postfntext\fn@endnote}% -\def\FNH@inactive {% - \let\footnote \FNH@fn@footnote - \let\footnotetext\FNH@fn@footnotetext - \expandafter\expandafter\expandafter\def - \expandafter\expandafter\expandafter\fn@endfntext - \expandafter\expandafter\expandafter - {\expandafter\FNH@fix@endfntext\fn@endfntext}% - \PackageInfo{footnotehyper}% - {hyperref package not loaded or hyperfootnotes^^J - =false option; I did not activate myself and only patched footnote.sty^^J - for color/xcolor compatibility, leaving some other issues unfixed.}}% +\long\def\FNH@nohyp@fntext@i#1{% + \global\setbox\FNH@notes\vbox + {\unvbox\FNH@notes + \FNH@startnote + \@makefntext{\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}% + \FNH@endnote + }% +}% % \end{macrocode} % \end{macro} -% \begin{macro}{\FNH@hyper@fntext} -% Some |amsmath| complications. I change the coding, but same effect as -% in original |\fn@fntext|. +% \begin{macro}{\FNH@startnote} +% Same as original (the code comment is kept from original.) % \begin{macrocode} -\def\FNH@hyper@fntext {\ifx\ifmeasuring@\undefined\expandafter\@secondoftwo - \else\expandafter\@firstofone\fi - {\ifmeasuring@\expandafter\@gobbletwo\fi}% - \FNH@hyper@fntext@i }% +\def\FNH@startnote{% + \hsize\FNH@colwidth + \interlinepenalty\interfootnotelinepenalty + \reset@font\footnotesize + \floatingpenalty\@MM% Is this right??? + \@parboxrestore + \protected@edef\@currentlabel{\csname p@\@mpfn\endcsname\@thefnmark}% + \color@begingroup +}% % \end{macrocode} % \end{macro} -% \begin{macro}{\FNH@hyper@fntext@i} -% Note: original \cs{fn@fntext} had no \cs{long}, which looks wrong. -% -% We do the \cs{ifHy@nesting} test although hyperref's manual -% says ``Allows links to be nested; no drivers currently support this.'' +% \begin{macro}{\FNH@endnote} +% Fixed from original. +% \begin{macrocode} +\def\FNH@endnote{\color@endgroup}% +% \end{macrocode} +% \end{macro} +% \begin{macro}{\FNH@savenotes} +% Same as original apart from using |hyperref|-aware \cs{FNH@hyper@fntext}, +% and taking into account |hyperref|'s custom \cs{@xfootnotetext}. This was +% missed by |v0.9f| hence |\footnotetext[N]{..}| did not work +% inside |savenotes| environment. Fixed for |v0.99|. +% +% Maybe I should change the way \cs{@minipagerestore} is handled. % \begin{macrocode} -\long\def\FNH@hyper@fntext@i #1{\global\setbox\fn@notes\vbox - {\unvbox\fn@notes - \fn@startnote - \@makefntext - {\rule\z@\footnotesep\ignorespaces - \ifHy@nesting\expandafter\ltx@firstoftwo - \else\expandafter\ltx@secondoftwo - \fi - {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}% - {\Hy@raisedlink - {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}% - {\relax}}% - \let\@currentHref\Hy@footnote@currentHref - \let\@currentlabelname\@empty - #1}% - \@finalstrut\strutbox }% - \fn@endnote }% +\def\FNH@savenotes{% + \begingroup + \ifFNH@savingnotes\else + \FNH@savingnotestrue + \let\@footnotetext \FNH@hyper@fntext + \let\@mpfootnotetext \FNH@hyper@fntext + \let\H@@mpfootnotetext\FNH@nohyp@fntext % fool hyperref's \@xfootnotetext + \FNH@width\columnwidth + \let\FNH@colwidth\FNH@width + \global\setbox\FNH@notes\box\voidb@x + \let\FNH@thempfn\thempfn + \let\FNH@mpfn\@mpfn + \ifx\@minipagerestore\relax\let\@minipagerestore\@empty\fi + \expandafter\def\expandafter\@minipagerestore\expandafter{% + \@minipagerestore + \let\thempfn\FNH@thempfn + \let\@mpfn\FNH@mpfn + }% + \fi }% % \end{macrocode} % \end{macro} -% \begin{macro}{\FNH@hyper@spewnotes} -% The final touch in our hack is to patch the original \cs{spewnotes} for it -% to use the original, non-hyperref modified, version of \cs{@footnotetext}. -% And let's not forget \cs{endsavenotes} (done at begin document). +% \begin{macro}{\FNH@spewnotes} +% This uses \cs{H@@footnotetext} which is the preserved original +% meaning of \cs{@footnotetext} not creating a link target. % \begin{macrocode} -\def\FNH@hyper@spewnotes {\endgroup - \if@savingnotes\else\ifvoid\fn@notes\else - \begingroup\let\@makefntext\@empty - \let\@finalstrut\@gobble - \let\rule\@gobbletwo - \H@@footnotetext{\unvbox\fn@notes}% - \endgroup\fi\fi +\def\FNH@spewnotes {% + \endgroup + \ifFNH@savingnotes\else + \ifvoid\FNH@notes\else + \begingroup + \let\@makefntext\@empty + \let\@finalstrut\@gobble + \let\rule\@gobbletwo + \H@@footnotetext{\unvbox\FNH@notes}% + \endgroup + \fi + \fi }% % \end{macrocode} % \end{macro} -% \begin{macro}{\FNH@fixed@endfntext} +% \begin{macro}{\FNH@footnote} +% \begin{macro}{\FNH@footnotetext} % We now take care of |footnote.sty|'s |footnote| environment. The original % \cs{fn@endfntext} is lacking a \cs{fn@endnote}, and this meant that % |footnote.sty| was incompatible with |color/xcolor| packages. Also this @@ -737,113 +835,186 @@ interface.) % % The |footnotetext| environment adds a complication, in case of optional % argument we should not try to set up a link due to the fact that |hyperref| -% does not support them for |\footnotemark[N]/\footnotetext[N]| syntax. +% does not support it for the |\footnotemark[N]/\footnotetext[N]| syntax. % And we need to make sure that the |footnote| and |footnotetext| environments % obey the |\savenotes/\spewnotes| mechanism. % % To handle all of this we code things completely differently from -% |footnote.sty|, its |\fn@getmark| isn't used at all. +% |footnote.sty|. +% +% The |v0.9f| |\begin{footnotetext}[N]| inside |savenotes| tried to create +% an hyperref target. Fixed for |v0.99|. +% +% Note: the |footnote.sty| code did a |\leavevmode\unskip| at entrance of +% |footnote| environment, which \fnh has not kept. % \begin{macrocode} -\def\FNH@fixed@endfntext {% - \@finalstrut\strutbox - \fn@postfntext - \fn@endnote - \egroup\FNH@endfntext@next % will decide if link or no link -}% -\def\FNH@endfntext@link {\begingroup - \let\@makefntext\@empty\let\@finalstrut\@gobble\let\rule\@gobbletwo - \@footnotetext {\unvbox\z@}% - \endgroup +\def\FNH@footnote@envname {footnote}% +\def\FNH@footnotetext@envname{footnotetext}% +\def\FNH@footnote{% + \ifx\@currenvir\FNH@footnote@envname + \expandafter\FNH@footnoteenv + \else + \expandafter\FNH@latex@footnote + \fi }% -\def\FNH@endfntext@nolink {\begingroup - \let\@makefntext\@empty\let\@finalstrut\@gobble - \let\rule\@gobbletwo - \if@savingnotes\expandafter\fn@fntext\else\expandafter\H@@footnotetext\fi - {\unvbox\z@}\endgroup +\def\FNH@footnoteenv{% + \@ifnextchar[% + \FNH@footnoteenv@i %] + {\stepcounter\@mpfn + \protected@xdef\@thefnmark{\thempfn}% + \@footnotemark + \def\FNH@endfntext@fntext{\@footnotetext}% + \FNH@startfntext}% }% -% \end{macrocode} -% \end{macro} -% \begin{macro}{\FNH@fixed@footnote} -% \begin{macro}{\FNH@fixed@footnotetext} -% \begin{macrocode} -\def\FNH@fixed@footnote {\ifx\@currenvir\fn@footnote - \expandafter\FNH@footnoteenv\else\expandafter\fn@latex@@footnote\fi }% -\def\FNH@footnoteenv {\@ifnextchar[\FNH@xfootnoteenv%] - {\stepcounter\@mpfn - \protected@xdef\@thefnmark{\thempfn}\@footnotemark - \def\FNH@endfntext@next{\FNH@endfntext@link}\fn@startfntext}}% -\def\FNH@xfootnoteenv [#1]{% +\def\FNH@footnoteenv@i[#1]{% \begingroup \csname c@\@mpfn\endcsname #1\relax \unrestored@protected@xdef\@thefnmark{\thempfn}% - \endgroup\@footnotemark\def\FNH@endfntext@next{\FNH@endfntext@link}% - \fn@startfntext}% -\def\FNH@fixed@footnotetext {\ifx\@currenvir\fn@footnotetext - \expandafter\FNH@footnotetextenv\else\expandafter\fn@latex@@footnotetext\fi}% -\def\FNH@footnotetextenv {\@ifnextchar[\FNH@xfootnotetextenv%] - {\protected@xdef\@thefnmark{\thempfn}% - \def\FNH@endfntext@next{\FNH@endfntext@link}\fn@startfntext}}% -\def\FNH@xfootnotetextenv [#1]{% + \endgroup + \@footnotemark + \def\FNH@endfntext@fntext{\@footnotetext}% + \FNH@startfntext +}% +\def\FNH@footnotetext{% + \ifx\@currenvir\FNH@footnotetext@envname + \expandafter\FNH@footnotetextenv + \else + \expandafter\FNH@latex@footnotetext + \fi +}% +\def\FNH@footnotetextenv{% + \@ifnextchar[% + \FNH@footnotetextenv@i %] + {\protected@xdef\@thefnmark{\thempfn}% + \def\FNH@endfntext@fntext{\@footnotetext}% + \FNH@startfntext}% +}% +\def\FNH@footnotetextenv@i[#1]{% \begingroup \csname c@\@mpfn\endcsname #1\relax \unrestored@protected@xdef\@thefnmark{\thempfn}% - \endgroup\def\FNH@endfntext@next{\FNH@endfntext@nolink}% - \fn@startfntext }% + \endgroup + \ifFNH@savingnotes + \def\FNH@endfntext@fntext{\FNH@nohyp@fntext}% + \else + \def\FNH@endfntext@fntext{\H@@footnotetext}% + \fi + \FNH@startfntext +}% % \end{macrocode} % \end{macro}\end{macro} -% \begin{macro}{\@makefntext} -% \begin{macro}{\fn@prefntext} -% \begin{macro}{\fn@postfntext} -% The definitions of |\fn@prefntext| and |\fn@prefntext| (which are needed for -% the |footnote| environment, within |\fn@startfntext| and |\fn@endfntext|) -% are from a daring analysis done inside |footnote.sty| of |\@makefntext|. It -% may very easily fail to give a sensible result. \fnh does a check of its own -% to determine if that was the case but can't salvage the situation, except -% for hard-coded rescues like done here with |frenchb|. In particular the -% mechanism is doomed to failure if the parameter in |\@makefntext| is not -% visible at top level in its meaning. It is also wrong if the parameter is -% used multiple times. These checks will fail (rather, they are skipped) if -% |footnote|'s loading was done by the user and not by |footnotehyper|. +% \begin{macro}{\FNH@startfntext} +% \begin{macro}{\FNH@endfntext} +% \begin{macro}{\FNH@endfntext@fntext} +% This is used for the environmental form of the footnote environments. +% The use of |\box\z@| originates in |footnote.sty|, should I change that ? +% +% Both of \cs{endfootnote} and \cs{endfootnotetext} are aliases for +% \cs{FNH@endfntext}. % -% Note: there is an interference which I could fix here between |hyperref| -% and |frenchb| regarding |\footnotemark[NUM]|, but it is better to wait it -% is fixed on |frenchb| side (or |hyperref|'s side !), else my own fix might -% badly interfere with the ``official'' one |;-)|. +% The \cs{FNH@endfntext@fntext} may be \cs{@footnotetext} (which will be +% \cs{FNH@hyper@fntext} in |savingnotes| environment), or +% \cs{H@@footnotetext}, or \cs{FNH@nohyp@fntext} if in |savingnotes| scope. % \begin{macrocode} -\ifx\FNH@@makefntext\undefined\expandafter\@gobble - \else\expandafter\AtBeginDocument\fi -{% - \ifx\@makefntextFB\undefined - \expandafter\@gobble\else\expandafter\@firstofone\fi - {\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else - \let\FNH@@makefntext\@makefntextORI\fi}% - \expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}\FNH@@@1.2!3?4,\FNH@@@\relax +\def\FNH@startfntext{% + \setbox\z@\vbox\bgroup + \FNH@startnote + \FNH@prefntext + \rule\z@\footnotesep\ignorespaces }% -\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3% -{% - \ifx\relax#3\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi - \FNH@bad@footnote@env - {\def\fn@prefntext{#1}\def\fn@postfntext{#2}\FNH@check@b}% +\def\FNH@endfntext {% + \@finalstrut\strutbox + \FNH@postfntext + \FNH@endnote + \egroup + \begingroup + \let\@makefntext\@empty\let\@finalstrut\@gobble\let\rule\@gobbletwo + \FNH@endfntext@fntext {\unvbox\z@}% + \endgroup }% -\def\FNH@check@b #1\relax -{% +% \end{macrocode} +% \end{macro}\end{macro}\end{macro} +% \begin{macro}{\@makefntext} +% \begin{macro}{\FNH@prefntext} +% \begin{macro}{\FNH@postfntext} +% The definitions of |\FNH@prefntext| and |\FNH@prefntext| (which are needed +% for the |footnote| environment, |\FNH@startfntext| and |\FNH@endfntext|) +% are extracted from a somewhat daring analysis of |\@makefntext|. +% Contrarily to |footnote.sty|'s original code (which may cause low level +% \TeX\ +% errors in bad cases) the method here will alert the user if the argument +% of |\@makefntext| is not visible at top level in its meaning or is used +% there multiple times. We also insert here some code to handle especially +% the case of |babel-frenchb|. +% \begin{macrocode} +\AtBeginDocument{\let\FNH@@makefntext\@makefntext + \ifx\@makefntextFB\undefined + \expandafter\@gobble\else\expandafter\@firstofone\fi + {\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else + \let\FNH@@makefntext\@makefntextORI\fi}% + \expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}% + \FNH@@@1.2!3?4,\FNH@@@\relax +}% +\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{% + \ifx\relax#3\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + \FNH@bad@makefntext@alert + {\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}\FNH@check@b}% +}% +\def\FNH@check@b #1\relax{% \expandafter\expandafter\expandafter\FNH@check@c - \expandafter\meaning\expandafter\fn@prefntext - \meaning\fn@postfntext1.2!3?4,\FNH@check@c\relax + \expandafter\meaning\expandafter\FNH@prefntext + \meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax +}% +\def\FNH@check@c #11.2!3?4,#2#3\relax{% + \ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@makefntext@alert }% -\def\FNH@check@c #11.2!3?4,#2#3\relax - {\ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@footnote@env}% -\def\FNH@bad@footnote@env -{\PackageWarningNoLine{footnotehyper}% - {The footnote environment from package footnote^^J - will be dysfunctional, sorry (not my fault...). You may try to mail me the^^J - preamble and/or only the next lines:}% +\def\FNH@bad@makefntext@alert{% + \PackageWarningNoLine{footnotehyper}% + {^^J The footnote environment will not be fully functional, sorry.^^J + You may try to email the author with the following information:}% \typeout{\meaning\@makefntext}% - \let\fn@prefntext\@empty\let\fn@postfntext\@empty + \let\FNH@prefntext\@empty\let\FNH@postfntext\@empty }% -\endinput % \end{macrocode} % \end{macro}\end{macro}\end{macro} +% \begin{macro}{\makesavenoteenv} +% Same as original. Not recommended. Safer to use explicitely +% |savenotes| environment. +% \begin{macrocode} +\def\makesavenoteenv{\@ifnextchar[\FNH@msne@ii\FNH@msne@i}%] +\def\FNH@msne@i #1{% + \expandafter\let\csname FNH$#1\expandafter\endcsname %$ + \csname #1\endcsname + \expandafter\let\csname endFNH$#1\expandafter\endcsname %$ + \csname end#1\endcsname + \FNH@msne@ii[#1]{FNH$#1}%$ +}% +\def\FNH@msne@ii[#1]#2{% + \expandafter\edef\csname#1\endcsname{% + \noexpand\savenotes + \expandafter\noexpand\csname#2\endcsname + }% + \expandafter\edef\csname end#1\endcsname{% + \expandafter\noexpand\csname end#2\endcsname + \noexpand\expandafter + \noexpand\spewnotes + \noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi + }% +}% +% \end{macrocode} +% \end{macro} +% Original footnote.sty patches |\parbox|, we don't touch it. Also it defines a +% |minipage*| environment, we don't do it. +% \begin{macrocode} +% \makesavenoteenv[minipage*]{minipage} +% \let\fn@parbox\parbox +% \def\parbox{\@ifnextchar[{\fn@parbox@i{}}{\fn@parbox@ii{}}} +% \def\fn@parbox@i#1[#2]{% +% \@ifnextchar[{\fn@parbox@i{#1[#2]}}{\fn@parbox@ii{#1[#2]}}% +% } +% \long\def\fn@parbox@ii#1#2#3{\savenotes\fn@parbox#1{#2}{#3}\spewnotes} +\endinput +% \end{macrocode} % \MakePercentComment \Finale %% diff --git a/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.ins b/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.ins index e0a60adb4e4..889dd425796 100644 --- a/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.ins +++ b/Master/texmf-dist/source/latex/footnotehyper/footnotehyper.ins @@ -1,13 +1,13 @@ %% %% Package: footnotehyper -%% Version: 0.9f (2016/10/03) +%% Version: 0.99 (2017/02/16) %% License: LPPL 1.3c -%% Copyright (C) 2016 Jean-Francois Burnol . +%% Copyright (C) 2016-2017 Jean-Francois Burnol . %% \def\pkgname {footnotehyper} -\def\pkgdate {2016/10/03} -\def\docdate {2016/10/03} -\def\pkgversion {v0.9f} +\def\pkgdate {2017/02/16} +\def\docdate {2017/02/16} +\def\pkgversion {v0.99} \def\pkgdescription {hyperref aware footnote.sty (JFB)} %% %% Run tex on this file to extract from footnotehyper.dtx: diff --git a/Master/texmf-dist/tex/latex/footnotehyper/footnotehyper.sty b/Master/texmf-dist/tex/latex/footnotehyper/footnotehyper.sty index 42184342406..192a473dcbf 100644 --- a/Master/texmf-dist/tex/latex/footnotehyper/footnotehyper.sty +++ b/Master/texmf-dist/tex/latex/footnotehyper/footnotehyper.sty @@ -23,162 +23,233 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{footnotehyper}% - [2016/10/03 v0.9f hyperref aware footnote.sty (JFB)] + [2017/02/16 v0.99 hyperref aware footnote.sty (JFB)] %% %% Package: footnotehyper -%% Version: 0.9f (2016/10/03) +%% Version: 0.99 (2017/02/16) %% License: LPPL 1.3c -%% Copyright (C) 2016 Jean-Francois Burnol . +%% Copyright (C) 2016-2017 Jean-Francois Burnol . %% -\DeclareOption*{\PackageWarning{footnotehyper}{Option `\CurrentOption' is unknown}}% +\DeclareOption*% + {\PackageWarning{footnotehyper}{Option `\CurrentOption' is unknown}}% \ProcessOptions\relax -\@ifpackageloaded{footnote} - {\PackageWarningNoLine{footnotehyper}% - {Please next time do not load package footnote,^^J - but leave that to me. For the time being, I will start by undoing the^^J - modifications it did to \string\parbox. Use \string\fnparbox\space if needed.}% - } - {\let\FNH@@makefntext\@makefntext\let\@makefntext\@firstofone - \RequirePackage{footnote} - \let\@makefntext\FNH@@makefntext - }% -\let\fnparbox\parbox\let\parbox\fn@parbox -\let\FNH@fn@footnote \footnote % footnote.sty's \footnote will get -\let\FNH@fn@footnotetext\footnotetext % redefined later. We preserve also -\let\footnote \fn@latex@@footnote % the meaning of \footnote from prior -\let\footnotetext\fn@latex@@footnotetext % to the loading of footnote.sty -\def\fn@endnote {\color@endgroup}% +\newbox\FNH@notes +\newdimen\FNH@width +\let\FNH@colwidth\columnwidth +\newif\ifFNH@savingnotes \AtBeginDocument {% - \let\fn@latex@@footnote \footnote % meaning of \footnote at end of preamble - \let\fn@latex@@footnotetext\footnotetext -}% -\AtBeginDocument{\@ifpackageloaded{hyperref} + \@ifpackageloaded{hyperref} {\ifHy@hyperfootnotes - \let\fn@fntext \FNH@hyper@fntext - \let\spewnotes \FNH@hyper@spewnotes - \let\endsavenotes\spewnotes - \let\fn@endfntext\FNH@fixed@endfntext - \let\footnote \FNH@fixed@footnote - \let\footnotetext\FNH@fixed@footnotetext + \let\FNH@latex@footnote \footnote + \let\FNH@latex@footnotetext\footnotetext + \newenvironment{savenotes} + {\FNH@savenotes\ignorespaces}{\FNH@spewnotes\ignorespacesafterend}% + \let\spewnotes \FNH@spewnotes + \let\footnote \FNH@footnote + \let\footnotetext \FNH@footnotetext + \let\endfootnote \FNH@endfntext + \let\endfootnotetext\FNH@endfntext \else - \FNH@inactive - \fi }{\FNH@inactive}% - \let\endfootnote\fn@endfntext - \let\endfootnotetext\endfootnote -}% -\def\FNH@fix@endfntext\@finalstrut\strutbox\fn@postfntext - {\@finalstrut\strutbox\fn@postfntext\fn@endnote}% -\def\FNH@inactive {% - \let\footnote \FNH@fn@footnote - \let\footnotetext\FNH@fn@footnotetext - \expandafter\expandafter\expandafter\def - \expandafter\expandafter\expandafter\fn@endfntext - \expandafter\expandafter\expandafter - {\expandafter\FNH@fix@endfntext\fn@endfntext}% \PackageInfo{footnotehyper}% - {hyperref package not loaded or hyperfootnotes^^J - =false option; I did not activate myself and only patched footnote.sty^^J - for color/xcolor compatibility, leaving some other issues unfixed.}}% -\def\FNH@hyper@fntext {\ifx\ifmeasuring@\undefined\expandafter\@secondoftwo - \else\expandafter\@firstofone\fi - {\ifmeasuring@\expandafter\@gobbletwo\fi}% - \FNH@hyper@fntext@i }% -\long\def\FNH@hyper@fntext@i #1{\global\setbox\fn@notes\vbox - {\unvbox\fn@notes - \fn@startnote - \@makefntext - {\rule\z@\footnotesep\ignorespaces - \ifHy@nesting\expandafter\ltx@firstoftwo - \else\expandafter\ltx@secondoftwo - \fi - {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}% - {\Hy@raisedlink - {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}% - {\relax}}% - \let\@currentHref\Hy@footnote@currentHref - \let\@currentlabelname\@empty - #1}% - \@finalstrut\strutbox }% - \fn@endnote }% -}% -\def\FNH@hyper@spewnotes {\endgroup - \if@savingnotes\else\ifvoid\fn@notes\else - \begingroup\let\@makefntext\@empty - \let\@finalstrut\@gobble - \let\rule\@gobbletwo - \H@@footnotetext{\unvbox\fn@notes}% - \endgroup\fi\fi -}% -\def\FNH@fixed@endfntext {% - \@finalstrut\strutbox - \fn@postfntext - \fn@endnote - \egroup\FNH@endfntext@next % will decide if link or no link + {inactive due to hyperfootnotes=false option}% + \fi}% + {\PackageWarning{footnotehyper}{^^J\@spaces\@spaces*************^^J% + \space deactivating myself as hyperref is not detected !^^J}}% }% -\def\FNH@endfntext@link {\begingroup - \let\@makefntext\@empty\let\@finalstrut\@gobble\let\rule\@gobbletwo - \@footnotetext {\unvbox\z@}% +\def\FNH@hyper@fntext{\FNH@fntext\FNH@hyper@fntext@i}% +\def\FNH@nohyp@fntext{\FNH@fntext\FNH@nohyp@fntext@i}% +\def\FNH@fntext #1{\ifx\ifmeasuring@\@undefined + \expandafter\@secondoftwo\else\expandafter\@firstofone\fi + {\ifmeasuring@\expandafter\@gobbletwo\fi}#1% +}% +\long\def\FNH@hyper@fntext@i#1{% + \global\setbox\FNH@notes\vbox + {\unvbox\FNH@notes + \FNH@startnote + \@makefntext + {\rule\z@\footnotesep\ignorespaces + \ifHy@nesting\expandafter\ltx@firstoftwo + \else\expandafter\ltx@secondoftwo + \fi + {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}{#1}}% + {\Hy@raisedlink + {\expandafter\hyper@@anchor\expandafter{\Hy@footnote@currentHref}% + {\relax}}% + \let\@currentHref\Hy@footnote@currentHref + \let\@currentlabelname\@empty + #1}% + \@finalstrut\strutbox + }% + \FNH@endnote + }% +}% +\long\def\FNH@nohyp@fntext@i#1{% + \global\setbox\FNH@notes\vbox + {\unvbox\FNH@notes + \FNH@startnote + \@makefntext{\rule\z@\footnotesep\ignorespaces#1\@finalstrut\strutbox}% + \FNH@endnote + }% +}% +\def\FNH@startnote{% + \hsize\FNH@colwidth + \interlinepenalty\interfootnotelinepenalty + \reset@font\footnotesize + \floatingpenalty\@MM% Is this right??? + \@parboxrestore + \protected@edef\@currentlabel{\csname p@\@mpfn\endcsname\@thefnmark}% + \color@begingroup +}% +\def\FNH@endnote{\color@endgroup}% +\def\FNH@savenotes{% + \begingroup + \ifFNH@savingnotes\else + \FNH@savingnotestrue + \let\@footnotetext \FNH@hyper@fntext + \let\@mpfootnotetext \FNH@hyper@fntext + \let\H@@mpfootnotetext\FNH@nohyp@fntext % fool hyperref's \@xfootnotetext + \FNH@width\columnwidth + \let\FNH@colwidth\FNH@width + \global\setbox\FNH@notes\box\voidb@x + \let\FNH@thempfn\thempfn + \let\FNH@mpfn\@mpfn + \ifx\@minipagerestore\relax\let\@minipagerestore\@empty\fi + \expandafter\def\expandafter\@minipagerestore\expandafter{% + \@minipagerestore + \let\thempfn\FNH@thempfn + \let\@mpfn\FNH@mpfn + }% + \fi +}% +\def\FNH@spewnotes {% + \endgroup + \ifFNH@savingnotes\else + \ifvoid\FNH@notes\else + \begingroup + \let\@makefntext\@empty + \let\@finalstrut\@gobble + \let\rule\@gobbletwo + \H@@footnotetext{\unvbox\FNH@notes}% \endgroup + \fi + \fi +}% +\def\FNH@footnote@envname {footnote}% +\def\FNH@footnotetext@envname{footnotetext}% +\def\FNH@footnote{% + \ifx\@currenvir\FNH@footnote@envname + \expandafter\FNH@footnoteenv + \else + \expandafter\FNH@latex@footnote + \fi +}% +\def\FNH@footnoteenv{% + \@ifnextchar[% + \FNH@footnoteenv@i %] + {\stepcounter\@mpfn + \protected@xdef\@thefnmark{\thempfn}% + \@footnotemark + \def\FNH@endfntext@fntext{\@footnotetext}% + \FNH@startfntext}% }% -\def\FNH@endfntext@nolink {\begingroup - \let\@makefntext\@empty\let\@finalstrut\@gobble - \let\rule\@gobbletwo - \if@savingnotes\expandafter\fn@fntext\else\expandafter\H@@footnotetext\fi - {\unvbox\z@}\endgroup -}% -\def\FNH@fixed@footnote {\ifx\@currenvir\fn@footnote - \expandafter\FNH@footnoteenv\else\expandafter\fn@latex@@footnote\fi }% -\def\FNH@footnoteenv {\@ifnextchar[\FNH@xfootnoteenv%] - {\stepcounter\@mpfn - \protected@xdef\@thefnmark{\thempfn}\@footnotemark - \def\FNH@endfntext@next{\FNH@endfntext@link}\fn@startfntext}}% -\def\FNH@xfootnoteenv [#1]{% +\def\FNH@footnoteenv@i[#1]{% \begingroup \csname c@\@mpfn\endcsname #1\relax \unrestored@protected@xdef\@thefnmark{\thempfn}% - \endgroup\@footnotemark\def\FNH@endfntext@next{\FNH@endfntext@link}% - \fn@startfntext}% -\def\FNH@fixed@footnotetext {\ifx\@currenvir\fn@footnotetext - \expandafter\FNH@footnotetextenv\else\expandafter\fn@latex@@footnotetext\fi}% -\def\FNH@footnotetextenv {\@ifnextchar[\FNH@xfootnotetextenv%] - {\protected@xdef\@thefnmark{\thempfn}% - \def\FNH@endfntext@next{\FNH@endfntext@link}\fn@startfntext}}% -\def\FNH@xfootnotetextenv [#1]{% + \endgroup + \@footnotemark + \def\FNH@endfntext@fntext{\@footnotetext}% + \FNH@startfntext +}% +\def\FNH@footnotetext{% + \ifx\@currenvir\FNH@footnotetext@envname + \expandafter\FNH@footnotetextenv + \else + \expandafter\FNH@latex@footnotetext + \fi +}% +\def\FNH@footnotetextenv{% + \@ifnextchar[% + \FNH@footnotetextenv@i %] + {\protected@xdef\@thefnmark{\thempfn}% + \def\FNH@endfntext@fntext{\@footnotetext}% + \FNH@startfntext}% +}% +\def\FNH@footnotetextenv@i[#1]{% \begingroup \csname c@\@mpfn\endcsname #1\relax \unrestored@protected@xdef\@thefnmark{\thempfn}% - \endgroup\def\FNH@endfntext@next{\FNH@endfntext@nolink}% - \fn@startfntext }% -\ifx\FNH@@makefntext\undefined\expandafter\@gobble - \else\expandafter\AtBeginDocument\fi -{% - \ifx\@makefntextFB\undefined - \expandafter\@gobble\else\expandafter\@firstofone\fi - {\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else - \let\FNH@@makefntext\@makefntextORI\fi}% - \expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}\FNH@@@1.2!3?4,\FNH@@@\relax -}% -\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3% -{% - \ifx\relax#3\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi - \FNH@bad@footnote@env - {\def\fn@prefntext{#1}\def\fn@postfntext{#2}\FNH@check@b}% -}% -\def\FNH@check@b #1\relax -{% + \endgroup + \ifFNH@savingnotes + \def\FNH@endfntext@fntext{\FNH@nohyp@fntext}% + \else + \def\FNH@endfntext@fntext{\H@@footnotetext}% + \fi + \FNH@startfntext +}% +\def\FNH@startfntext{% + \setbox\z@\vbox\bgroup + \FNH@startnote + \FNH@prefntext + \rule\z@\footnotesep\ignorespaces +}% +\def\FNH@endfntext {% + \@finalstrut\strutbox + \FNH@postfntext + \FNH@endnote + \egroup + \begingroup + \let\@makefntext\@empty\let\@finalstrut\@gobble\let\rule\@gobbletwo + \FNH@endfntext@fntext {\unvbox\z@}% + \endgroup +}% +\AtBeginDocument{\let\FNH@@makefntext\@makefntext + \ifx\@makefntextFB\undefined + \expandafter\@gobble\else\expandafter\@firstofone\fi + {\ifFBFrenchFootnotes \let\FNH@@makefntext\@makefntextFB \else + \let\FNH@@makefntext\@makefntextORI\fi}% + \expandafter\FNH@check@a\FNH@@makefntext{1.2!3?4,}% + \FNH@@@1.2!3?4,\FNH@@@\relax +}% +\long\def\FNH@check@a #11.2!3?4,#2\FNH@@@#3{% + \ifx\relax#3\expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi + \FNH@bad@makefntext@alert + {\def\FNH@prefntext{#1}\def\FNH@postfntext{#2}\FNH@check@b}% +}% +\def\FNH@check@b #1\relax{% \expandafter\expandafter\expandafter\FNH@check@c - \expandafter\meaning\expandafter\fn@prefntext - \meaning\fn@postfntext1.2!3?4,\FNH@check@c\relax -}% -\def\FNH@check@c #11.2!3?4,#2#3\relax - {\ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@footnote@env}% -\def\FNH@bad@footnote@env -{\PackageWarningNoLine{footnotehyper}% - {The footnote environment from package footnote^^J - will be dysfunctional, sorry (not my fault...). You may try to mail me the^^J - preamble and/or only the next lines:}% + \expandafter\meaning\expandafter\FNH@prefntext + \meaning\FNH@postfntext1.2!3?4,\FNH@check@c\relax +}% +\def\FNH@check@c #11.2!3?4,#2#3\relax{% + \ifx\FNH@check@c#2\expandafter\@gobble\fi\FNH@bad@makefntext@alert +}% +\def\FNH@bad@makefntext@alert{% + \PackageWarningNoLine{footnotehyper}% + {^^J The footnote environment will not be fully functional, sorry.^^J + You may try to email the author with the following information:}% \typeout{\meaning\@makefntext}% - \let\fn@prefntext\@empty\let\fn@postfntext\@empty + \let\FNH@prefntext\@empty\let\FNH@postfntext\@empty +}% +\def\makesavenoteenv{\@ifnextchar[\FNH@msne@ii\FNH@msne@i}%] +\def\FNH@msne@i #1{% + \expandafter\let\csname FNH$#1\expandafter\endcsname %$ + \csname #1\endcsname + \expandafter\let\csname endFNH$#1\expandafter\endcsname %$ + \csname end#1\endcsname + \FNH@msne@ii[#1]{FNH$#1}%$ +}% +\def\FNH@msne@ii[#1]#2{% + \expandafter\edef\csname#1\endcsname{% + \noexpand\savenotes + \expandafter\noexpand\csname#2\endcsname + }% + \expandafter\edef\csname end#1\endcsname{% + \expandafter\noexpand\csname end#2\endcsname + \noexpand\expandafter + \noexpand\spewnotes + \noexpand\if@endpe\noexpand\@endpetrue\noexpand\fi + }% }% \endinput %% -- cgit v1.2.3