# Endnotes in plain TeX

Are there macros available for creating endnotes in Plain TeX?

I am sure I can write these myself but would prefer to free ride on someone else's effort.

• ctan.org/pkg/endnote possibly? – Paul Gessler Jan 31 '15 at 0:18
• @PaulGessler: This is just slightly imperfect but will be very easy to modify. It's 99% of what I was looking for. Thanks very much. If you convert this to an answer, I'll look forward to accepting it. – WillO Jan 31 '15 at 0:24
• Done, glad it will help. And by the way: Welcome to TeX.SX! – Paul Gessler Jan 31 '15 at 0:35

endnote from CTAN may give a suitable starting point. Here's a quick example:

\input endnote

Hello world! This is to have an endnote. \endnote{[1]}{ Endnote text.}

\producenotes

\bye


You can be inspired by OPmac trick 0051. Here is my clumsy translation of this OPmac trick:

Glossary at the end of the document

The abbreviations or some else can be occurred in the document and we need to write some explanations of such objects at the end of the document. We write \glos{abbreviation}{explanation}. Nothing occurs in this place of the document. For example:

\input opmac
...
I am working at CTU\glos{CTU}{Czech Technical University in Prague} in Prague.


The macro \glos saves the information into memory and uses them at the place where \makeglos is used. You can implement \glos and \makeglos by:

\def\gloslist{}
\def\glos #1#2{%
\expandafter\isinlist\expandafter\gloslist\csname;#1\endcsname
\iftrue \opwarning{Duplicated glossary item #1'}%
\else
\global\sdef{;#1}{{#1}{#2}}%
\fi
}
\def\makeglos{%
\ifx\gloslist\empty \opwarning{Gossary data unavailable}%
\else
\bgroup
\let\iilist=\gloslist
\dosorting
\def\act##1{\ifx##1\relax \else \expandafter\printglos##1\expandafter\act\fi}
\expandafter\act\iilist\relax
\egroup
\fi
}
\newdimen\glosindent  \glosindent=2\parindent
\def\printglos #1#2{\noindent \hangindent=\glosindent \hbox to\glosindent{#1\hss-- }#2\par}


The glossary is automatically sorted by the alphabet. If you needn't such sorting and the order by the occurrence is sufficient then you can comment out the \dosorting sequence in the \makeglos definition.

Of course, you can program the \printglos by your wish, by your typography design. The \printglos macro has two parameters: {abbverviation}{explanation} and it prints one glossary item in the list. The \printglos defined above sets fixed indentation 2\parindent for all
items. You can use another indentation, for example the indentation can be
calculated from the maximal lenght of the abbverviation, see OPmac trick 0041

Another more simple example of the \printglos:

\def\printglos #1#2{\noindent #1 -- #2\par}


Explanation: The \glos macro saves \;abbver1 \;abbver2 etc. into \gloslist and defines \;abbver1 as {abbver1}{explanation}, \;abbver2 as {abbver2}{explanation} etc. The macro \makeglos converts \gloslist to \iilist locally and does the alphabeticaly sorting by the macro \dosorting from OPmac. Finally, the \act` macro prints the items.

Relevant OPmac tricks:

• This is basically a kludge: use OPmac's glossary engine to fake endnotes. – jarnosz Jun 12 '15 at 17:03