Equation-Tags als Hyperlinks zu Endnotes verwenden

Fragen und Probleme, die nicht den obigen Kategorien zugeordnet werden können


bodhisat
Forum-Newbie
Forum-Newbie
Beiträge: 2
Registriert: So 27. Mär 2016, 17:08

Equation-Tags als Hyperlinks zu Endnotes verwenden

Beitrag von bodhisat »

Hallo goLaTeX-Gemeinde,

mein Ziel:

Ich möchte, dass meine Gleichungszähler als klickbare Hyperlinks zu Endnoten funktionieren, deren Counter ebenfalls genau wie der Tag aussehen, also z.B. (1.2) sowohl bei der Gleichung als auch bei der Endnote-Liste am Schluss.

mein bisheriges Vorgehen:

Für Endnotes habe ich nach meinem Wissen zwei Optionen: Pakete 'endnotes' und 'enotez'. Ich habe zunächst ersteres probiert, kombiniert mit diesem ziemlich ausführlichen Hack, den ich im Netz ausfindig gemacht habe:
%%% 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

Hier folgt das Minimalbeispiel mit 'endnotes':
\documentclass{article}

\usepackage[backref = page, hyperfootnotes, colorlinks = true, linkcolor = blue]{hyperref}
\usepackage{endnotes}

\usepackage{hyperendnotes} % Hack für 'endnotes' obendrüber

\usepackage{mathtools}
\numberwithin{equation}{section}
\numberwithin{endnote}{section}

\usepackage{lastpage}
\newcommand\notelink[1]{\hyperref[LastPage]{(#1)}}
\newtagform{notetag}[\notelink]{}{}
\usetagform{notetag}

\renewcommand\notesname{Formula Sources \vspace{.25cm}}
\renewcommand\makeenmark{(\theenmark)\hspace{.15cm}}

\begin{document}

\begin{section}{Weltgleichung}

	\begin{equation} \refstepcounter{endnote} \endnotetext{Weltgleichung I }
	  a + b = c
	\end{equation}

\newpage 

	\begin{equation} \refstepcounter{endnote} \endnotetext{Weltgleichung II}
	  1 + 2 = 3
	\end{equation}
	
\end{section}

\clearpage

\theendnotes
	
\end{document}
Diese Lösung hat zwei Defizite:
  • I) Die Gleichungstags verweisen nur auf die Seite mit den Quellen, allerdings nicht direkt auf die Endnote, die zur Gleichung gehört. (nicht so schlimm)
    II) Die Backlinks in der Endnotes-Liste verweisen nicht direkt zu den Gleichungen, in deren Nähe die Endnote-Texte definiert wurden (sehr schlimm).
Die zweite 'Lösung' mit 'enotez' folgt:
\documentclass{article}

\usepackage[hyperfootnotes, colorlinks = true, linkcolor = blue]{hyperref}
\usepackage[backref]{enotez}

\renewcommand\enotezwritemark[1]{}

\usepackage{mathtools}
\numberwithin{equation}{section}

\usepackage{lastpage}
\newcommand\notelink[1]{\hyperref[LastPage]{(#1)}}
\newtagform{notetag}[\notelink]{}{}
\usetagform{notetag}


\renewcommand*\enmark[1]{#1}
\DeclareInstance{enotez-list}{plain}{paragraph}{number = (\enmark{#1})}

\begin{document}

\begin{section}{Weltgleichung}
	
	\begin{equation} \endnote{Weltgleichung I}
	  a + b = c
	\end{equation}
\end{section}

\newpage

\begin{section}{Weltgleichung zum Zweiten}
	
	\begin{equation} \endnote{Weltgleichung II}
	1 + 2 = 3
	\end{equation}
\end{section}

\clearpage

\printendnotes
	
\end{document}
Diese Lösung hat das Problem, dass die Endnotes-Tags nicht mit den Gleichungstags übereinstimmen. (sehr schlecht)
Nach Rücksprache mit dem Paket-Maintainer Clemens Niederberger ist das auch nicht so einfach, da 'enotez' nicht mit einem LaTeX-Counter arbeitet, sondern einer 'expl3 int variable' namens '\g__enotez_endnote_mark_int' (keine Ahnung warum). Deshalb bin ich einfach nur ratlos.

Hat jemand eine schöne Lösung für mein Problem? Ansonsten muss ich ganz tief in die Eingeweide von TeX einsteigen, und das würde ich gerne vermeiden.

Danke sehr und beste Grüße,
bodhisat

Benutzeravatar
Johannes_B
Moderator
Moderator
Beiträge: 5079
Registriert: Do 1. Nov 2012, 14:55
Kontaktdaten:

Beitrag von Johannes_B »

TeXwelt - Fragen und Antworten Schaut vorbei und stellt Fragen.
LaTeX-Vorlagen?

Der Weg zum Ziel: Ruhe bewahren und durchatmen, Beiträge und unterstützende Links aufmerksam lesen, Lösungsansätze verstehen und ggf. nachfragen.

bodhisat
Forum-Newbie
Forum-Newbie
Beiträge: 2
Registriert: So 27. Mär 2016, 17:08

Beitrag von bodhisat »

Sorry, nicht bedacht, dass das unerwünscht ist.

Antworten