2

Lets say I have the following document:

\documentclass[a4paper]{article}

\usepackage{authblk}

\usepackage{hyperref}

\begin{document}

\title{Some paper}

\author[1]{First Last}
\author[2]{Second Last}

\affil[1]{First Affil}
\affil[2]{Second Affil}

\maketitle

\end{document}

and I want to include the ORCID of one of the authors. I would like the symbol with an attached hyperlink appearing after one of the authors' names.

How would I go about this?

Note: This may seem like a duplicate of this question, in which the following approaches are suggested:

  1. Use Academicons:

    \usepackage{academicons}
    \usepackage{xcolor}
    \definecolor{orcidlogocol}{HTML}{A6CE39}
    
    \newcommand{\orcid}[1]{
      \href{https://orcid.org/#1}{\textcolor{orcidlogocol}{\aiOrcid}}
    }
    

    This works, but only using xelatex and not plain (pdf)latex.

  2. Using a suitable graphic (say orcid.pdf, converted from one of the svgs available:

    \usepackage{graphicx}
    
    \newcommand{\orcid}[1]{
      \href{https://orcid.org/#1}{\includegraphics[scale=1]{orcid}}
    }
    

    Note that there is a more sophisticated version which scales the icon to the height of the surrounding text using the scalerel package:

      \newcommand\orcidicon[1]{
        \href{https://orcid.org/#1}{\mbox{\scalerel{\includegraphics{orcid}}{|}}}}
    

    This unfortunately gives me the error

      ! Use of \\author doesn't match its definition.
    

Thus, both of the approaches don't really seem to work for me. Is there any way to get this working?

2

The easy way to set something to a good height relative to the current font is to use dimensions with units of ex, which is nominally the height of the lower case x in the font. So naively one would write

 \includegraphics[height=1.7ex]{orcid}

to include the image.

Unfortunately the authblk constructions need the above command to expand nicely; but it doesn't, even after adding \protection type mechanisms such as \newrobustcmd from etoolbox (try

\newrobustcmd{\orcid}[1]{%
  \href{https://orcid.org/#1}{\includegraphics[height=1.7ex]{orcid}%
  \,#1}}

and you will see a very strange effect).

A way round this is to store the graphic appropriately scaled in a box and then use that box in the affiliation.

The combination

\newbox{\myorcidaffilbox}
\sbox{\myorcidaffilbox}{\large\includegraphics[height=1.7ex]{orcid}}

sets up a box for this purpose and stores the graphic in it; the size \large is the font size that is used for printing affiliations. Then we can write a command

\newcommand{\orcidaffil}[1]{%
  \href{https://orcid.org/#1}{\usebox{\myorcidaffilbox}\,#1}}

that puts this box in to our orcid construct via a \usebox command.

Sample output

\documentclass[a4paper]{article}

\usepackage{authblk}
\usepackage{graphicx}
\usepackage{hyperref}

\newbox{\myorcidaffilbox}
\sbox{\myorcidaffilbox}{\large\includegraphics[height=1.7ex]{orcid}}
\newcommand{\orcidaffil}[1]{%
  \href{https://orcid.org/#1}{\usebox{\myorcidaffilbox}\,#1}}

\begin{document}

\title{Some paper}

\author[1]{First Last}
\author[2]{Second Last}

\affil[1]{First Affil \orcidaffil{0000-0002-1825-0097}}
\affil[2]{Second Affil}

\maketitle

\end{document}

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.