summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/authorarchive/authorarchive.sty
blob: 41534ebd125a42c9a874e13a1b1c01c2d0433755 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
%% Copyright (C) 2008-2019 Achim D. Brucker, https://www.brucker.ch
%%
%% License:
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1.3c of the License, or (at your option) any later version.
%%   OR
%%   The 2-clause BSD-style license.
%%
%%   SPDX-License-Identifier: LPPL-1.3c+ OR BSD-2-Clause
\NeedsTeXFormat{LaTeX2e}\relax
\ProvidesPackage{authorarchive}
  [2019/06/23 v1.1.1%
  Self-archiving information for scientific publications.]
%
\PassOptionsToPackage{hyphens}{url}
%
\RequirePackage{ifthen}
\RequirePackage[inline]{enumitem}
\RequirePackage{graphicx}
\RequirePackage{eso-pic}
\RequirePackage{intopdf}
\RequirePackage{kvoptions}
\RequirePackage{hyperref}
\RequirePackage{calc}
\RequirePackage{qrcode}
\RequirePackage{dtk-logos}
%
%Better url breaking
\g@addto@macro{\UrlBreaks}{\UrlOrds}
%
% Option declarations
% -------------------
\SetupKeyvalOptions{
  family=AA,
  prefix=AA@
}
%
\DeclareStringOption[.]{bibtexdir}
\DeclareStringOption[https://duckduckgo.com/?q=]{baseurl}
\DeclareStringOption[.pdf]{suffix}
\DeclareStringOption[UNKNOWN PUBLISHER]{publisher}[]
\DeclareStringOption[UNKNOWN YEAR]{year}[]
\DeclareStringOption[]{key}[]
\DeclareStringOption[]{doi}[]
\DeclareStringOption[]{doiText}[]
\DeclareStringOption[]{publisherurl}[]
\DeclareStringOption[UNKNOWN START PAGE]{startpage}[]
\DeclareStringOption[UNKNOWN PUBLICATION]{publication}[]

\DeclareBoolOption{ACM}
\DeclareBoolOption{acmart}
\DeclareBoolOption{ENTCS}
\DeclareBoolOption{IEEE}
\DeclareBoolOption{LNCS}
\DeclareBoolOption{LNI}
\DeclareBoolOption{nocopyright}
\DeclareBoolOption{nourl}
\DeclareBoolOption{nobib}
\DeclareBoolOption{orcidicon}
%\ProcessOptions\relax


% Default option rule
\DeclareDefaultOption{%
  \ifx\CurrentOptionValue\relax
    \PackageWarningNoLine{\@currname}{%
      Unknown option `\CurrentOption'\MessageBreak
      is passed to package `authorarchive'%
    }%
    % Pass the option to package color.
    % Again it is better to expand \CurrentOption.
    \expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{color}%
  \else
    % Package color does not take options with values.
    % We provide the standard LaTeX error.
    \@unknownoptionerror
  \fi
}
\ProcessKeyvalOptions*

% Provide command for dynamic configuration seutp
\def\authorsetup{\kvsetkeys{AA}}

% Load local configuration
\InputIfFileExists{authorarchive.config}{}{}


\newlength\AA@x
\newlength\AA@y
\newlength\AA@width

\def\AA@bibBibTeX{\AA@bibtexdir/\AA@key.bib}
\def\AA@bibBibTeXLong{\AA@bibtexdir/\AA@key.bibtex}
\def\AA@bibWord{\AA@bibtexdir/\AA@key.word.xml}
\def\AA@bibEndnote{\AA@bibtexdir/\AA@key.enw}
\def\AA@bibRIS{\AA@bibtexdir/\AA@key.ris}

\newboolean{AA@bibExists}
\setboolean{AA@bibExists}{false}
\IfFileExists{\AA@bibBibTeX}{\setboolean{AA@bibExists}{true}}{}
\IfFileExists{\AA@bibBibTeXLong}{\setboolean{AA@bibExists}{true}}{}
\IfFileExists{\AA@bibWord}{\setboolean{AA@bibExists}{true}}{}
\IfFileExists{\AA@bibEndnote}{\setboolean{AA@bibExists}{true}}{}
\IfFileExists{\AA@bibRIS}{\setboolean{AA@bibExists}{true}}{}

\setlength\AA@x{1in+\hoffset+\oddsidemargin}

\newcommand{\authorcrfont}{\footnotesize}
\newcommand{\authorat}[1]{\AtPageUpperLeft{\put(\LenToUnit{\AA@x},\LenToUnit{.2cm-\paperheight}){#1}}}
\newcommand{\authorwidth}[1]{\setlength{\AA@width}{#1}}
\setlength{\AA@width}{\textwidth}

\def\AA@pageinfo{}
\ifthenelse{\equal{\AA@startpage}{UNKNOWN START PAGE}}{%
}{%
  \setcounter{page}{\AA@startpage}%
  \def\AA@pageinfo{pp. \thepage--\pageref{\aa@lastpage}, }
}



%%%% sig-alternate.cls
\ifAA@ACM%
  \ifthenelse{\equal{\AA@publisher}{UNKNOWN PUBLISHER}}{%
    \setkeys{AA}{publisher=ACM}
  }{}
  \global\boilerplate={}
  \global\copyrightetc={}
  \renewcommand{\conferenceinfo}[2]{}
  \renewcommand{\authorcrfont}{\scriptsize}
  \setlength\AA@x{1in+\hoffset+\oddsidemargin}
  \setlength\AA@y{-\textheight+\topmargin+\headheight-\footskip} % -\voffset-\topmargin-\headheight-\footskip}
  \renewcommand{\authorat}[1]{\put(\LenToUnit{\AA@x},\LenToUnit{\AA@y}){#1}}
  \setlength{\AA@width}{\columnwidth}
\fi
%
%%%% acmart.cls
\ifAA@acmart%
  \ifthenelse{\equal{\AA@publisher}{UNKNOWN PUBLISHER}}{%
    \setkeys{AA}{publisher=ACM}
  }{}
  \renewcommand{\authorat}[1]{\AtPageUpperLeft{\put(\LenToUnit{\AA@x},\LenToUnit{0.2cm-\paperheight}){#1}}}
  \setlength{\AA@width}{\textwidth}
\fi
%
%%%% LNCS
\ifAA@LNCS%
  \ifAA@orcidicon%
    \renewcommand{\orcidID}[1]{\href{https://orcid.org/#1}{%
      \textsuperscript{\,\includegraphics[height=2\fontcharht\font`A]{vector_iD_icon}}}}
  \else\relax\fi%
%  
  \ifthenelse{\equal{\AA@publisher}{UNKNOWN PUBLISHER}}{%
    \setkeys{AA}{publisher=Springer-Verlag}
  }{}
  \renewcommand{\authorcrfont}{\scriptsize}
  \@ifclasswith{llncs}{a4paper}{%
    \pdfpagesattr{/CropBox [92 114 523 780]}%
    \renewcommand{\authorat}[1]{\put(\LenToUnit{\AA@x},40){#1}}%
  }{%
    \pdfpagesattr{/CropBox [92 65 523 731]}% LNCS page: 152x235 mm
    \renewcommand{\authorat}[1]{\put(\LenToUnit{\AA@x},23){#1}}
  }
  \setlength{\AA@width}{\textwidth}
  \setcounter{tocdepth}{2}
\fi
%
%%%% LNI
\ifAA@LNI%
  \ifthenelse{\equal{\AA@publisher}{UNKNOWN PUBLISHER}}{%
    \setkeys{AA}{publisher=GI}
  }{}
  \renewcommand{\authorat}[1]{\put(\LenToUnit{\AA@x},35){#1}}
  \renewcommand{\authorcrfont}{\scriptsize}
  \pdfpagesattr{/CropBox [70 65 526.378 748.15]} % TODO
  \setlength{\AA@width}{\textwidth}
  \setcounter{tocdepth}{2}
\fi
%
%%%% ENTCS
\ifAA@ENTCS%
  \addtolength{\voffset}{1cm}
  \ifthenelse{\equal{\AA@publisher}{UNKNOWN PUBLISHER}}{%
    \setkeys{AA}{publisher=Elsevier Science B.~V.}
  }{}
  \renewcommand{\authorat}[1]{\put(\LenToUnit{\AA@x},\LenToUnit{-.5cm-\the\ht\AA@authoratBox}){#1}}
  \renewcommand{\authorcrfont}{\scriptsize}
  \setlength{\AA@width}{\textwidth}
\fi
%
%%%% IEEE
\ifAA@IEEE%
  \ifthenelse{\equal{\AA@publisher}{UNKNOWN PUBLISHER}}{%
    \setkeys{AA}{publisher=IEEE}
  }{}
  \renewcommand{\authorat}[1]{\put(\LenToUnit{\AA@x},6){#1}}
  \renewcommand{\authorcrfont}{\scriptsize}
  \setlength{\AA@width}{\textwidth}
  \setcounter{tocdepth}{2}
\fi
%

\hypersetup{%
  draft         = false,
  bookmarksopen = true,
  bookmarksnumbered= true,
  pdfauthor     = {\@author},
  pdftitle      = {\@title},
}

\@ifpackageloaded{totpages}{%
  \def\aa@lastpage{TotPages}
}{%
  \RequirePackage{lastpage}
  \def\aa@lastpage{LastPage}
}
\newsavebox{\AA@authoratBox}

\AddToShipoutPicture*{%
  \setlength{\unitlength}{1mm}%
  \savebox{\AA@authoratBox}{%
    \parbox{1.4cm}{%
      \bgroup%
        \normallineskiplimit=0pt%
        \ifAA@nourl%
           \ifx\AA@doi\@empty\relax%
           \else%
              \qrcode[hyperlink,height=1.17cm,padding]{https://doi.org/\AA@doi}%
            \fi%
        \else%
          \qrcode[hyperlink,height=1.17cm,padding]{\AA@baseurl/\AA@key\AA@suffix}%
        \fi%
      \egroup%
    }%
    \ifAA@nourl\ifx\AA@doi\@empty\addtolength{\AA@width}{1.4cm}\fi\fi
    \parbox{\AA@width-1.4cm}{\authorcrfont%
      \ifAA@LNCS%
        \AA@publication, \AA@pageinfo  \AA@year. %
        \ifAA@nocopyright\else
          \textcopyright~\AA@year~\AA@publisher.
        \fi
        This is the author's
        version of the work. It is posted
        \ifAA@nourl\relax\else%
          at \url{\AA@baseurl/\AA@key\AA@suffix} %
        \fi
        \ifAA@nocopyright\relax\else
          by permission of \AA@publisher{}
        \fi
        for your personal use.
        \ifx\AA@doi\@empty%
          \relax
        \else
          The final publication is available at Springer via
          \ifx\AA@doiText\@empty%
            \url{https://doi.org/\AA@doi}.
          \else
            \href{https://doi.org/\AA@doi}{\AA@doiText}.
          \fi
        \fi
      \else
        \ifAA@nocopyright\relax\else
          \textcopyright~\AA@year~\AA@publisher. %
        \fi%
        This is the author's
        version of the work. It is posted
        \ifAA@nourl\relax\else%
          at \url{\AA@baseurl/\AA@key\AA@suffix} %
        \fi
        \ifAA@nocopyright\relax\else
          by permission of \AA@publisher{} %
        \fi
        for your personal use. Not for redistribution. The definitive
        version was published in \emph{\AA@publication}, \AA@pageinfo \AA@year%
        \ifx\AA@doi\@empty%
          \ifx\AA@publisherurl\@empty%
            .%
          \else
            \url{\AA@publisherurl}.%
          \fi
        \else
          \ifx\AA@doiText\@empty%
            , doi: \href{https://doi.org/\AA@doi}{\AA@doi}.%
          \else
            , doi: \href{https://doi.org/\AA@doi}{\AA@doiText}.%
          \fi
        \fi
      \fi
      \ifAA@nobib\relax\else%
        \ifthenelse{\boolean{AA@bibExists}}{%
          \hfill
          \begin{itemize*}[label={}, itemjoin={,}]
            \IfFileExists{\AA@bibBibTeX}{%
              \item \attachandlink{\AA@bibBibTeX}[application/x-bibtex]{BibTeX entry of this paper}{\BibTeX}%
            }{%
              \IfFileExists{\AA@bibBibTeXLong}{%
                \item \attachandlink[\AA@key.bib]{\AA@bibBibTeXLong}[application/x-bibtex]{BibTeX entry of this paper}{\BibTeX}%
              }{%
                \typeout{No file \AA@bibBibTeX{} (and no \AA@bibBibTeXLong) found. Not embedded reference in BibTeX format.}%
              }%
            }%
            \IfFileExists{\AA@bibWord}{%
              \item \attachandlink{\AA@bibWord}[application/xml]{XML entry of this paper (e.g., for Word 2007 and later)}{Word}%
            }{%
              \typeout{No file \AA@bibWord{} found. Not embedded reference for Word 2007 and later.}%
            }%
            \IfFileExists{\AA@bibEndnote}{%
              \item \attachandlink{\AA@bibEndnote}[application/x-endnote-refer]{Endnote entry of this paper}{EndNote}%
            }{%
              \typeout{No file \AA@bibEndnote{} found. Not embedded reference in Endnote format.}%
            }%
            \IfFileExists{\AA@bibRIS}{%
              \item \attachandlink{\AA@bibRIS}[application/x-research-info-systems]{RIS entry of this paper}{RIS}%
            }{%
              \typeout{No file \AA@bibRIS{} found. Not embedded reference in RIS format.}%
            }%
          \end{itemize*}\\
        }{%
          \PackageError{authorarchive}{No bibliographic files found. Specify option 'nobib' if this is intended.}
        }
      \fi
    }
  }
  \authorat{\raisebox{\the\ht\AA@authoratBox}{\usebox{\AA@authoratBox}}}
}