• No results found

The endnotes-hy Package

N/A
N/A
Protected

Academic year: 2021

Share "The endnotes-hy Package"

Copied!
5
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

The endnotes-hy Package

D. P. Story

Email: dpstory@uakron.edu processed April 10, 2020

Contents

1 Introduction 1

2 Required packages 2

3 Package code 2

4 Index 5

5 Change History 5

1

h∗packagei

1 Introduction

This package is an extension of endnotes.

Background: A colleague—a dedicated user of the endnotes package—complained to me (for some reason) that links created by hyperref do not point to the endnotes at the end of the file; for example, if we say

\endnote{\label{hnamei}htexti}

then any link, such as \hyperref[hnamei]{endnote~\ref*{hnamei}} jumps to the most recent anchor (Doc-Start, for example); no hypertext anchor is created where the endnote is inserted into the document. This short package is an attempt to rectify this problem.

Syntax: The \endnote command has been modified to conform to the following syntax:

\endnote*[hnumi]{htexti}\label{hnamei}

Refer to the documentation of the endnotes package for a description of the

\endnote command and its hnumi and htexti arguments. If the *-option (new

(2)

syntax) is used, the endnote mark is not placed, but the endnote is written to the ENT file. Such a “secret” endnote can be referred to using standard hyperref commands, see the endnote 1 on page 4 for more information. The placement of the \label has changed for this package as well. To define an endnote label, place \label{name} following the \endnote command, a more traditional loca- tion. This was done to get access to the hnamei, if it exist. This enables the package to place a hypertext link around the endnote mark.

2

The optional hnumi can be used to write special endnotes.

N1

As a side benefit to this new syntax, you can place verbatim text into an endnote.

3

If there is no \label following

\endnote, no hypertext link is created.

4

Note: This package will work correctly without the hyperref package (of course, no links). The advantage of using endnotes-hy without hyperref is to use the extended syntax: \endnote*[hnumi]{htexti}\label{hnamei}

2 Required packages

2

\RequirePackage{endnotes}

Require etoolbox because we redefine several commands using \patchcmd; this is not really necessary, we could have redefined the whole command instead.

3

\RequirePackage{etoolbox}

3 Package code

We allow the author not to use hyperref; this enables the use of the extended syntax of the \endnote command.

4

