我試著將 a 放入\hyperlink
a 中\makenote
,但出現以下錯誤:
! Use of \\makenote doesn't match its definition.
\@ifnextchar #1#2#3->\let \reserved@d =#1\def \reserved@a {
#2}\def \reserved@b {#3}\futurelet \@let@token \@ifnch
l.20 Testing hyperlink \makenote{a \hyperlink{anchorname}{hyperlink}.}
in makenote.
這是原始碼:
% lualatex
\documentclass{scrbook}
\usepackage{luatex85}
\usepackage{fontspec}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}
\usepackage{hyperref}
\begin{document}
Testing makenote \makenote{makenote}.
Testing \hyperlink{anchorname}{hyperlink}.
Testing hyperlink \makenote{a \hyperlink{anchorname}{hyperlink}.} in makenote.
Testing \hypertarget{anchorname}{hypertarget}.
Testing hyperref in makenote \makenote{a \hyperref[labelname]{hyperref}.}.
Testing \label{labelname}label.
\end{document}
我用於編譯,但如果我使用(事先註解掉),lualatex
我會得到相同的錯誤。pdflatex
fontspec
該\hyperlink
命令在文本中運行良好,僅在\makenote
.
這個\hyperref
指令適用於\makenote
,但不幸的是 s 的錨點\label
並不完全是\label
s 通常定義的位置。因此這是一個解決方案。
答案1
自 KOMA-Script 3.23 起包scrlayer-notecolumn
有一個星號變體\makenote
,不需要保護命令,可能會破壞並且不應擴展:
\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}[2017/02/08]
\usepackage{hyperref}
\begin{document}
Testing makenote \makenote{makenote}.
Testing \hyperlink{anchorname}{hyperlink}.
Testing hyperlink \makenote*{a \hyperlink{anchorname}{hyperlink}.} in makenote.
Testing \hypertarget{anchorname}{hypertarget}.
Testing hyperref in makenote \makenote{a \hyperref[labelname]{hyperref}.}.
Testing \label{labelname}label.
\end{document}
結果是
沒有錯誤。
您可以獲得相同的結果(即使使用 3.23 之前的 KOMA-Script):
\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}
\usepackage{hyperref}
\begin{document}
Testing makenote \makenote{makenote}.
Testing \hyperlink{anchorname}{hyperlink}.
Testing hyperlink \makenote{a \protect\hyperlink{anchorname}{hyperlink}.} in makenote.
Testing \hypertarget{anchorname}{hypertarget}.
Testing hyperref in makenote \makenote{a \hyperref[labelname]{hyperref}.}.
Testing \label{labelname}label.
\end{document}
或者
\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}
\DeclareRobustCommand*{\rhyperlink}{\hyperlink}
\usepackage{hyperref}
\begin{document}
Testing makenote \makenote{makenote}.
Testing \hyperlink{anchorname}{hyperlink}.
Testing hyperlink \makenote{a \rhyperlink{anchorname}{hyperlink}.} in makenote.
Testing \hypertarget{anchorname}{hypertarget}.
Testing hyperref in makenote \makenote{a \hyperref[labelname]{hyperref}.}.
Testing \label{labelname}label.
\end{document}
或者
\documentclass{scrbook}
\usepackage{fontspec}
\usepackage{scrlayer-scrpage}
\usepackage{scrlayer-notecolumn}
\DeclareRobustCommand*{\rmakenote}[1]{%
\makenote{\detokenize{#1}}%
}
\usepackage{hyperref}
\begin{document}
Testing makenote \makenote{makenote}.
Testing \hyperlink{anchorname}{hyperlink}.
Testing hyperlink \rmakenote{a \hyperlink{anchorname}{hyperlink}.} in makenote.
Testing \hypertarget{anchorname}{hypertarget}.
Testing hyperref in makenote \makenote{a \hyperref[labelname]{hyperref}.}.
Testing \label{labelname}label.
\end{document}