1

Using version 2019/11/18 of Springer's sn-jnl.cls template (archived as a gist here), I get the following:

\documentclass{sn-jnl}
\usepackage{xparse}
\NewDocumentCommand{\githublink}{m m o}{\href{}{\texttt{}}}
\begin{document}
. \githublink{}{}[]
\end{document}
! Argument of \XKV@d@fine@k@y has an extra }.
<inserted text>
                \par
l.5 . \githublink{}{}[]

What's going on here, and how do I fix this?

EDIT

This can be further minimized to

\documentclass{article}
\RequirePackage{hyperref}%
%%\RequirePackage{hypcap}%
\gdef\breakurldefns{%
%\if@pdflatex\else%
  \RequirePackage[hyphenbreaks]{breakurl}%
  \let\href\burlalt%
  %\fi
}%
\breakurldefns%
%    \bgroup
\usepackage{hyperref}
\begin{document}
. \href{}{\texttt{}}
\end{document}
10
  • you do not need xparse with current latex releases, which latex format are you using (current is LaTeX2e <2022-11-01> patch level 1) Commented Jan 17, 2023 at 22:44
  • your MWE is missing \makeatletter for \if@pdflatex Commented Jan 17, 2023 at 22:48
  • this is unrelated to newdocumentcommand you can simplify your example to \documentclass{article} \usepackage{hyperref} \usepackage[hyphenbreaks]{breakurl} \begin{document} . \burlalt{}{\texttt{}} \end{document} Commented Jan 17, 2023 at 22:53
  • Thank you, MWE now fixed Commented Jan 17, 2023 at 23:03
  • 1
    the 2nd argument is the URL to link to, did you intend to put the font change in the first argument? Commented Jan 17, 2023 at 23:10

2 Answers 2

2

The breakurl package shouldn't be used with pdflatex, but to avoid that it is loaded you must load the class with the option pdflatex as the class is a bit dump and doesn't make use of existing methods to detect the output mode automatically.

\documentclass[pdflatex]{sn-jnl}
\begin{document}

\href{abc}{\texttt{abc}}
\end{document}
1

If you try

\documentclass{article}
\usepackage{hyperref}
\usepackage[hyphenbreaks]{breakurl}
\begin{document}

. \burlalt{aaaa}{bbb}
\end{document}

You get

enter image description here

so the first argument is typeset, you can use font changes there. The second argument is the URL

3
  • \documentclass{article} \usepackage{hyperref} \usepackage{breakurl} \begin{document} \burlalt{\texttt{aaaa}}{bbbb} \end{document} still fails, but \texttt{\burlalt{aaaa}{bbbb}} succeeds. Commented Jan 17, 2023 at 23:22
  • but not if you compile with latex, then you get bbb, and in the OP's class breakurl is only used in dvi mode (hoping that \if@pdflatex does what is claim it does). Commented Jan 17, 2023 at 23:24
  • @UlrikeFischer eek, I'd delete but it's accepted, Jason if you accepted Ulrike's answer... Commented Jan 18, 2023 at 0:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .