Debian Codegraph @

texmf-dist/source/latex/orcidlink/orcidlink.dtx

raw
1 % \iffalse meta-comment
2 %
3 % Copyright (C) 2019-2026 by Leo C. Stein <[email protected]>
4 % ---------------------------------------------------------------------------
5 % This work may be distributed and/or modified under the
6 % conditions of the LaTeX Project Public License, either version 1.3
7 % of this license or (at your option) any later version.
8 % The latest version of this license is in
9 % http://www.latex-project.org/lppl.txt
10 % and version 1.3 or later is part of all distributions of LaTeX
11 % version 2005/12/01 or later.
12 %
13 % This work has the LPPL maintenance status `maintained'.
14 %
15 % The Current Maintainer of this work is Leo C. Stein.
16 %
17 % This work consists of the files orcidlink.dtx and orcidlink.ins
18 % and the derived filebase orcidlink.sty.
19 %
20 % \fi
21 %
22 % \iffalse
23 %<*driver>
24 \ProvidesFile{orcidlink.dtx}
25 %</driver>
26 %
27 %<*driver>
28 \documentclass{ltxdoc}
29 \usepackage[dvipsnames]{xcolor}
30 \usepackage{orcidlink}[2024/04/09]
31 \hypersetup{colorlinks,urlcolor=NavyBlue,citecolor=NavyBlue,linkcolor=NavyBlue}
32 \hypersetup{pdftitle={The orcidlink package},pdfauthor={Leo C. Stein},
33 pdfsubject={-}}
34 \usepackage{graphicx}
35 \usepackage{microtype}
36 \EnableCrossrefs
37 \CodelineIndex
38 \RecordChanges
39 \begin{document}
40 \DocInput{orcidlink.dtx}
41 \PrintChanges
42 \end{document}
43 %</driver>
44 % \fi
45 %
46 % \CheckSum{60}
47 %
48 % \CharacterTable
49 % {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
50 % Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
51 % Digits \0\1\2\3\4\5\6\7\8\9
52 % Exclamation \! Double quote \" Hash (number) \#
53 % Dollar \$ Percent \% Ampersand \&
54 % Acute accent \' Left paren \( Right paren \)
55 % Asterisk \* Plus \+ Comma \,
56 % Minus \- Point \. Solidus \/
57 % Colon \: Semicolon \; Less than \<
58 % Equals \= Greater than \> Question mark \?
59 % Commercial at \@ Left bracket \[ Backslash \\
60 % Right bracket \] Circumflex \^ Underscore \_
61 % Grave accent \` Left brace \{ Vertical bar \|
62 % Right brace \} Tilde \~}
63 %
64 %
65 % \changes{v1.0.0}{2020/11/19}{Converted to DTX file}
66 % \changes{v1.0.1}{2020/11/21}{Bugfix due to misunderstanding of docstrip}
67 % \changes{v1.0.2}{2020/11/21}{Fix fragility of command when inside of
68 % author, and combined with hyperref's option pdfusetitle}
69 % \changes{v1.0.3}{2021/03/15}{Improve fragility by calculating
70 % scaling ourselves, and using DeclareRobustCommand}
71 % \changes{v1.0.4}{2021/06/11}{Use XeTeXLinkBox to get hyperlink
72 % working correctly with XeTeX. Thanks to Tim Henke for the bug report.}
73 % \changes{v1.0.5}{2023/12/30}{Turn off TikZ externalization of logos.
74 % Thanks to github user aquileia for the bug report.}
75 % \changes{v1.1.0}{2024/06/25}{Support ORCID's three different ID
76 % formats. Thanks to Hugo Heagren for suggestions.}
77 % \changes{v1.1.1}{2026/04/09}{Add explicit dependency for etoolbox. Solves
78 % potential errors if etoolbox isn't properly pulled in from hyperref. Thanks to
79 % Otto Hanski.}
80 %
81 % \DoNotIndex{\newcommand,\newenvironment}
82 %
83 % \GetFileInfo{orcidlink.sty}
84 % \title{The \textsf{orcidlink} package}
85 % \author{Leo C.\ Stein\,\orcidlink{0000-0001-7559-9597} \\ \href{mailto:[email protected]}{[email protected]}}
86 % \date{\fileversion~from \filedate}
87 %
88 % \maketitle
89 %
90 % \noindent Source repo:
91 % \url{https://github.com/duetosymmetry/orcidlink-LaTeX-command}.
92 %
93 % \section{Introduction}
94 %
95 % This is a LaTeX style file providing a macro for inserting a
96 % hyperlinked ORCiD logo. The package also provides three commands
97 % for ORCiD's three recommended ID printing formats, and a command for
98 % just the ORCiD logo, not linked to anything.
99 %
100 % \section{Usage}
101 %
102 % To use this package, in the preamble include
103 % \begin{verbatim}
104 % \usepackage{orcidlink}
105 % \end{verbatim}
106 %
107 % \DescribeMacro{\orcidlink\marg{orcid}}
108 % Insert the ORCiD logo (\orcidlink{}), which is hyperlinked to the URL
109 % of the researcher whose iD was specified.
110 % Replace the mandatory argument \meta{orcid} with your
111 % ORCiD --- just the digits, not your whole URL.
112 % For example, the command
113 % |\orcidlink{0000-0001-7559-9597}| will hyperlink to the URL
114 % \url{https://orcid.org/0000-0001-7559-9597}.
115 % This is most common in
116 % the author list. For example, in the preamble of a RevTeX article,
117 % if you write
118 % \begin{verbatim}
119 % \author{Emmy Noether\,\orcidlink{0000-0000-0000-0000}}
120 % \end{verbatim}
121 % then the article byline will look something like this:
122 %
123 % \includegraphics[width=0.5\textwidth]{preview}\newline{}
124 % The macro is used in the author line of this documentation as well.
125 %
126 % \DescribeMacro{\orcidlogo}
127 % If you simply want the ORCiD logo without a hyperlink anywhere, use
128 % |\orcidlogo|.
129 %
130 % ORCiD's \href{https://info.orcid.org/brand-guidelines/}{guidelines}
131 % recommend three formats: full, compact, and inline. The three
132 % formats are available:
133 % \begin{enumerate}
134 % \item \DescribeMacro{\orcidlinkf\marg{orcid}} Full format. Example:
135 % |\orcidlinkf{0000-0001-7559-9597}| will insert
136 % \orcidlinkf{0000-0001-7559-9597}
137 % \item \DescribeMacro{\orcidlinkc\marg{orcid}} Compact format.
138 % Example: |\orcidlinkc{0000-0001-7559-9597}| will insert
139 % \orcidlinkc{0000-0001-7559-9597}
140 % \item \DescribeMacro{\orcidlinki\marg{Name}\marg{orcid}} Inline
141 % format. Example: |\orcidlinki{Leo C. Stein}{0000-0001-7559-9597}|
142 % will insert \orcidlinki{Leo C. Stein}{0000-0001-7559-9597}
143 % \end{enumerate}
144 %
145 % \DescribeMacro{\orcidlinkX\marg{before}\marg{orcid}\marg{after}}
146 %
147 % The command |\orcidlinkX{before}{orcid}{after}| is a helper macro
148 % that's used to implement all of the others. Though it is just an
149 % internal helper, I saw no reason to keep it internal.
150 % |\orcidlinkX{before}{orcid}{after}| results in
151 % \orcidlinkX{before}{orcid}{after}. The entire output is hyperlinked
152 % to the ORCiD page. There is a thin space |\,| between ``before,''
153 % the logo, and ``after.'' However if ``before'' is empty, the space
154 % will be omitted; similarly for ``after.''
155 %
156 % \section{Package Compatibility}
157 %
158 % This package relies on \texttt{hyperref} and \texttt{tikz}. If you
159 % want to pass options to either of these packages, load them
160 % \emph{before} you load \texttt{orcidlink}. Similarly, if you want
161 % to specify options to e.g. \texttt{xcolor}, load \texttt{xcolor}
162 % before loading \texttt{tikz} or \texttt{orcidlink}.
163 %
164 % \StopEventually{}
165 %
166 % \section{Implementation}
167 %
168 % \iffalse
169 %<*package>
170 % \fi
171 %
172 % \begin{macrocode}
173 \NeedsTeXFormat{LaTeX2e}[1994/06/01]
174 \ProvidesPackage{orcidlink}
175 [2026/04/09 v1.1.1 Add explicit etoolbox dependency.]
176
177 %% This started out as Milo's code on TeX.SE,
178 %% see https://tex.stackexchange.com/a/445583/34063.
179 %% It has since been expanded with more commands.
180 \RequirePackage{etoolbox}
181 \RequirePackage{hyperref}
182 \RequirePackage{tikz}
183
184 \ProcessOptions\relax
185
186 \usetikzlibrary{svg.path}
187
188 \definecolor{orcidlogocol}{HTML}{A6CE39}
189 \tikzset{
190 orcidlogo/.pic={
191 \fill[orcidlogocol] svg{M256,128c0,70.7-57.3,128-128,128C57.3,256,0,198.7,0,128C0,57.3,57.3,0,128,0C198.7,0,256,57.3,256,128z};
192 \fill[white] svg{M86.3,186.2H70.9V79.1h15.4v48.4V186.2z}
193 svg{M108.9,79.1h41.6c39.6,0,57,28.3,57,53.6c0,27.5-21.5,53.6-56.8,53.6h-41.8V79.1z M124.3,172.4h24.5c34.9,0,42.9-26.5,42.9-39.7c0-21.5-13.7-39.7-43.7-39.7h-23.7V172.4z}
194 svg{M88.7,56.8c0,5.5-4.5,10.1-10.1,10.1c-5.6,0-10.1-4.6-10.1-10.1c0-5.6,4.5-10.1,10.1-10.1C84.2,46.7,88.7,51.3,88.7,56.8z};
195 }
196 }
197
198 %% Reciprocal of the height of the svg whose source is above. The
199 %% original generates a 256pt high graphic; this macro holds 1/256.
200 \newcommand{\@OrigHeightRecip}{0.00390625}
201
202 %% We will compute the current X height to make the logo the right height
203 \newlength{\@curXheight}
204
205 %% Prevent externalization of the ORCiD logo.
206 \newcommand{\@preventExternalization}{%
207 \ifcsname tikz@library@external@loaded\endcsname%
208 \tikzset{external/export next=false}\else\fi%
209 }
210
211 % \end{macrocode}
212 %
213 % \begin{macro}{\orcidlogo}
214 % \begin{macrocode}
215 \newcommand{\orcidlogo}{%
216 \texorpdfstring{%
217 \setlength{\@curXheight}{\fontcharht\font`X}%
218 \XeTeXLinkBox{%
219 \@preventExternalization%
220 \begin{tikzpicture}[yscale=-\@OrigHeightRecip*\@curXheight,
221 xscale=\@OrigHeightRecip*\@curXheight,transform shape]
222 \pic{orcidlogo};
223 \end{tikzpicture}%
224 }}{}}
225 % \end{macrocode}
226 % \end{macro}
227
228 % \begin{macro}{\orcidlinkX}
229 % \begin{macrocode}
230 \DeclareRobustCommand\orcidlinkX[3]{\href{https://orcid.org/#2}{%
231 \ifstrempty{#1}{}{#1\,}\orcidlogo\ifstrempty{#3}{}{\,#3}}}
232 % \end{macrocode}
233 % \end{macro}
234 % \begin{macro}{\orcidlinkf}
235 % \begin{macrocode}
236 \newcommand{\orcidlinkf}[1]{\orcidlinkX{}{#1}{https://orcid.org/#1}}
237 % \end{macrocode}
238 % \end{macro}
239 % \begin{macro}{\orcidlinkc}
240 % \begin{macrocode}
241 \newcommand{\orcidlinkc}[1]{\orcidlinkX{}{#1}{#1}}
242 % \end{macrocode}
243 % \end{macro}
244 % \begin{macro}{\orcidlinki}
245 % \begin{macrocode}
246 \newcommand{\orcidlinki}[2]{\orcidlinkX{#1}{#2}{}}
247 % \end{macrocode}
248 % \end{macro}
249 % \begin{macro}{\orcidlink}
250 % \begin{macrocode}
251 \newcommand{\orcidlink}[1]{\orcidlinkX{}{#1}{}}
252
253 \endinput
254 % \end{macrocode}
255 % \end{macro}
256 %
257
258 %
259 % \iffalse
260 %</package>
261 % \fi
262 %
263 % \Finale
264 \endinput