編輯:

編輯:

我的程式碼mwe.tex是:

\documentclass{book}

\usepackage{ragged2e}%
\usepackage[pdftex,bookmarks=false,bookmarksopen=false,colorlinks=true,citecolor=blue,linkcolor=blue,urlcolor=blue,breaklinks=true,linktocpage=true,hyperfootnotes=true]{hyperref}%
\usepackage{endnotes}%
\makeatletter
\newbox\endnotebox%
\setbox\endnotebox=\hbox{11}%

\newlength{\enotehangalign}%
\setlength{\enotehangalign}{13\p@}%

\AtBeginDocument{%
\def\enoteformat{%
\def\@makeenmark{\hbox to \wd\endnotebox{\hss{\normalfont\@theenmark}}}%
\rightskip\z@ \leftskip\z@ \parindent=\z@\parskip\z@\def\@textsuperscript{}\hangindent\enotehangalign%
  \leavevmode{\makeenmark\ignorespaces\enskip\ignorespaces}\RaggedRight}%
\def\enoteheading{\section*{Notes}%
}%
\def\enotesize{\fontsize{8}{10}\selectfont}%
}%
\@addtoreset{endnote}{chapter}%
\usepackage{hyperendnote}

\makeatother
\begin{document}

This is for test\endnote{Test}

\clearpage

\theendnotes
\end{document}

hyperendnote.sty載入的定義mwe.tex是:

%%% 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

但連結endnote不起作用,有人可以建議我做錯了什麼嗎?

順便一提:我有代碼hyperendnote.sty順便說一句:我有來自的這個問題。

請參考尾註輸出的影像,我需要設定什麼:

在此輸入影像描述

答案1

hyperref好吧,如果你打開第 41 頁的文檔,你會發現:

在此輸入影像描述

並且在裡面也提到了這個答案在您已經連結的問題中

然而,如果您在呼叫套件後刪除/註釋您使用的程式碼,則endnotes產生的 pdf 將顯示連結的註腳 1,您可以按一下它以顯示註腳 1。

以下MWE

\begin{filecontents*}{hyperendnote.sty}
%%% 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
\end{filecontents*}


\documentclass{book}

\usepackage{ragged2e}
\usepackage[%  
  pdftex,
  bookmarks=false,bookmarksopen=false,
  colorlinks=true,citecolor=blue,linkcolor=blue,urlcolor=blue,
  breaklinks=true,
  linktocpage=true,
  hyperfootnotes=true
]{hyperref}
\usepackage{endnotes}

%\makeatletter
%\newbox\endnotebox%
%\setbox\endnotebox=\hbox{11}%
%
%\newlength{\enotehangalign}%
%\setlength{\enotehangalign}{13\p@}%
%
%\AtBeginDocument{%
  %\def\enoteformat{%
  %\def\@makeenmark{\hbox to \wd\endnotebox{\hss{\normalfont\@theenmark}}}%
  %\rightskip\z@ \leftskip\z@ \parindent=\z@\parskip\z@\def\@textsuperscript{}\hangindent\enotehangalign%
    %\leavevmode{\makeenmark\ignorespaces\enskip\ignorespaces}\RaggedRight}%
  %\def\enoteheading{\section*{Notes}%
  %}%
  %\def\enotesize{\fontsize{8}{10}\selectfont}%
%}%
%\@addtoreset{endnote}{chapter}%
%\makeatother
\usepackage{hyperendnote}


\begin{document}

This is for test\endnote{Test}

\clearpage

\theendnotes
\end{document}

以及生成的 pdf:

第一頁有連結

點擊紅色圓圈中的連結後,您將看到按要求顯示的第 2 頁:

第2頁

編輯:

添加代碼後

\chapter{Test 1}
This is for test\endnote{Test}. 
This is for test\endnote{Test 2}. 
This is for test\endnote{Test 3}. 
This is for test\endnote{Test 4}. 
This is for test\endnote{Test 5}. 
This is for test\endnote{Test 6}. 
This is for test\endnote{Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 
  Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7
  Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 Test 7 
  Test 7 Test 7 Test 7 Test 7}. 
This is for test\endnote{Test 8}. 
This is for test\endnote{Test 9}. 
This is for test\endnote{Test 10}. 
This is for test\endnote{Test 11}. 

與我給出的初始 MWE 沒有其他變化,我得到以下結果,這似乎與您的結果相同,包括藍色連結:

結果尾註

相關內容