-
Notifications
You must be signed in to change notification settings - Fork 2
/
author-partial.tex
180 lines (150 loc) · 4.71 KB
/
author-partial.tex
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
%%%%% Authors, affiliations and author notes stuff %%%%%
% Macros for creating and referencing stored reference
\makeatletter
\def\MyNewLabel#1#2#3{\expandafter\gdef\csname #1@#2\endcsname{#3}}
\def\MyRef#1#2{\@ifundefined{#1@#2}{???}{\csname #1@#2\endcsname}}
\newcommand*\ifcounter[1]{%
\ifcsname c@#1\endcsname
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi
}
\makeatother
% Create labels for Addresses if the are given by code
$for(address)$
\MyNewLabel{ADDRTXT}{$address.code$}{$address.address$}
$endfor$
% Create labels for Footnotes if they are given by code
$for(footnote)$
\MyNewLabel{ANOTETXT}{$footnote.code$}{$footnote.text$}
$endfor$
%%% Special footnotes for addresses and author footnotes
\usepackage{bigfoot}
\DeclareNewFootnote{Addr}[arabic] % Only used for NOT authblk
\DeclareNewFootnote{ANote}[fnsymbol]
%%% Address and author notes as a function of format %%%
$if(authblk)$ % Use authblk for affiliations %%%%%%%%%%%
\usepackage{authblk}
% Always separate by commas
\renewcommand\Authsep{, }
\renewcommand\Authand{, }
\renewcommand\Authands{, }
% Counter for addresses and footnotes
\newcounter{addrcnt}
% thanks definition that doesn't produce superscript marks
\makeatletter
\newcommand*\createaddrlblbycode[1]{%
\ifcounter{ADDRLBL@#1}
{}
{\refstepcounter{addrcnt}\newcounter{ADDRLBL@#1}\setcounter{ADDRLBL@#1}{\value{addrcnt}}}%
}
\newcommand*\addrlblbycode[1]{\arabic{ADDRLBL@#1}}
\newcommand*\addrbycode[1]{%
\ifcounter{ADDR@#1}
{}
{\newcounter{ADDR@#1}%
\affil[\addrlblbycode{#1}]{\MyRef{ADDRTXT}{#1}}}%
}
\newcommand*\createanotelblbycode[1]{%
\ifcounter{ANOTELBL@#1}
{}
{\refstepcounter{footnoteANote}\newcounter{ANOTELBL@#1}\setcounter{ANOTELBL@#1}{\value{footnoteANote}}}%
}
\newcommand*\anotelblbycode[1]{\fnsymbol{ANOTELBL@#1}}
\newcommand*\anotebycode[1]{%
\ifcounter{ANOTE@#1}
{}
{\newcounter{ANOTE@#1}%
\footnotetextANote[\value{ANOTELBL@#1}]{\MyRef{ANOTETXT}{#1}}}%
}
\makeatother
$for(author)$
$for(author.affiliation)$
\createaddrlblbycode{$author.affiliation$}
$endfor$
$if(author.corresponding_author)$
\MyNewLabel{ANOTETXT}{$author.name$@CORRESP}{Corresponding author. \href{mailto:$author.email$}{\nolinkurl{$author.email$}}}
\makeatletter\createanotelblbycode{$author.name$@CORRESP}\makeatother
$endif$
$for(author.footnote)$
\createanotelblbycode{$author.footnote$}
$endfor$
\author[%
$for(author.affiliation)$
\addrlblbycode{$author.affiliation$}%
$sep$,%
$endfor$
$if(author.corresponding_author)$
$if(author.affiliation)$,$endif$%
\makeatletter\anotelblbycode{$author.name$@CORRESP}\makeatother
$endif$
$if(author.footnote)$
$if(author.corresponding_author)$,$elseif(author.affiliation)$,$endif$%
$for(author.footnote)$
$$\anotelblbycode{$author.footnote$}$$%
$sep$,%
$endfor$
$endif$
]{$author.name$}
$for(author.affiliation)$
\addrbycode{$author.affiliation$}
$endfor$
$endfor$
$else$ % Use footnotes for affiliations %%%%%%%%%%%%%
% Get rid of redefinition of \@makefnmark in \maketitle
% Gets rid of spacing issues
\usepackage{etoolbox}
\makeatletter
\patchcmd\maketitle{\def\@makefnmark{\rlap{\@textsuperscript{\normalfont\@thefnmark}}}}{}{}{}
\makeatother
% Hook into the \@thanks command
\makeatletter
\def\thanksAddr#1{% <--- These %'s are necessary for spacing
\footnotemarkAddr\protected@xdef\@thanks{\@thanks%
\protect\footnotetextAddr[\the \c@footnoteAddr]{#1}}%
}
\def\thanksANote#1{%
\footnotemarkANote%
\protected@xdef\@thanks{\@thanks%
\protect\footnotetextANote[\the \c@footnoteANote]{#1}}%
}
\newcommand*\thanksAddrbycode[1]{%
\ifcounter{ADDR@#1}
{\footnotemarkAddr[\value{ADDR@#1}]}
{\newcounter{ADDR@#1}%
\thanksAddr{\MyRef{ADDRTXT}{#1}}%
\setcounter{ADDR@#1}{\value{footnoteAddr}}} % Note sure this will work
}
\newcommand*\thanksANotebycode[1]{%
\ifcounter{ANOTE@#1}
{\footnotemarkANote[\value{ANOTE@#1}]}
{\newcounter{ANOTE@#1}%
\thanksANote{\MyRef{ANOTETXT}{#1}}%
\setcounter{ANOTE@#1}{\value{footnoteANote}}} % Note sure this will work
}
\makeatother
\newcommand*\authsep{, }
\newcommand*\thankssep{$$^{,}$$}
$if(author)$
\author{%
$for(author)$
$author.name$%
$for(author.affiliation)$
\thanksAddrbycode{$author.affiliation$}%
$sep$\thankssep%
$endfor$
$if(author.corresponding_author)$
$if(author.affiliation)$\thankssep$endif$% extra comma
\thanksANote{Corresponding author. \href{mailto:$author.email$}{\nolinkurl{$author.email$}}} % space here seems necessary to get spacing right
$endif$
$if(author.footnote)$$if(author.affiliation)$\thankssep$elseif(author.corresponding_author)$\thankssep$endif$$endif$% extra comma
$for(author.footnote)$
\thanksANotebycode{$author.footnote$}%
$sep$\thankssep%
$endfor$
$sep$\authsep%
$endfor$
}
$endif$%endif(author)
$endif$%endif(authblk)