使用 hyperref 制作尾注可点击链接

使用 hyperref 制作尾注可点击链接

我想使用endnoteshyperrefbiblatex来获得指向尾注的链接。以下是显示链接未显示的原因的 MWE:

\begin{filecontents}{testbib.bib}
@Book{jones00,
  author =   {Douglas Jones},
  title =    {A book},
  publisher =    {The metasyntactic variable publishing company},
  year =     2000}
\end{filecontents}

\documentclass{article}
\usepackage{endnotes}
\usepackage[autocite=footnote,notetype=endonly,style=verbose-trad1]{biblatex}
\bibliography{testbib}
\let\footnote\endnote
\usepackage{hyperref}
\begin{document}
Something\autocite[p.12]{jones00} something else\footnote{another endnote?}

\theendnotes
\end{document}

我愿意接受其他能够更好地配合的尾注制作选项hyperref,但我宁愿坚持使用文章文档类。

答案1

我曾在 comp.text.tex 上发现过以下代码,归功于 Ulrich Dirr:

%%% hyperendnotes.sty
\makeatletter
\newif\ifenotelinks
\newcounter{Hendnote}
% Redefining portions of endnotes-package:
\let\savedhref\href
\let\savedurl\url
\def\endnotemark{%
\@ifnextchar[\@xendnotemark{%
\stepcounter{endnote}%
\protected@xdef\@theenmark{\theendnote}%
\protected@xdef\@theenvalue{\number\c@endnote}%
\@endnotemark
}%
}%
\def\@xendnotemark[#1]{%
\begingroup\c@endnote#1\relax
\unrestored@protected@xdef\@theenmark{\theendnote}%
\unrestored@protected@xdef\@theenvalue{\number\c@endnote}%
\endgroup
\@endnotemark
}%
\def\endnotetext{%
\@ifnextchar[\@xendnotenext{%
\protected@xdef\@theenmark{\theendnote}%
\protected@xdef\@theenvalue{\number\c@endnote}%
\@endnotetext
}%
}%
\def\@xendnotenext[#1]{%
\begingroup
\c@endnote=#1\relax
\unrestored@protected@xdef\@theenmark{\theendnote}%
\unrestored@protected@xdef\@theenvalue{\number\c@endnote}%
\endgroup
\@endnotetext
}%
\def\endnote{%
\@ifnextchar[\@xendnote{%
\stepcounter{endnote}%
\protected@xdef\@theenmark{\theendnote}%
\protected@xdef\@theenvalue{\number\c@endnote}%
\@endnotemark\@endnotetext
}%
}%
\def\@xendnote[#1]{%
\begingroup
\c@endnote=#1\relax
\unrestored@protected@xdef\@theenmark{\theendnote}%
\unrestored@protected@xdef\@theenvalue{\number\c@endnote}%
\show\@theenvalue
\endgroup
\@endnotemark\@endnotetext
}%
\def\@endnotemark{%
\leavevmode
\ifhmode
\edef\@x@sf{\the\spacefactor}\nobreak
\fi
\ifenotelinks
\expandafter\@firstofone
\else
\expandafter\@gobble
\fi
{%
\Hy@raisedlink{%
\hyper@@anchor{Hendnotepage.\@theenvalue}{\empty}%
}%
}%
\hyper@linkstart{link}{Hendnote.\@theenvalue}%
\makeenmark
\hyper@linkend
\ifhmode
\spacefactor\@x@sf
\fi
\relax
}%
\long\def\@endnotetext#1{%
\if@enotesopen
\else
\@openenotes
\fi
\immediate\write\@enotes{%
\@doanenote{\@theenmark}{\@theenvalue}%
}%
\begingroup
\def\next{#1}%
\newlinechar='40
\immediate\write\@enotes{\meaning\next}%
\endgroup
\immediate\write\@enotes{%
\@endanenote
}%
}%
\def\theendnotes{%
\immediate\closeout\@enotes
\global\@enotesopenfalse
\begingroup
\makeatletter
\edef\@tempa{`\string>}%
\ifnum\catcode\@tempa=12
\let\@ResetGT\relax
\else
\edef\@ResetGT{\noexpand\catcode\@tempa=\the\catcode\@tempa}%
\@makeother\>%
\fi
\def\@doanenote##1##2##3>{%
\def\@theenmark{##1}%
\def\@theenvalue{##2}%
\par
\smallskip %<-small vertical gap between endnotes
\begingroup
\def\href{\expandafter\savedhref}%
\def\url{\expandafter\savedurl}%
\@ResetGT
\edef\@currentlabel{\csname p@endnote\endcsname\@theenmark}%
\enoteformat
}%
\def\@endanenote{%
\par\endgroup
}%
% Redefine, how numbers are formatted in the endnotes-section:
\renewcommand*\@makeenmark{%
\hbox{\normalfont\@theenmark~}%
}%
% header of endnotes-section
\enoteheading
% font-size of endnotes
\enotesize
\input{\jobname.ent}%
\endgroup
}%
\def\enoteformat{%
\rightskip\z@
\leftskip1.8em
\parindent\z@
\leavevmode\llap{%
\setcounter{Hendnote}{\@theenvalue}%
\addtocounter{Hendnote}{-1}%
\refstepcounter{Hendnote}%
\ifenotelinks
\expandafter\@secondoftwo
\else
\expandafter\@firstoftwo
\fi
{\@firstofone}%
{\hyperlink{Hendnotepage.\@theenvalue}}%
{\makeenmark}%
}%
}%
% stop redefining portions of endnotes-package:
\makeatother
% Toggle switch in order to turn on/off back-links in the
% endnote-section:
\enotelinkstrue
%\enotelinksfalse

将其与endnotes包一起加载( hyperref) 享受。

答案2

看起来这不是一个biblatex问题。READMEhyperref在第 18 页指出 endnotes 包“不受支持”。

答案3

使用 enotez 包(\usepackage{enotez})。

有关详细信息,请参阅:https://tex.stackexchange.com/a/228296/42648

答案4

enotez 运行良好,但当它与大量样式文件一起使用时,我们遇到了问题。相反,我们定义了一个在该环境中工作的尾注的简单模型。还使用了两个选项,您可以单击注释编号或标有该编号的文本。后者似乎对平板电脑上显示的小字体很有用,因为很难打出非常小的注释编号。这是一个完整的示例。

% A simple macro that uses endnotes with hyperref
% (by Giovanni Rinaldi and Klaus Truemper)
%
% Important: the command \setcounter{notelabelcount}{0} needs
%            to go just before \theendnotes
%
\documentclass[12pt]{article}
\usepackage{hyperref}
%\hypersetup{pdfborder=0 0 0} % Uncomment if you want to get rid 
                              % of the box highlighting the link
\usepackage{endnotes}

% hyperref of notes
\newcounter{notelabelcount}
\setcounter{notelabelcount}{0}
\def\HyperRaiseLinkDefault{12pt} % Replace 12pt with \baselineskip or
                                 % any other suitable length
% this macro makes the note number become the link to the endnote
\newcommand{\mysimplenote}[1]{%
   \addtocounter{notelabelcount}{1}%
   \hyperref[notelabel\thenotelabelcount]{%
   \endnote{%
      \addtocounter{notelabelcount}{1}%
      \phantomsection\label{notelabel\thenotelabelcount}%
      {#1}%
   }}%
}

% this macro makes some text (1st parameter) become the link to 
% the endnote (second parameter)
\newcommand{\mynote}[2]{%
   \addtocounter{notelabelcount}{1}%
   \hyperref[notelabel\thenotelabelcount]{#1}%
   \endnote{%
      \addtocounter{notelabelcount}{1}%
      \phantomsection\label{notelabel\thenotelabelcount}%
      {#2}%
   }%
}

\begin{document}
RODERIGO:
Tush! Never tell me. I take it much unkindly
That thou, Iago, who hast had my purse
As if the strings were thine, shouldst know of
this\mysimplenote{W.~Shakespeare, Othello, Act 1, Scene 1.}.

MONTANO: 
Methinks the wind hath spoke aloud at land,
A fuller blast ne'er shook our battlements.
If it hath ruffianed so upon the sea
What ribs of oak, when mountains melt on them,
Can hold the mortise? What shall we hear of
this?\mysimplenote{W.~Shakespeare, Othello, Act 2, Scene 1.}

OTHELLO:
Get you to bed on th' instant, I will be returned
Forthwith. Dismiss your attendant there, 
\mynote{look't be done}{W.~Shakespeare, Othello, Act 4, Scene 3.}.

\newpage

\setcounter{notelabelcount}{0} % this is necessary
\theendnotes

\end{document}

相关内容