From 1ffe0fb9a53db45d97308792ed99bf6beb2b19ca Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Wed, 8 Jan 2014 22:45:08 +0000
Subject: tablefootnote (8jan14)

git-svn-id: svn://tug.org/texlive/trunk@32609 c570f23f-e606-0410-a88d-b1316a301751
---
 .../source/latex/tablefootnote/tablefootnote.dtx   | 449 ++++++++++++++-------
 1 file changed, 314 insertions(+), 135 deletions(-)

(limited to 'Master/texmf-dist/source/latex/tablefootnote/tablefootnote.dtx')

diff --git a/Master/texmf-dist/source/latex/tablefootnote/tablefootnote.dtx b/Master/texmf-dist/source/latex/tablefootnote/tablefootnote.dtx
index cc1c3077b04..162ea0e73f5 100644
--- a/Master/texmf-dist/source/latex/tablefootnote/tablefootnote.dtx
+++ b/Master/texmf-dist/source/latex/tablefootnote/tablefootnote.dtx
@@ -1,9 +1,9 @@
 % \iffalse meta-comment
 %
 % File: tablefootnote.dtx
-% Version: 2012/07/29 v1.0h
+% Version: 2014/01/08 v1.1a
 %
-% Copyright (C) 2011 - 2012 by
+% Copyright (C) 2011 - 2014 by
 %    H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
 %
 % This work may be distributed and/or modified under the
@@ -84,7 +84,7 @@
 \input docstrip.tex
 \Msg{******************************************************************}
 \Msg{* Installation                                                   *}
-\Msg{* Package: tablefootnote 2012/07/29 v1.0h Table foot notes (HMM) *}
+\Msg{* Package: tablefootnote 2014/01/08 v1.1a Table foot notes (HMM) *}
 \Msg{******************************************************************}
 
 \keepsilent
@@ -96,9 +96,9 @@
 This is a generated file.
 
 Project: tablefootnote
-Version: 2012/07/29 v1.0h
+Version: 2014/01/08 v1.1a
 
-Copyright (C) 2011 - 2012 by
+Copyright (C) 2011 - 2014 by
     H.-Martin M"unch <Martin dot Muench at Uni-Bonn dot de>
 
 The usual disclaimer applies:
@@ -126,6 +126,8 @@ the README, and the derived files
    tablefootnote.ins, tablefootnote.drv,
    tablefootnote-example.tex, tablefootnote-example.pdf.
 
+In memoriam Tommy Muench + 2014/01/02.
+
 \endpreamble
 \let\MetaPrefix\DoubleperCent
 
@@ -181,7 +183,7 @@ the README, and the derived files
 %<*driver>
 \NeedsTeXFormat{LaTeX2e}[2011/06/27]
 \ProvidesFile{tablefootnote.drv}%
-  [2012/07/29 v1.0h Table foot notes (HMM)]
+  [2014/01/08 v1.1a Table foot notes (HMM)]
 \documentclass{ltxdoc}[2007/11/11]% v2.0u
 \usepackage{holtxdoc}[2012/03/21]%  v0.24
 %% tablefootnote may work with earlier versions of LaTeX2e and those
@@ -221,7 +223,7 @@ the README, and the derived files
 %
 % \fi
 %
-% \CheckSum{431}
+% \CheckSum{595}
 %
 % \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
@@ -271,7 +273,7 @@ the README, and the derived files
 % \DoNotIndex{\value,\arabic,\hline,\text,\caption,\centering,\clear,\url}
 %
 % \title{The \xpackage{tablefootnote} package}
