summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/endnotes/endnotes.sty
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-01-05 03:00:30 +0000
committerNorbert Preining <norbert@preining.info>2020-01-05 03:00:30 +0000
commitd703bc2777b69363e791c0ec50045947b1a399da (patch)
tree518c616bdf53da2c5dccf1bbd0a17ba14d4b7c7a /macros/latex/contrib/endnotes/endnotes.sty
parent46d85b2b8e0282e241f8a41c6c0cd190c495eab0 (diff)
CTAN sync 202001050300
Diffstat (limited to 'macros/latex/contrib/endnotes/endnotes.sty')
-rw-r--r--macros/latex/contrib/endnotes/endnotes.sty27
1 files changed, 25 insertions, 2 deletions
diff --git a/macros/latex/contrib/endnotes/endnotes.sty b/macros/latex/contrib/endnotes/endnotes.sty
index d3ef6514ba..7d428d167d 100644
--- a/macros/latex/contrib/endnotes/endnotes.sty
+++ b/macros/latex/contrib/endnotes/endnotes.sty
@@ -4,9 +4,10 @@
% * ENDNOTES *
% ****************************************
%
-% Date of this version: 15 January 2003.
+% Date of this version: 02 January 2020.
%
%% Copyright 2002 John Lavagnino
+%% Copyright 2019-2020 LaTeX3 Project
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.2
@@ -114,6 +115,11 @@
% Frank's updates.
%
%
+% Jürgen Spitzmüller 2019-08-17: just warn if \verb|\theendnotes| is
+% used, but noendnotes have been inserted yet.
+%
+% Jürgen Spitzmüller 2020-01-02: ensure .ent file is cleared.
+%
% ****************************************
% * ENDNOTE COMMANDS *
% ****************************************
@@ -254,6 +260,8 @@
% ****************************************
%
+\ProvidesPackage{endnotes}[2020-01-02 endnotes package]
+
\@definecounter{endnote}
\def\theendnote{\@arabic\c@endnote}
@@ -283,6 +291,7 @@
\newwrite\@enotes
\newif\if@enotesopen \global\@enotesopenfalse
+\newif\if@haveenotes \global\@haveenotesfalse
\def\@openenotes{\immediate\openout\@enotes=\jobname.ent\relax
\global\@enotesopentrue}
@@ -296,6 +305,7 @@
% of the lines wind up being quite short.
\long\def\@endnotetext#1{%
+ \global\@haveenotestrue
\if@enotesopen \else \@openenotes \fi
\immediate\write\@enotes{\@doanenote{\@theenmark}}%
\begingroup
@@ -309,6 +319,7 @@
% have, requiring the use of \protect for fragile commands.
\long\def\addtoendnotes#1{%
+ \global\@haveenotestrue
\if@enotesopen \else \@openenotes \fi
\begingroup
\newlinechar='40
@@ -316,6 +327,16 @@
\immediate\write\@enotes{#1}%
\endgroup}
+% Check at document end if endnotes have been inserted;
+% if not, assure the *.ent file is cleared if it exists.
+\AtEndDocument{%
+ \if@haveenotes\else
+ \IfFileExists{\jobname.ent}{
+ \if@enotesopen\else\@openenotes\fi
+ \addtoendnotes{}}{}
+ \fi
+}
+
% End of unique endnote code
\def\endnotemark{%
@@ -411,7 +432,9 @@
\def\@endanenote{\par\endgroup}%
\enoteheading
\enotesize
- \input{\jobname.ent}%
+ \InputIfFileExists{\jobname.ent}{}{%
+ \PackageWarning{endnotes}{No endnotes found (file \jobname.ent does not exist)\MessageBreak}
+ }%
\endgroup}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%