\newcommand\hyperref@nohy[2][]{#2}

5

\AtBeginDocument{\@ifundefined{hyperref}{\let\hyperref@en\hyperref@nohy

6

\let\phantomendnote\relax}

7

{\let\hyperref@en\hyperref}}

\phantomendnote The key is to create an hyperref anchor to reference; this definition is based on

\phantomsection of hyperref. This is used internally.

8

\def\phantomendnote{%

9

\Hy@MakeCurrentHrefAuto{endnote}%

10

\Hy@raisedlink

11

{\hyper@anchorstart{endnote.\@theenmark}\hyper@anchorend}}

12

\def\endnoteautorefname{endnote}

Redefinition of \theendnotes

\theendnotes

13

\patchcmd{\theendnotes}{\enoteformat}

14

{\phantomendnote\def\@currentHref{endnote.\@theenmark}%

15

\enoteformat}{}{}

Redefine \endnote to take an optional *, if this option is used, the mark does not

\endnote

appear in the text. This enables us to easily define an endnote and refer to it even

with multiple paragraphs. I didn’t like the syntax of inserting the \label within

(3)

the argument of \endnote, this seems to have problems. The new syntax is as follows:

Syntax: \endnote*[hnumi]{htexti}\label{hnamei}

This new syntax could be a problem if an author has already used endnotes and then converts to endnotes-hy. In endnotes the *-option is note defined and the

\label command is typically placed within the argument of the {htexti}. Labels would have to be moved to a position following {htexti}.

To obtain this syntax, we need several stages of parsing. The major problem is to get the label name in time to build a hyperref link around \@endnotemark.

16

\newtoks\@entoks

17

\def\endnote{\let\@encurrlabelname\@empty

18

\@ifstar{\let\@noMrk1\endnote@i}{\let\@noMrk0\endnote@i}}

19

\def\endnote@i{\@ifnextchar[%]

20

{\@xendnote}

21

{\stepcounter{endnote}%

22

\protected@xdef\@theenmark{\theendnote}%

We placed the {text} argument into a token register, this removes that argument from the input stream, and allows us to see of the next token is \label, if so, we get the label name argument.

23

\afterassignment\endnote@ii\@entoks}}

If the next token is \label, get the label name with \endnote@iii, otherwise, move on to \endnote@iv, the final step.

24

\def\endnote@ii{\@ifnextchar\label{\endnote@iii}{\endnote@iv}}

25

\def\endnote@iii\label#1{\def\@encurrlabelname{#1}\endnote@iv}

If the flag \@noMrk is 0 (mark is typeset), and if there is a label name, we make an hypertext link.

26

\def\endnote@iv{%

27

\if\@noMrk0\relax

28

\ifx\@encurrlabelname\@empty

29

\@endnotemark

30

\else

31

\hyperref@en[\@encurrlabelname]{\@endnotemark}%

32

\fi

33

\fi

Finish by expanding \@endnotetext with its argument that was saved in the

\@entoks register.

34

\expandafter\@endnotetext\expandafter{\the\@entoks}}

We patch into \@endnotetext just after \def\next{#1}. If there was a \label,

\@endnotetext

we insert it back into the argument of \endnote.

35

\patchcmd{\@endnotetext}

36

{\def\next{#1}}

37

{\ifx\@encurrlabelname\@empty

38

\def\next{#1}\else

39

\edef\x{\noexpand\label{\@encurrlabelname}}%

40

\expandafter\def\expandafter\next\expandafter{\x#1}\fi}{}{}

(4)

If \endnote has an optional argument, the flow passes to \xendnote. We re-

\xendnote

place \@endnotemark\@endnotetext by redirecting flow to to \endnote@ii, after saving the argument in \@entoks.

41

\patchcmd{\@xendnote}

42

{\@endnotemark\@endnotetext}

43

{\afterassignment\endnote@ii\@entoks}

44

{}{}

45

h/packagei

Notes

1An endnote created with *-option

2This is normal endnote

N1This is special endnote

3Some verbatim text

%^$^&$%^&

4No hypertext link created

(5)

4 Index

Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the code lines where the entry is used.

Symbols

\@currentHref . . . 14

\@encurrlabelname . . . . 17, 25, 28, 31, 37, 39 \@endnotemark . . . . 29, 31, 42 \@endnotetext . . . . 3, 34, 35, 42 \@entoks . . . 16, 23, 34, 43 \@noMrk . . . 18, 27 \@theenmark . . . . 11, 14, 22 \@xendnote . . . 20, 41 A \afterassignment . . . 23, 43 \AtBeginDocument . . . 5

E \endnote . . . 2, 17 \endnote@i . . . 18, 19 \endnote@ii . . . . 23, 24, 43 \endnote@iii . . . 24, 25 \endnote@iv . . . . 24–26 \endnoteautorefname . . . 12

\enoteformat . . . 13, 15 H \Hy@MakeCurrentHrefAuto . . . 9

\Hy@raisedlink . . . 10

\hyper@anchorend . . . 11

\hyper@anchorstart . . . 11

\hyperref . . . 7

\hyperref@en . . . 5, 7, 31 \hyperref@nohy . . . 4, 5 L \label . . . . 24, 25, 39 N \next . . . . 36, 38, 40 P \patchcmd . . . . 13, 35, 41 \phantomendnote . . . 6, 8, 14 \protected@xdef . . . 22

R \RequirePackage . . . 2, 3 S \stepcounter . . . 21

T \theendnote . . . 22

\theendnotes . . . 2, 13 X \x . . . 39, 40 \xendnote . . . . 4

5 Change History

v0.1 (2020/04/08)

General: First published version of this package. . 1

Referenties

GERELATEERDE DOCUMENTEN

An algebra task was chosen because previous efforts to model algebra tasks in the ACT-R architecture showed activity in five different modules when solving algebra problem;

If the option foot was passed to the package, you may consider numbering authors’ names so that you can use numbered footnotes for the affiliations. \author{author one$^1$ and

• You must not create a unit name that coincides with a prefix of existing (built-in or created) units or any keywords that could be used in calc expressions (such as plus, fil,

\@makeentext{〈note〉} : Must produce the actual endnote, using \theenmark as the mark of the endnote and 〈note〉 as the text. It is called when effectively inside a \parbox, with

\pIIe@code In this case the code inserted by the driver on behalf of the \Gin@PS@restored command performs a “0 setgray” operation, thus resetting any colour the user might have set

Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla.. Cur- abitur auctor

This type of genetic engineering, Appleyard argues, is another form of eugenics, the science.. that was discredited because of its abuse by

Although the finishing of all composite structures, such as the examples of the boat hull or a glider fuselage, mainly depends on the quality of the mould finish, the application