-% \date{2012/07/29 v1.0h}
+% \date{2014/01/08 v1.1a}
 % \author{H.-Martin M\"{u}nch\\\xemail{Martin.Muench at Uni-Bonn.de}}
 %
 % \maketitle
@@ -302,39 +304,42 @@ the README, and the derived files
 %
 % \tableofcontents
 %
-% \bigskip
+% \pagebreak
 %
 % \section{Introduction\label{sec:Introduction}}
 %
 % \indent This \LaTeX{} package provides the command |\tablefootnote{...}| to be
 % used in a \texttt{table} or \texttt{sidewaystable} environment. In those
 % environments |\footnote{...}| would not work and would need to be replaced
-% by |\footnotemark| in the \texttt{(sideways)table} and |\footnotetext{...}|
-% after the \texttt{(sideways)table} environment ended. Additionally the counters
-% for \texttt{footnote} and (when the \xpackage{hyperref} package is used)
-% \texttt{Hfootnote} would need to be adjusted manually. Then still the hyperlinks
-% in a \texttt{(sideways)table} would not work. When the
-% \xpackage{footnotebackref} package is used, |\footnotemark| and
-% |\footnotetext{...}| would need to be redefined.
-% Just using |\tablefootnote{...}| in the (sideways)table does all this
-% automatically. (Compatibility with the \xpackage{footnotebackref} package
+% by |\footnotemark| in the \texttt{(sideways)\allowbreak table} and
+% |\footnotetext{...}| after the \texttt{(sideways)table} environment ended.
+% Additionally the counters for \texttt{footnote} and
+% (when the \xpackage{hyperref} package is used) \texttt{Hfootnote}
+% would need to be adjusted manually. Then still the hyperlinks
+% in a \texttt{(sideways)table} would not work.
+% When the \xpackage{footnotebackref} package is used,
+% |\footnotemark| and |\footnotetext{...}| would need to be redefined.
+% Just using |\tablefootnote{...}| (with optional argument for custom foot note
+% marks) in the (sideways)table does all this automatically.
+% (Compatibility with the \xpackage{footnotebackref} package
 % was achieved without redefining |\footnotemark| or |\footnotetext|.)
 % Redefining |\footnote| was \emph{not} done as to not create conflicts with
 % other packages.
 %
-% \pagebreak
-%
 % \section{Usage}
 %
 % \indent Just load the package placing
 % \begin{quote}
 %   |\usepackage{tablefootnote}|
 % \end{quote}
-% \enlargethispage{\baselineskip}
-% \noindent in the preamble of your \LaTeXe{} source file and use
-% |\tablefootnote{...}| instead of |\footnote{...}| in (sideways)tables.\\
+% \noindent in the preamble of your \LaTeXe{} source file and use\newline
+% |\tablefootnote{...}| instead of |\footnote{...}| and\newline
+% |\tablefootnote[...]{...}| instead of |\footnote[...]{...}|
+% in (sideways)\allowbreak tables.\\
 % When the \xpackage{footnotebackref} package is used,
-% it must be loaded before the \xpackage{tablefootnote} package.\\
+% it must be loaded before the \xpackage{tablefootnote} package
+% and the \xpackage{hyperrefpackage} with option |hyperfootnotes=true|
+% must be loaded, too. (Backreference{-}links without links do not make sense.)\\
 % When the \xpackage{rotating} package (for |sidewaystable|s) is used,
 % it must be loaded before the \xpackage{tablefootnote} package and it must be
 % a recent version (v2.16a, 2009/03/28, or newer).\\
@@ -362,9 +367,9 @@ the README, and the derived files
 % or |\FloatBarrier| from the \xpackage{picins} package
 % (\url{http://www.ctan.org/pkg/picins}) might help, too.
 % (Or after finishing the document, move the (sideways)table in the source code
-% near the position where it floats to.)
+% near the position where it floats to or use the optional footnote marks.)
 %
-% \bigskip
+% \pagebreak
 %
 % \section{Alternatives\label{sec:Alternatives}}
 %
@@ -383,8 +388,6 @@ the README, and the derived files
 %   change the table-caption!) \texttt{sidewaystable} does not work with it.\\
 %   \url{http://www.ctan.org/pkg/longtable}
 %
-% \pagebreak
-%
 % \item[-] The \xpackage{supertabular} package provides the \texttt{mpsupertabular}
 %   environment as replacement for the combined \texttt{table} and \texttt{tabular}
 %   environments. Footnotes are just tablenotes (with working hyperlinks when using the
@@ -422,6 +425,8 @@ the README, and the derived files
 %   Therefore there is no float problem (because the footnotes are not continuously
 %   numbered). The hyperlinks to the table notes indeed work.
 %
+% \pagebreak[3]
+%
 % \item[-] The \xpackage{threeparttable} package creates tablenotes again. Therefore
 %   there is no float problem (because the tablenotes are not continuously numbered with
 %   the footnotes). There are no hyperlinks to the table notes (at least not automatically).
@@ -437,8 +442,6 @@ the README, and the derived files
 %   directly without \xpackage{threeparttablex} (see above).\\
 %   \url{http://www.ctan.org/pkg/threeparttablex}
 %
-% \pagebreak
-%
 % \item[-] One can manually use |\footnotemark| in the table and |\footnotetext{...}|
 %  after the table environment ended and manually change the |footnote| and
 %  (when the \xpackage{hyperref} package is used) |Hfootnote| counters and needs
@@ -477,6 +480,7 @@ the README, and the derived files
 \usepackage{placeins}[2005/04/18]% v2.2  ; for \FloatBarrier
 \usepackage{rotating}[2009/03/28]% v2.16a; for sidewaystable-environment
 \usepackage[%
+ hyperfootnotes=true,%
  extension=pdf,%
  plainpages=false,%
  pdfpagelabels=true,%
@@ -493,11 +497,12 @@ the README, and the derived files
  % print is OK for all those options
  pdfstartview=FitH,%
  pdfpagelayout=OneColumn%
-]{hyperref}[2012/02/28]% v6.82p
+]{hyperref}[2012/11/06]% v6.83m
  % Due to the urls used in the example, either the hyperref or the url
  % package are needed (or the urls must be removed before compiling).
 
-\usepackage{tablefootnote}[2012/07/29]% v1.0h
+\usepackage{footnotebackref}[2012/07/01]% v1.0
+\usepackage{tablefootnote}[2014/01/08]%   v1.1a
 
 \gdef\unit#1{\mathord{\thinspace\mathrm{#1}}}%
 \listfiles
@@ -506,7 +511,7 @@ the README, and the derived files
 \section*{Example for tablefootnote}
 
 This example demonstrates the use of package\newline
-\textsf{tablefootnote}, v1.0h as of 2012/07/29 (HMM).\newline
+\textsf{tablefootnote}, v1.1a as of 2014/01/08 (HMM).\newline
 There were no options used. (The package provides no options.)\newline
 
 \textbf{The \texttt{tablefootnote-example.tex} needs to be compiled
@@ -529,7 +534,7 @@ specifier~\texttt{H} from the float package.\newline
 
 \texttt{Hyperref} option \verb|pdfview=FitH| and \verb|FitBH| do
 not work due to a bug in pdf\TeX{}, computing wrong
-anchor coordinates (\textsc{Heiko Oberdiek}, 29. October 2011).
+anchor coordinates (\textsc{Heiko Oberdiek}, 29.~October 2011).
 Depending on used pdf-viewer, hyperlinks in sidewaystables lead
 e.\,g.~at the end of the document, not at the footnote.
 \verb|pdfview=Fit|, \verb|FitV|, \verb|FitR|, \verb|FitB|,
@@ -543,7 +548,7 @@ e.\,g.~at the end of the document, not at the footnote.
 
 \renewcommand{\thefootnote}{\fnsymbol{footnote}}
 \verb|\renewcommand{\thefootnote}{\fnsymbol{footnote}}|
-causes footnote-symbol-footnotes, which are possible
+causes footnote{-}symbol{-}footnotes, which are possible
 (see Table~\ref{tab.symbol}).
 
 \begin{table}
@@ -569,7 +574,7 @@ switches back to normal footnote numbers again.
 \centering
 \begin{tabular}{ccc}
 Some\tablefootnote{A table footnote.} & %
-text\tablefootnote{Another table footnote.} & %
+text\tablefootnote[99]{A table footnote with custom footnote number.} & %
 in a table\tablefootnote{A third table footnote.}
 \end{tabular}
 \caption[A table]{A normal table.\label{tab.normal}}
@@ -606,7 +611,8 @@ at the same page before the table, or place the table in
 \verb|\clear(double)page|, \verb|h(!)|, \verb|H|~from the
 \texttt{float} package, or \verb|\FloatBarrier| from the
 \texttt{picins} package might help, too. (Or move the table in the
-source code near the position where it floats to.)
+source code near the position where it floats to
+or use the optional footnote marks.)
 
 Table~\ref{tab.floatH} (page~\pageref{tab.floatH}) uses float specifier
 \texttt{H} from the float package and does not float.
@@ -622,7 +628,8 @@ Some text.\footnote{This is just another text footnote.}
 \begin{tabular}{ccc}
 Text\tablefootnote{Please rotate the view for testing the %
 hyperlinks.} & %
-in a\tablefootnote{Another sidewaystable footnote.} & %
+in a\tablefootnote[98]{Another sidewaystable footnote %
+with optional footnote mark.} & %
 sidewaystable%
 \tablefootnote{Sidewaystable-environment provided by %
 \url{http://CTAN.org/pkg/rotating} package.}
@@ -658,7 +665,8 @@ Some text.\footnote{This is just another text footnote.}
 \pagebreak
 
 End of the example for the
-tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
+tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}}
+package.
 
 \end{document}
 %</example>
@@ -679,7 +687,7 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %
 %    \begin{macrocode}
 \NeedsTeXFormat{LaTeX2e}[2011/06/27]
-\ProvidesPackage{tablefootnote}[2012/07/29 v1.0h
+\ProvidesPackage{tablefootnote}[2014/01/08 v1.1a
               Table foot notes (HMM)]
 %    \end{macrocode}
 %
@@ -697,6 +705,7 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %    \begin{macrocode}
 \RequirePackage{ltxcmds}[2011/11/09]%     v1.22
 \RequirePackage{letltxmacro}[2010/09/02]% v1.4
+\RequirePackage{xifthen}[2009/04/17]%     v1.3
 %    \end{macrocode}
 %
 % A last information for the user:
@@ -761,13 +770,13 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
       \newcommand\tablemakefntext[1]{%
         \noindent\makebox[1.634em][r]{%
          \mbox{\textsuperscript{\normalfont%
-           \hyperlink{tfn:\theHfootnote}{\@thefnmark}%
+           \hyperlink{tfn:m\theHfootnote}{\@thefnmark}%
         }}}%
-        \,#1%
+        \ #1%
       }
     \else
       \newcommand\tablemakefntext[1]{%
-        \noindent\makebox[1.8em][r]{%1.634
+        \noindent\makebox[1.8em][r]{%
           \mbox{\textsuperscript{\normalfont%
             \@thefnmark%
         }}}%
@@ -779,18 +788,18 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
       \noindent\makebox[1.8em][r]{%
         \mbox{\textsuperscript{\normalfont%
           \ifFootnoteBackref@numberlinked%
-            \hyperlink{tfn:\theHfootnote}{\@thefnmark}\,%
+            \hyperlink{tfn:m\theHfootnote}{\@thefnmark}\ %
           \else%
             \@thefnmark%
           \fi%
       }}}%
-      \hyperlink{tfn:\theHfootnote}{\FootnoteBackref@symbol}%
+      \hyperlink{tfn:m\theHfootnote}{\FootnoteBackref@symbol}%
       #1%
     }
   \fi
-}{
+}{%
   \newcommand\tablemakefntext[1]{%
-    \noindent\makebox[1.8em][r]{%1.634
+    \noindent\makebox[1.8em][r]{%
       \mbox{\textsuperscript{\normalfont%
         \@thefnmark%
     }}}%
@@ -821,14 +830,29 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 % the back reference.
 %
 %    \begin{macrocode}
-\newcommand{\tfn@footnotemarks}{%
+\newcommand{\tfn@footnotemarks}[1][]{%
   \hbox{%
-  \footnotemark%
-  \ltx@ifpackageloaded{footnotebackref}{%
-    \raisebox{\ht\strutbox}{\hypertarget{tfn:\theHfootnote}{}}%
-   }{% footnotebackref not loaded
+    \ifthenelse{\isempty{#1}}%
+      {\footnotemark%
+       \ltx@ifpackageloaded{footnotebackref}%
+         {\raisebox{\ht\strutbox}{\hypertarget{tfn:m\theHfootnote}{}}}%
+         {% footnotebackref not loaded
+         }%
+      }%
+      {\ltx@ifpackageloaded{hyperref}%
+        {\ifHy@hyperfootnotes%
+           \hyperlink{tfn:#1}{\footnotemark[#1]}%
+         \else%
+           \footnotemark[#1]%
+         \fi%
+        }%
+        {\footnotemark[#1]}%
+       \ltx@ifpackageloaded{footnotebackref}%
+        {\raisebox{\ht\strutbox}{\hypertarget{tfn:m#1}{}}}%
+        {% footnotebackref not loaded
+        }%
+      }%
    }%
-  }%
   \@tempcnta=\tfn@footnotetablecount\relax%
   \advance\@tempcnta by -1%
   \xdef\tfn@footnotetablecount{\the\@tempcnta}%
@@ -853,71 +877,101 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
       Unfortunately package tablefootnote is not yet\MessageBreak%
       able to regard this in sidewaystables.\MessageBreak%
       Here the footnotes are printed one below\MessageBreak%
-      the other. Sorry.\MessageBreak%
+      the other. Sorry!\MessageBreak%
      }%
   \fi%
   }
 
+%    \end{macrocode}
+% \end{macro}
+%
+% \pagebreak
+%
+% \begin{macro}{\tfn@updateHyper}
+% |\tfn@updateHyper| updates some \xpackage{hyperref} internals.
+%
+%    \begin{macrocode}
+\newcommand{\tfn@updateHyper}{%
+  % The code of this command is partly from the
+  % hyperref package by Heiko Oberdiek, 2011/10/01, v6.82j.
+  % Newer versions of that package are available at CTAN.
+  \global\let\Hy@saved@currentHref\@currentHref%
+  \ifHy@hyperfootnotes%
+    \hyper@makecurrent{Hfootnote}%
+  \fi%
+  \global\let\Hy@footnote@currentHref\@currentHref%
+  \global\let\@currentHref\Hy@saved@currentHref%
+  }
+
 %    \end{macrocode}
 % \end{macro}
 %
 % \begin{macro}{\tfn@footnotetext}
-% |\tfn@footnotetext| contains the |\footnotetext{...}| command and handles the
-% numbering. |\tfn@footnotetext| will be executed after the table. The foot note
-% counter has been increased automatically with each |\footnotemark|, therefore
-% it must be reset to its value before the table began.
+% |\tfn@footnotetext| contains the |\footnotetext[...]{...}| command and handles
+% the numbering. |\tfn@footnotetext| will be executed after the table.
+% The foot note counter has been increased automatically with each |\footnotemark|,
+% therefore it must be reset to its value before the table began.
 %
 %    \begin{macrocode}
-\newcommand{\tfn@footnotetext}[1]{%
+\newcommand{\tfn@footnotetext}[2][]{%
   \ifx\tfn@footnotetableprint\tfn@footnotezero%
     % This is the first footnotetext after the (sideways)table.
     \addtocounter{footnote}{\tfn@footnotetablecount}%
 %    \end{macrocode}
 %
 % When the \xpackage{hyperref} package is used, also its |Hfootnote| counter must
-% be reset.
+% be reset (when the footnotes are hyperlinked).
 %
 %    \begin{macrocode}
     \ltx@ifpackageloaded{hyperref}{%
-      \addtocounter{Hfootnote}{\tfn@footnotetablecount}%
+      \ifHy@hyperfootnotes%
+        \addtocounter{Hfootnote}{\tfn@footnotetablecount}%
+      \fi%
+      \tfn@updateHyper%
      }{}%
   \fi%
 %    \end{macrocode}
 %
 % For issuing the text for the next footnote the footnote-counter
-% (and |Hfootnote| counter) are increased by one.
+% (and |Hfootnote| counter in case of links) are increased by one.
 %
 %    \begin{macrocode}
   \addtocounter{footnote}{+1}%
   \ltx@ifpackageloaded{hyperref}{%
-    \addtocounter{Hfootnote}{+1}%
+    \ifHy@hyperfootnotes%
+      \addtocounter{Hfootnote}{+1}%
+    \fi%
 %    \end{macrocode}
 %
 % The \xpackage{hyperref} package was not expecting this kind of change of the
 % |(H)footnote| numbers, therefore some code-lines are missing here which can be
-% found at other places in that same package.
+% found at other places in that same package and are called by this command.
 %
 %    \begin{macrocode}
-    % Code from the hyperref package by Heiko Oberdiek,
-    % 2011/10/01, v6.82j, newer versions available
-    \global\let\Hy@saved@currentHref\@currentHref%
-    \hyper@makecurrent{Hfootnote}%
-    \global\let\Hy@footnote@currentHref\@currentHref%
-    \global\let\@currentHref\Hy@saved@currentHref%
-    % End of code form the hyperref package
+    \tfn@updateHyper%
 %    \end{macrocode}
 %
 % When \xpackage{hyperref} is not loaded, nothing is to be done here.
 %
 %    \begin{macrocode}
-   }{}% else \relax
+   }{}%
 %    \end{macrocode}
 %
-% The |\footnotetext{...}| places the foot note text as usual.
+% The |\footnotetext[...]{...}| places the foot note text as usual.
 %
 %    \begin{macrocode}
   \ifx\tfn@swt\tfn@footnotezero%
-    \footnotetext{#1}%
+    \ifthenelse{\isempty{#1}}%
+      {\footnotetext{#2}}%
+      {\ltx@ifpackageloaded{hyperref}%
+        {\ifHy@hyperfootnotes%
+           \footnotetext[#1]{%
+              \raisebox{\ht\strutbox}{\hypertarget{tfn:#1}{}}#2}%
+         \else%
+           \footnotetext[#1]{#2}%
+         \fi%
+        }{\footnotetext[#1]{#2}}%
+      }%
   \else%
 %    \end{macrocode}
 %
@@ -947,26 +1001,87 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 % back references must be created for the table footnotes, too.
 %
 %    \begin{macrocode}
-  \ltx@ifpackageloaded{footnotebackref}{%
-    \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
-    \LetLtxMacro{\@makefntext}{\swtablemakefntext}%
-    \footnotetext{\hbox {\@textsuperscript {\normalfont %
-                           \hyperlink{tfn:\theHfootnote}{\thefootnote}%
-      }}\thinspace %
-      \ifx\FootnoteBackref@symbol\empty%
-      \else\hyperlink{tfn:\theHfootnote}{\FootnoteBackref@symbol}%
-      \fi%
-      #1}%
-    \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
-   }{% footnotebackref not loaded
-    \footnotetext{\hbox {\@textsuperscript {\normalfont \thefootnote %
-      }}\thinspace #1}%
-   }%
+    \ltx@ifpackageloaded{footnotebackref}{%
+      \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
+      \LetLtxMacro{\@makefntext}{\swtablemakefntext}%
+      \ifthenelse{\isempty{#1}}%
+        {\footnotetext{%
+           \raisebox{\ht\strutbox}{\hypertarget{tfn:\theHfootnote}{}}%
+           \hbox{\@textsuperscript{\normalfont%
+                \hyperlink{tfn:m\theHfootnote}{\thefootnote}}}\thinspace%
+         \ifx\FootnoteBackref@symbol\empty%
+         \else\hyperlink{tfn:m\theHfootnote}{\FootnoteBackref@symbol}%
+         \fi%
+         #2}%
+       }{\edef\tfn@tfn{\arabic{footnote}}%
+         \edef\tfn@thn{\arabic{Hfootnote}}%
+         \setcounter{footnote}{#1}%
+         \setcounter{Hfootnote}{#1}%
+         \tfn@updateHyper%
+         \footnotetext{%
+           \raisebox{\ht\strutbox}{\hypertarget{tfn:#1}{}}%
+           \hbox{\@textsuperscript{\normalfont%
+                  \hyperlink{tfn:m#1}{#1}}}%
+           \thinspace%
+           \ifx\FootnoteBackref@symbol\empty%
+           \else%
+             \raisebox{\ht\strutbox}{%
+               \hyperlink{tfn:m#1}{\FootnoteBackref@symbol}}%
+           \fi%
+           #2%
+          }%
+         \setcounter{footnote}{\tfn@tfn}%
+         \setcounter{Hfootnote}{\tfn@thn}%
+         \tfn@updateHyper%
+       }%
+      \LetLtxMacro{\@makefntext}{\tfncurrentmft}%
+     }{% footnotebackref not loaded
+       \ifthenelse{\isempty{#1}}%
+         {\footnotetext{%
+            \hbox{\@textsuperscript{\normalfont\thefootnote}}%
+            \ltx@ifpackageloaded{hyperref}%
+             {\ifHy@hyperfootnotes%%
+                \raisebox{\ht\strutbox}{%
+                                    \hypertarget{tfn:\theHfootnote}{}}%
+              \fi%
+             }%
+             {\relax}%
+            \thinspace%
+            #2}%
+        }{\edef\tfn@tfn{\arabic{footnote}}%
+          \ltx@ifpackageloaded{hyperref}{%
+            \ifHy@hyperfootnotes%
+              \edef\tfn@thn{\arabic{Hfootnote}}%
+            \fi%
+           }{}% else \relax
+          \setcounter{footnote}{#1}
+          \ltx@ifpackageloaded{hyperref}{%
+            \ifHy@hyperfootnotes%
+              \setcounter{Hfootnote}{#1}%
+            \fi%
+            \tfn@updateHyper%
+           }{}%
+          \footnotetext{%
+            \hbox{\@textsuperscript{\normalfont #1}}%
+            \ltx@ifpackageloaded{hyperref}%
+             {\ifHy@hyperfootnotes%
+                \raisebox{\ht\strutbox}{\hypertarget{tfn:#1}{}}%
+              \fi%
+             }{}%
+            \thinspace%
+            #2}%
+          \setcounter{footnote}{\tfn@tfn}%
+          \ltx@ifpackageloaded{hyperref}{%
+            \ifHy@hyperfootnotes%
+              \setcounter{Hfootnote}{\tfn@thn}%
+            \fi%
+            \tfn@updateHyper%
+           }{}%
+        }%
+     }%
   \fi%
 %    \end{macrocode}
 %
-% \pagebreak
-%
 % For further footnotes in the table the \\
 % |\ifx\tfn@footnotetableprint\tfn@footnotezero|\ldots|\fi| \\
 % from the beginning of this |\tfn@footnotetext| macro must not be repeated,
@@ -1013,22 +1128,46 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 % \end{macro}
 %
 % \begin{macro}{\tablefootnote}
-% |\tablefootnote{...}| is the command to be used by the user instead of |\footnote{...}|
-% in the table. It places a foot note mark via |\tfn@footnotemarks| and appends a
-% |\tfn@footnotetext{#1}| to the |\tfn@tablefootnoteprintout| macro. (And remembers that
-% table foot notes have been used.)
+% |\tablefootnote[...]{...}| is the command to be used by the user instead of
+% |\footnote[...]{...}| in the (sideways)table. It places a foot note mark via
+% |\tfn@footnotemarks| and appends a |\tfn@footnotetext{#1}| to the\\
+% |\tfn@tablefootnoteprintout| macro. (And remembers that table foot notes
+% have been used.)
 %
 %    \begin{macrocode}
-\newcommand{\tablefootnote}[1]{%
-\tfn@footnotemarks%
-\ltx@GlobalAppendToMacro{%
-\tfn@tablefootnoteprintout}{\tfn@footnotetext{#1}}%
-\gdef\tfn@fnt{1}%
+\newcommand{\tablefootnote}[2][]{%
+  \tfn@footnotemarks[#1]%
+  \ifthenelse{\isempty{#1}}{\relax}{%
+    \ltx@GlobalPrependToMacro{\tfn@tablefootnoteprintout}{%
+      \addtocounter{footnote}{+1}%
+      \ltx@ifpackageloaded{hyperref}{%
+        \ifHy@hyperfootnotes%
+          \addtocounter{Hfootnote}{+1}%
+        \fi%
+        \tfn@updateHyper%
+       }{}%
+     }%
+   }%
+  \ltx@GlobalAppendToMacro{\tfn@tablefootnoteprintout}{%
+    \tfn@footnotetext[#1]{#2}%
+    \ifthenelse{\isempty{#1}}{\relax}{%
+      \addtocounter{footnote}{-1}%
+      \ltx@ifpackageloaded{hyperref}{%
+        \ifHy@hyperfootnotes%
+          \addtocounter{Hfootnote}{-1}%
+        \fi%
+        \tfn@updateHyper%
+       }{}%
+     }%
+   }%
+  \gdef\tfn@fnt{1}%
 }
 
 %    \end{macrocode}
 % \end{macro}
 %
+% \pagebreak
+%
 % \begin{macro}{\tfn@swtbox}
 % For |sidewaystable|s the |\tfn@tablefootnoteprintout| is placed in a \\
 % |\parbox|, which can be placed at the end of the |sidewaystable|:
@@ -1040,14 +1179,12 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 \else%
 \vskip \skip\footins%
 \fi%
-\parbox[b][][t]{\linewidth}{\raggedright \tfn@tablefootnoteprintout}%
+\parbox[b][][t]{\linewidth}{\raggedright\tfn@tablefootnoteprintout}%
 }
 
 %    \end{macrocode}
 % \end{macro}
 %
-% \pagebreak
-%
 % |\tfn@tablefootnoteprintout| shall be executed after the end of the table environment.
 % The \xpackage{etoolbox} package provides very easy syntax for this:
 %
@@ -1067,8 +1204,8 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
    }%
 %    \end{macrocode}
 %
-% When the \xpackage{rotating} package has been loaded, we need to detect whether the
-% |\tablefootnote| is placed inside of a |sidewaystable|.
+% When the \xpackage{rotating} package has been loaded, we need to detect
+% whether the |\tablefootnote| is placed inside of a |sidewaystable|.
 %
 %    \begin{macrocode}
   \ltx@ifpackageloaded{rotating}{%
@@ -1078,8 +1215,8 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %    \end{macrocode}
 %
 % At the end of |sidewaystable| environments |\tfn@swtbox| shall be placed
-% (if~there was any |\tablefootnote| in that |sidewaystable| at all). And
-% |\tfn@swt| as well as |\tfn@fnt| must be reset to |0|.
+% (if~there was any |\tablefootnote| in that |sidewaystable| at all).
+% And |\tfn@swt| as well as |\tfn@fnt| must be reset to |0|.
 %
 %    \begin{macrocode}
     \AtEndEnvironment{sidewaystable}{%
@@ -1101,6 +1238,8 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 }{%
 %    \end{macrocode}
 %
+% \pagebreak
+%
 % When the \xpackage{etoolbox} package is not available (e.\,g. because of missing
 % \eTeX{}) we~do a workaround:
 %
@@ -1172,11 +1311,6 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
      }{\relax}
     \tfnorigtable%
    }{%
-%    \end{macrocode}
-%
-% \pagebreak
-%
-%    \begin{macrocode}
      \tfnendorigtable%
      \ltx@ifpackageloaded{footnotebackref}{%
        \LetLtxMacro{\tfncurrentmft}{\@makefntext}%
@@ -1220,6 +1354,8 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 
 %    \end{macrocode}
 %
+% \pagebreak
+%
 % \DescribeMacro{\AtBeginDocument}
 % When the \xpackage{rotating} (for |sidewaystable|s) or the
 % \xpackage{footnotebackref} (for back references for the footnotes)
@@ -1235,10 +1371,10 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
     \ifx\tfn@fnbr\tfn@footnotezero%
       \PackageError{tablefootnote}{%
         Package footnotebackref loaded after tablefootnote}{%
-        When using both the footnotebackref and the tablefootnote package,%
-        \MessageBreak%
-        the footnotebackref package MUST be loaded before the tablefootnote%
-        \space package!\MessageBreak%
+        When using both the footnotebackref and the tablefootnote %
+        package,\MessageBreak%
+        the footnotebackref package MUST be loaded before the %
+        tablefootnote package!\MessageBreak%
        }%
     \fi%
    }{% else \relax
@@ -1261,22 +1397,59 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 % will be misplaced, regardless of the use of the \xpackage{tablefootnote} package
 % (or of tables or footnotes). The text to be printed will be OK.
 % This problem of \LuaLaTeX{} (not \xpackage{tablefootnote}) was found and reported
-% by \textsc{Arno Trautmann}, 2011/11/15 - thanks!
+% by \textsc{Arno Trautmann}, 2011/11/15 -- thanks!
 %
 %    \begin{macrocode}
   \ltx@ifpackageloaded{hyperref}{%
+    \ifHy@hyperfootnotes%
     \ifluatex%
       \PackageWarningNoLine{tablefootnote}{%
-        LuaTeX & hyperref used:\MessageBreak%
+        LuaTeX and hyperref package used:\MessageBreak%
         Hyperreferences in rotated content\MessageBreak%
         will be misplaced\MessageBreak%
         regardless of tablefootnote package.\MessageBreak%
         The text to be printed will be OK%
        }%
     \fi%
+    \fi%
    }{% else \relax
    }%
-  }
+%    \end{macrocode}
+%
+% \pagebreak
+%
+% When the \xpackage{footnotebackref}-package is used but the footnotes are not
+% hyperlinked, neither the back references nor the tablefootnotes will work.
+%
+%    \begin{macrocode}
+  \ltx@ifpackageloaded{footnotebackref}{%
+    \ltx@ifpackageloaded{hyperref}{
+      \ifHy@hyperfootnotes%
+        \relax%
+      \else%
+        \PackageError{tablefootnote}{%
+          footnotebackref but not hyperfootnotes}{%
+          The footnotebackref package is used\MessageBreak%
+          but the hyperfootnotes option of the hyperref package%
+          \MessageBreak%
+          was set to false.\MessageBreak%
+          Either enable hyperfootnotes or do not use footnotebackref.%
+          \MessageBreak%
+          Loading of the tablefootnote package will be aborted.%
+        }%
+        \endinput%
+      \fi%
+    }{\PackageError{tablefootnote}{footnotebackref but not hyperref}{%
+        The footnotebackref package is used\MessageBreak%
+        but not the hyperref package.\MessageBreak%
+        Either load hyperref or do not use footnotebackref.%
+        \MessageBreak%
+        Loading of the tablefootnote package will be aborted.%
+        }%
+      \endinput
+    }%
+  }{}
+}
 
 %    \end{macrocode}
 %
@@ -1348,10 +1521,10 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %           \url{http://ctan.org/pkg/placeins}\\
 %           for |\FloatBarrier|
 %
-% \item[-] package \xpackage{hyperref}, 2012/02/28, v6.82p,
+% \item[-] package \xpackage{hyperref}, 2012/11/06, v6.83m,
 %           \url{http://ctan.org/pkg/hyperref}
 %
-% \item[-] package \xpackage{tablefootnote}, 2012/07/29, v1.0h,\\
+% \item[-] package \xpackage{tablefootnote}, 2014/01/08, v1.1a,\\
 %           \url{http://ctan.org/pkg/tablefootnote}\\
 %   (Well, it is the example file for this package, and because you
 %    are reading the documentation for the \xpackage{tablefootnote} package,
@@ -1380,7 +1553,7 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %
 % \DescribeMacro{M\"{u}nch}
 % A hyperlinked list of my (other) packages can be found at
-% \url{http://www.Uni-Bonn.de/~uzs5pv/LaTeX.html}.\\
+% \url{http://ctan.org/author/muench-hm}.\\
 %
 % \subsection{Package, unpacking TDS}
 % \paragraph{Package.} This package is available on \CTAN{}
@@ -1418,7 +1591,7 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %   \verb|tex tablefootnote.dtx|
 % \end{quote}
 %
-% About generating the documentation see paragraph~\ref{GenDoc} below.\\
+% \noindent About generating the documentation see paragraph~\ref{GenDoc} below.\\
 %
 % \paragraph{TDS.} Now the different files must be moved into
 % the different directories in your installation TDS tree
@@ -1498,7 +1671,7 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %
 % \subsection{Refresh file name databases}
 %
-% If your \TeX{}~distribution (\teTeX{}, \mikTeX{},\dots{}) relies on file name
+% If your \TeX{}~distribution (\TeX live, \mikTeX{}, \dots{}) relies on file name
 % databases, you must refresh these. For example, \teTeX{} users run
 % \verb|texhash| or \verb|mktexlsr|.
 %
@@ -1560,11 +1733,14 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 % (from which I also got everything I know about creating a file in
 % \xext{dtx} format, OK, say it: copying),
 % and for information about the \pdfTeX{}-bug,
-% \textsc{Arno Trautmann} for reporting the bug (misplaced hyperreferences in
+% \textsc{Arno Trautmann} for reporting the bug of misplaced hyperreferences in
 % |sidewaystable|s using \LuaTeX{}, independently of the \xpackage{tablefootnote}
-% package or footnotes at all) and the \Newsgroup{comp.text.tex}
-% and \Newsgroup{de.comp.text.tex} newsgroups as well as everybody at
-% \url{http://tex.stackexchange.com/} for their help in all things \TeX{}.
+% package or footnotes at all,
+% \textsc{Thomas~V.} for reporting the bug of not handling the case of
+% \xpackage{hyperref} option |hyperfootnotes=false|,
+% and the \Newsgroup{comp.text.tex} and \Newsgroup{de.comp.text.tex} newsgroups
+% as well as everybody at \url{http://tex.stackexchange.com}
+% for their help in all things \TeX{}.
 %
 % \pagebreak
 %
@@ -1584,7 +1760,6 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %     \item Bug fix: When \xpackage{etoolbox.sty} was not found, and the \xpackage{float}
 %             package had been loaded, and the float specifier was \texttt{H},
 %             then the |\tablefootnote|s were not printed for that table. Fixed.
-%     \item Minor details.
 %   \end{Version}
 %   \begin{Version}{2011/11/19 v1.0d}
 %     \item Replaced |{}^{\text{\textup{\thefootnote}}}| by
@@ -1606,7 +1781,7 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %             to
 %  \begin{verbatim}
 %  \vspace{2\baselineskip}%
-%  \parbox[b][][t]{\linewidth}{\raggedright \tfn@tablefootnoteprintout}%
+%  \parbox[b][][t]{\linewidth}{\raggedright\tfn@tablefootnoteprintout}%
 %  \end{verbatim}
 %             , therefore the \xpackage{setspace} and \xpackage{subcaption} packages
 %             are no longer required by the \xpackage{tablefootnote} package.
@@ -1621,9 +1796,8 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %            \xpackage{hyperref} package are used together. Hyperreferences in
 %            |sidewaystable|s are misplaced, independently of the
 %            \xpackage{tablefootnote} package or footnotes at all. (Bug reported
-%            by \textsc{Arno Trautmann}, 2011/11/15 - thanks!)
+%            by \textsc{Arno Trautmann}, 2011/11/15 -- thanks!)
 %     \item Added footnotesymbol-footnote-numbers in the example.
-%     \item Several details.
 %   \end{Version}
 %   \begin{Version}{2011/11/26 v1.0e}
 %     \item Check for \xpackage{hyperref} is only done once.
@@ -1641,11 +1815,9 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %     \item The warning about un-regarded |para|-option of \xpackage{footmoisc}
 %             package is only given at the second |tablefootnote| in a |sidewaystable|,
 %             not repeatedly for every |tablefootnote| in a |sidewaystable|.
-%     \item Minor details.
 %   \end{Version}
 %   \begin{Version}{2012/01/01 v1.0f}
 %     \item Bugfix: Wrong installation path given in the documentation, fixed.
-%     \item Minor details.
 %     \item Update of documentation, README, and \xfile{dtx} internals.
 %   \end{Version}
 %   \begin{Version}{2012/01/14 v1.0g}
@@ -1655,7 +1827,14 @@ tablefootnote\footnote{\url{http://CTAN.org/pkg/tablefootnote}} package.
 %     \item \xpackage{tablefootnote} is now compatible to the new
 %             \xpackage{footnotebackref} package, 2012/07/01, v1.0,
 %             \url{http://www.ctan.org/pkg/footnotebackref}.
-%     \item Minor details.
+%   \end{Version}
+%   \begin{Version}{2014/01/08 v1.1a}
+%     \item Tablefootnotes now regard optional footnote marks:
+%             |\tablefootnote[| custom mark here! |]{...}|
+%     \item Bug fix: the case of \xpackage{hyperref} option |hyperfootnotes=false|
+%             was not handeled at all. (Bug reported by \textsc{Thomas~V.}, %
+%             2014/01/02 -- thanks!)
+%     \item A lot of details.
 %   \end{Version}
 % \end{History}
 %
-- 
cgit v1.2.3

