Estou tentando colocar um \hyperlink
em um \makenote
, mas recebo o seguinte erro:
! 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.
Este é o código fonte:
% 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}
Eu uso lualatex
para compilação, mas recebo o mesmo erro se usar pdflatex
(comentando fontspec
previamente).
O \hyperlink
comando funciona muito bem no texto, só falha no arquivo \makenote
.
O \hyperref
comando funciona em \makenote
, mas infelizmente as âncoras dos \label
s não estão exatamente onde os \label
s são definidos em geral. Portanto esta é uma solução.
Responder1
Desde KOMA-Script 3.23O pacote scrlayer-notecolumn
possui uma variante em estrela de \makenote
, que não precisa proteger comandos, que pode quebrar e não deve ser expandida:
\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}
resulta em
sem erro.
Você pode obter o mesmo resultado (mesmo com KOMA-Script anterior a 3.23) usando:
\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}
ou
\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}
ou
\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}