交叉引用两种尾注(分开且用不同颜色的数字表示)

交叉引用两种尾注(分开且用不同颜色的数字表示)

一开始我使用 parnotes 和 endnotes 来区分两种不同的尾注:


\documentclass{article}

\usepackage{changepage} % \begin{adjustwidth}{...cm}{...cm}

\usepackage[colorlinks=true,linkcolor=red]{hyperref} % colors endnotes red --- for hyperlinks --- hyperref permits use of color{blue}{...}
\usepackage{endnotes} % \endnote{...}
\input{hyperendnotes.sty} % LOADS (needs \usepackage{hyperref}) hyperendnotes.sty; which can be downloaded at
% https://github.com/bibliogum/latexamu/blob/master/hyperendnotes.sty

\def\enoteheading{} % endnotes without standard heading

\usepackage[breakwithin, roman]{parnotes} % parnotes

\makeatletter % needed for \renewcommand{...} and \patchcmd{...}
\renewcommand{\parnotemarkfmt}[1]{{{\color{blue}\PN@mark@set{#1}\hspace{0.5mm}}}} % color parnotes blue --- tweaks spacing --- adjusts size of parnotes to look like hyperendnotes (part 1)
\usepackage{etoolbox} % \patchcmd{...}
\patchcmd{\PN@parnote@real}
  {\parnotemarkfmt{PN@t}}
  {\textsuperscript{\hspace{1.23mm}\parnotemarkfmt{PN@t}\hspace{-0.67mm}}}
  {}{} % <<< adjusts size of parnotes to look like hyperendnotes (part 2) --- thanks a lot for this part @egreg; at
% https://tex.stackexchange.com/questions/219000/a-question-about-using-a-renewcommand-to-adapt-a-package/219007#219007
\makeatother % needed for \renewcommand{...} and \patchcmd{...}

\begin{document}

\noindent Some text \parnote{A parnote} \parnote{Another parnote} \endnote{An endnote} \parnote{Another parnote} \endnote{Another endnote} \endnote{Another endnote} \endnote{Another endnote} \parnote{Another parnote} \parnote{Another parnote} \parnote{Another parnote} \parnote{Another parnote} \endnote{Another endnote} \parnote{Another parnote} \endnote{Another endnote} \endnote{Another endnote} \endnote{Another endnote} \endnote{Another endnote} \endnote{Another endnote} \parnote{Another parnote} \endnote{Another endnote} \parnote{Another parnote} \parnote{Another parnote} \par
\noindent \textbf{Parnotes}
\parnotes
\textbf{Endnotes} \par
\begin{adjustwidth}{2.49mm}{0cm}
\theendnotes
\end{adjustwidth}

\end{document}

所以他们分离和“标记”得很好(即使两种“类型”的尾注交织在一起)。

但那没有在 parnotes 上获取交叉引用(可点击的链接)...

加载hyperendnotes.sty只会将可点击的交叉引用“链接”放在 上\endnote{...},而不会放在 上\parnote{...}


因此用户 @cfr 暗示了enotez-package。我发现\usepackage{enotez}至少更简单,因为它不再需要加载额外内容hyperendnotes.sty

在第二次试验中,我仅使用了尾注(我放弃了 parnotes,因为我无法在它们上获得可点击的超链接。


在第二次试验中,我仅使用了尾注(我放弃了 parnotes,因为我无法在它们上获得可点击的超链接。

  • 注意:试用代码的第二个“灰框”需要编译两次。(由于-package enotez)。

\documentclass{article}

\usepackage{enotez}
\DeclareInstance{enotez-list}{section}{paragraph}{heading={}}
\setenotez{backref=true, list-style=section, reset, split-title=\noindent}

\usepackage{hyperref}
\hypersetup{colorlinks=true}
\usepackage{biblatex}

\begin{document}

\hypersetup{linkcolor=red}

Som text here \endnote{Endnote}. \par
Some more text \endnote{Endnote} before the first call of \colorbox{gray!20}{\textbackslash printendnotes}. 

\vspace{1em} \textbf{A first person's endnotes} \printendnotes \vspace{1em}

\setenotez{counter-format={roman}} \hypersetup{linkcolor=blue}

See? I can get clickable endnotes in two different colours, which is what I wanted. \endnote{Endnote}. \par {\large{But the problem is that ALL of the endnotes (of a certain colour) have to be grouped together and originate before the first \colorbox{gray!20}{\textbackslash printendnotes} and before ALL of the other endnotes (of another colour): there is no freedom to use the endnotes "interwoven", unfortunately.}} \endnote{Endnote}.


\vspace{1em} \textbf{A second person's endnotes} \printendnotes \vspace{2em}

\setenotez{counter-format={arabic}} \hypersetup{linkcolor=red}

You can get both footnote sections to truly follow each-other at the end of the document \endnote{Endnote} (which is what i wanted), by using a lot of \colorbox{gray!20}{\textbackslash vspace}'s (see the .tex-code below this line). But having to constantly adjust the \colorbox{gray!20}{\textbackslash vspace}'s doesn't seem very elegant at all. \endnote{Endnote}

\vspace{8.2em}% extra \vspace{...} to group the endnote sections together at the end of the .pdf

\vspace{1em} \textbf{A first person's endnotes} \printendnotes \vspace{1em}

\setenotez{counter-format={roman}} \hypersetup{linkcolor=blue}

\vspace{-15em}% extra \vspace{...} to group the endnote sections together at the end of the .pdf

See?\endnote{Endnote} Now the the sections are really together \endnote{Endnote} at the very end of the document. \par However: the {\large{origins of the two different types of endnotes still have to be grouped together, and cannot get interwoven, unfortunately.}}

\vspace{8em}% extra \vspace{...} to group the endnote sections together at the end of the .pdf

\vspace{1em} \textbf{A second person's endnotes} \printendnotes \vspace{1em}

\end{document}

现在有所有尾注均有交叉引用(可点击链接)!

但不同类型的尾注不再交织在一起。

这种方式无法正确地对不同“类型”的尾注进行编码标记(没有注释)。如果“交织”在一起,那么这两种“类型”就不会被编号并分别放在文档底部。


简而言之,以下任何一种方法都可以解决我的问题。

任何一个:

  • 在 parnotes 上获取交叉引用。

或者(使用可交叉引用的尾注时):

  • 标记“类型(尾注)”(具有单独的编号、颜色和数字)并单独打印。

我开始怀疑是否可以提供解决方案不是完全使用标准的注释、尾注或脚注?但只需使用其他代码标签来区分两种类型的“注释”,添加一些上标、编号、颜色(以“假”尾注)。然后将它们分开打印?也许(作为最后的手段)使用biblatex

我猜这种“伪造”或“自主定义脚注”是在德国 QA 网站 texwelt 上完成的:这里或者这里。我将在下面发布一个英文版本(略作修改):

\documentclass{article} 
\usepackage{xcolor}

%%%%%%%%%%%

\newcommand\newnotestype[2]{%
\newcounter{#1note}%
\expandafter\newwrite\csname the#1notes\endcsname
\expandafter\immediate\expandafter\openout\csname
the#1notes\endcsname=\jobname.#1\relax %
\expandafter\newcommand\csname  #1note\endcsname[1]{%
\stepcounter{#1note}%
{%
\tiny\textsuperscript\expandafter\textcolor{#2}{{%
\raisebox{1ex}{\hbox{\kern-0.0em\csname
the#1note\endcsname\kern-0.0em}}}}%
\expandafter\immediate\expandafter\write\csname the#1notes\endcsname%
{\csname the#1note\endcsname\ \unexpanded{##1 \par}}%
}}%

\expandafter\newcommand\csname display#1notes\endcsname[1]{%
\vspace{1\baselineskip}%
\expandafter\immediate\expandafter\closeout%
\csname the#1notes\endcsname%
\par\tiny\expandafter\textcolor{#2}{\textbf{##1}}\par%
\input\jobname.#1%
}}%

%%%%%%%%%%%

\newnotestype{first}{red}
\newnotestype{second}{blue}

%%%%%%%%%%%

\begin{document}

This is the test-text \firstnote{Endnote} \secondnote{Endnote} , some more \firstnote{Endnote} test-text, some more  \secondnote{Endnote} test-text \secondnote{Endnote}. 

%%%%%%%%%%%

\displayfirstnotes{A first person's endnotes}
\displaysecondnotes{A second person's endnotes}

\end{document}

现在不同类型的尾注轻易地贴上标签并再次交织在一起。

但同样不再交叉引用(可点击链接)任何尾注。

简单的\usepackage{hyperref}不再起作用,因为脚注不是真正的“脚注”:它们是“伪造的”看起来像脚注。

那么,有谁知道一个优雅的解决方案来实现这些“对象”的交叉引用(可点击的链接)?

其他一些问题:

  • 最后一次(第三次)试验也为尾注标题着色,但是不是尾注编号(至少不是打印尾注的地方)。如果有人能在那里把尾注编号弄成彩色,那就太好了。
  • 还有:这样,那里不再似乎是从阿拉伯数字转换为罗马数字的简单方法(一般来说,特别是对于一种“类型”的尾注)?

非常感谢。

相关内容