0

I would like to have my DOIs underlined using the RSC package, if possible just the DOI, e.g. tweaking the DOI function rather than the hyperlink. The solution suggested here "underline the doi entry with natbib and abbrvnat style" does work for the RSC package even though it load natbib. Any idea ?

Nb: I have loaded every package and options related to bibliography I am using, even those redondants.

\documentclass[10pt,a4paper]{article}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{filecontents}

\usepackage[linktoc=all,hidelinks,bookmarksnumbered,pagebackref,xetex]{hyperref}
\PassOptionsToPackage{sort&compress,square,numbers}{natbib}
\usepackage[usedoi,linkdoi,super=false]{rsc}

% \usepackage[normalem]{ulem}% \uline
% \newcommand{\doi}[1]{doi: \uline{#1}}

\begin{filecontents}{biblio_test.bib}

@Article{hung2010practical,
  Title                    = {On the practical aspects of recording wideline QCPMG NMR spectra},
  Author                   = {Hung, Ivan and Gan, Zhehong},
  Journal                  = {J. Magn. Reson.},
  Year                     = {2010},
  Number                   = {2},
  Pages                    = {256--265},
  Volume                   = {204},

  Doi                      = {10.1016/j.jmr.2010.03.001},
  File                     = {:Publications\\1-s2.0-S1090780710000571-main.pdf:PDF},
  Owner                    = {Henri},
  Publisher                = {Elsevier},
  Timestamp                = {2015.09.03}
}

\end{filecontents}


\begin{document}
Some text.\cite{hung2010practical}

\bibliographystyle{rsc}
\bibliography{biblio_test}

    \end{document}
1
+50

Since rsc.bst does not define a dedicated DOI macro we need to add that ourselves.

Find rsc.bst copy it to a location LaTeX can find it and rename it to, say, rsc-hcn.bst

Open rsc-hcn.bst and locate FUNCTION {format.doi} replace it by

FUNCTION {format.doi}
{ use.doi.all
    { doi empty$
        'skip$
        {
          link.doi
            {
              "\href{http://dx.doi.org/"
              doi *
              "}{" *
              bbl.doi * " \doiformat{" * doi * 
              "}}" *
            }
            { bbl.doi doi tie.or.space.connect }
          if$
          output
        }
      if$
    }
    'skip$
  if$
}

If you want the "DOI:" prefix to stick to the DOI, you can use bbl.doi * "~\doiformat{" * doi *.

In your document define \doiformat as desired.

\newcommand*\doiformat[1]{\uline{#1}}

MWE

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{filecontents}

\usepackage[linktoc=all,hidelinks,bookmarksnumbered,pagebackref]{hyperref}
\PassOptionsToPackage{sort&compress,square,numbers}{natbib}
\usepackage[usedoi,linkdoi,super=false]{rsc}

\usepackage[normalem]{ulem}% \uline
%\usepackage{soul}
\newcommand*\doiformat[1]{\uline{#1}}% or \ul from soul
\begin{filecontents}{\jobname.bib}

@Article{hung2010practical,
  Title                    = {On the practical aspects of recording wideline QCPMG NMR spectra},
  Author                   = {Hung, Ivan and Gan, Zhehong},
  Journal                  = {J. Magn. Reson.},
  Year                     = {2010},
  Number                   = {2},
  Pages                    = {256--265},
  Volume                   = {204},
  Doi                      = {10.1016/j.jmr.2010.03.001},
}
\end{filecontents}

\begin{document}
Some text.\cite{hung2010practical}

\bibliographystyle{rsc-hcn}
\bibliography{\jobname}
\end{document}

enter image description here


You can also use biblatex.

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{filecontents}
\usepackage[style=chem-rsc,doi=true]{biblatex}
\usepackage{hyperref}
\usepackage{soul}
\newcommand*\doiformat[1]{\ul{#1}}
\DeclareFieldFormat{doi}{%
  \mkbibacro{DOI}\addcolon\space
  \ifhyperref
    {\href{http://dx.doi.org/#1}{\doiformat{#1}}}
    {\doiformat{#1}}}

\begin{filecontents}{\jobname.bib}

@Article{hung2010practical,
  Title                    = {On the practical aspects of recording wideline QCPMG NMR spectra},
  Author                   = {Hung, Ivan and Gan, Zhehong},
  Journal                  = {J. Magn. Reson.},
  Year                     = {2010},
  Number                   = {2},
  Pages                    = {256--265},
  Volume                   = {204},
  Doi                      = {10.1016/j.jmr.2010.03.001},
}
\end{filecontents}

\addbibresource{\jobname.bib}

\begin{document}
Some text.\cite{hung2010practical}

\printbibliography
\end{document}
|improve this answer|||||
  • Wow, I did not realize it would be so much work just to get underlined doi. Thanks a lot ! Both solution work for me on their respective MWE, I have only tried solution 1 on my thesis, but there is no reason why it would not. If I may, I have copied the file "rsc-hcn.bst" in the same folder as "rsc.bst" (I use Texmaker and portable Miktek), yet bibtex could not find it and had to move it to the same folder as the master document. Would you know a good location for it ? – HcN Sep 27 '15 at 21:57
  • You can move it to your locale TeX folder. It did not work because you didn't renew the file name database. See tex.stackexchange.com/q/94257/35864, tex.stackexchange.com/q/2063/35864, tex.stackexchange.com/q/69483/35864, tex.stackexchange.com/q/30494/35864. – moewe Sep 28 '15 at 6:37
  • @HcN Forgot to ping you above. Additionally, if you don't use this style for many documents you can just have it next to the document that ought to use it as you do now. – moewe Sep 28 '15 at 7:34
  • Also, there seems to be a linebreak problem of the underlined doi using the biblatex option. Is there any solution to that problem ? – HcN Oct 9 '15 at 13:07
  • @HcN Line breaking in underlined text is notoriously hard, and line breaking in URLs is also very complicated. Together they are (at least) doubly complicated. It seems that the url package's command and the underlining commands don't like each other, I'm not sure if there is a good solution – moewe Oct 9 '15 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.