Closed xagawa closed 1 year ago
I remember (at least a previous version of) llncs.cls
had other problems with \doi
if hyperref
is loaded. Over the time I find the best fix is to add the following to the preamble after \documentclass{llncs}
(or otherwise loading llncs
):
% LNCS detects whether "hyperref" is loaded
% in \AtBeginDocument and overwrites \doi if so.
% We overwrite \doi again using our version.
\AtBeginDocument{\def\doi#1{\url{https://doi.org/#1}}}
This also suppresses the effect of \providecommand{\doi}
of splncs04.bst
because \doi
will already be defined by the time TeX processes bibliography. It assumes that you load hyperref
(which I think is the norm these days?).
Adding a version that works without hyperref
:
\documentclass{article}
% This excerpt of code is placed in the public domain.
\makeatletter
\def\doi{\begingroup\catcode`\%=12\relax\doi@}
\def\doi@#1{\endgroup DOI {\ttfamily\doi@loop#1\doi@end}}
\def\doi@loop{\@ifnextchar\doi@end{\doi@end}{\begingroup\let\bgroup\relax
\@ifnextchar\doi@brace@{\endgroup\doi@brace}{\endgroup\doi@token}}}
\let\doi@brace@\bgroup
\def\doi@brace#1{\string{\doi@loop#1\doi@end\string}\doi@loop}
\def\doi@token#1{\expandafter\doi@check\string#1\doi@loop}
\def\doi@check{\expandafter\@ifnextchar\string~{\raisebox{-0.2em}}{}}
\def\doi@end\doi@end{}
\makeatother
\begin{document}
\doi{`1234567890-=~!@#$%^&*()_+[]\ {xyz}|;':",./<>?\egroup\bgroup}.
\end{document}
It feels wrong to skew the simplest, unescaped encoding of DOI due to incapability of certain TeX macros.
@GeeLaw
Thank you for the fixes! The first one works well and I'll use it with \urlstyle{same}
to use a roman font as llncs did.
The current cryptobib with splncs04.bst causes a lot of errors because of
_
in typical doi of papers in LNCS. Replacing_
with\_
in doi eliminates this type of error and works well with and without hyperref.splncs04.bst will output
just after \begin{thebibliography}{nn}. When doi contains plain
_
, say,10.10_1
, this is converted ashttps://doi.org/10.10_1
and we have the errorMissing $ inserted
.