summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/workaddress/workaddress.dtx
blob: d3fa2fb6b37c7e0383bfde7ffaf342afdd8f171d (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
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
% \iffalse meta-comment
% An Infrastructure for managing addresses and affiliations in LaTeX
% Copyright (c) 2011 Michael Kohlhase, all rights reserved
%               this file is released under the
%               LaTeX Project Public License (LPPL)
% The original of this file is in the public repository at 
% http://github.com/KWARC/sTeX/
% \fi
% 
% \iffalse
%<*package>
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{workaddress}[2016/04/07 v0.4 WorkAddress]
%</package>
%<*driver>
\documentclass{ltxdoc}
\usepackage{workaddress,sref,url,array,float}
\usepackage[show]{ed}
\usepackage[hyperref=auto,style=alphabetic]{biblatex}
\addbibresource{kwarcpubs.bib}
\addbibresource{extpubs.bib}
\addbibresource{kwarccrossrefs.bib}
\addbibresource{extcrossrefs.bib}
\usepackage{ctangit}
\usepackage{hyperref}
\usepackage{stex-logo}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\WAperson[id=jdoe,affiliation=dfki,department=skss,
           url=http://dfki.de/jdoe]
          {John Doe}
\WAperson[id=miko,affiliation=jacu,department=case,
           url=http://kwarc.info/kohlhase]
          {Michael Kohlhase}
\WAinstitution[id=case,acronym=CASE,
                url=http://jacobs-university.de/ses/case,partof=jacu]
               {Center for Advanced Systems Engineering}
\WAinstitution[id=jacu,url=http://jacobs-university.de,shortname=Jacobs University,acronym=JU]
               {Jacobs University Bremen}
\WAinstitution[id=skss,url=http://dfki.de/sks,partof=dfki,acronym=SKS,]
               {Safe and Secure Cognitive Systems}
\WAinstitution[id=dfki,url=http://dfki.de,acronym=DFKI,shortname=DFKI]
               {German Research Center for Artificial Intelligence}
\def\tracissue#1{\cite{sTeX:online}, \hyperlink{http://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
\begin{document}\DocInput{workaddress.dtx}\end{document}
%</driver>
% \fi
%
%\CheckSum{334}
%
% \changes{v0.4}{2011/11/04}{Extracting from dcm.sty}
% \changes{v0.4}{2012/01/18}{new functionality for logos}
% 
% \GetFileInfo{workaddress.sty}
% 
% \MakeShortVerb{\|}
% \def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}}
% \def\latexml{\scsys{LaTeXML}}
%
%   \title{{\texttt{workaddress.sty}}: An Infrastructure for managing Addresses and
%   Affiliations in {\LaTeX}\thanks{Version {\fileversion} (last revised {\filedate})}}
%   \author{\WAauthorblock[aff,url]{miko,jdoe}}
%   \maketitle
%   \begin{abstract}The |workaddress| package allows manage addresses and Affiliations in
%     a bib\TeX-like manner.\ednote{continue}
%   \end{abstract}
%
% \setcounter{tocdepth}{2}\tableofcontents\newpage
%
% \section{Introduction}\label{sec:intro}
%
% The |workaddress| package allows manage Addresses and affiliations of persons in a
% bib\TeX-like manner.\ednote{continue}
% 
% \section{The User Interface}\label{sec:user}
% 
% \subsection{Package Options}\label{sec:user.options}
% 
% The |workaddress| package takes a single option: \DescribeMacro{showmeta}|showmeta|. If
% this is set, then the metadata keys are shown (see~\cite{Kohlhase:metakeys:ctan} for
% details and customization options).
%
% \subsection{Database Entries for Persons}
% 
% The |workaddress| package recognizes that from a metadata perspective, persons are complex
% entities. In particular, specifying metadata is a tedious and repetitive task that leads
% to embarrassing errors. Therefore the |workaddress| package takes a hint from bibTeX and allows
% to specify personal metadata in a database and use it by a database key.
% \begin{exfig}[ht]
% \begin{verbatim}
% \WAperson[id=jdoe,affiliation=dfki,department=skss,
%            url=http://dfki.de/jdoe]
%           {John Doe}
% \WAperson[id=miko,affiliation=jacu,department=case,
%            url=http://kwarc.info/kohlhase]
%           {Michael Kohlhase}
% \end{verbatim}
% \caption{A small database of Persons}
% \label{fig:persons}
% \end{exfig}
% The \DescribeMacro{\WAperson}|\WAperson| macro allows to specify personal metadata\ednote{This
% should be synchronized with the FOAF specification~\cite{FOAF:spec}} with the following
% keys: 
% \begin{center}
% \begin{tabular}{|l|l|l|}\hline
% key & value & comment\\\hline\hline
% id & string & identifier of this person\\\hline
% birthdate & date & birthdate \\\hline
% email & & the primary e-mail address\\\hline
% url & URI & primary home page \\\hline
% affiliation & Inst. identifier & the primary professional affiliation\\\hline
% personaltitle & string & the personal title e.g. {\texttt{King}}\\\hline
% academictitle & string & the academic title e.g. {\texttt{Prof. Dr.}}\\\hline
% department & Inst. identifier & the department specified in the work address\\\hline
% workaddress & long string & the work address \\\hline
% privaddress & long string & the private address \\\hline
% worktel & string & work telephone number \\\hline
% privtel & string & private telephone number\\\hline
% workfax & string & work fax number \\\hline
% privfax & string & private fax number \\\hline
% worktelfax & string & if the phone and fax share a prefix, give this as well \\\hline
% privtelfax & string & dito\\\hline
% \end{tabular}
% \end{center}
% In Figure~\ref{fig:persons} we have specified (minimal) metadata for the authors of the
% |workaddress| package. The metadata can be accessed by specifying the identifiers (given by the
% |id| key) in the |workaddress| macros defined below, see for instance the |\WAcreators| macro
% in Figure~\ref{fig:workaddressblock}, which leads to the title block of this note.
% 
% Like in bibTeX~\cite{Patashnik:b88}, it is a good idea to collect the metadata in a separate
% file that is input in the document. In practice it may be possible to generate these
% files from conventional address databases.
% 
% \subsection{Institutions}
% 
% Institutions are treated analogously to persons.
% \begin{exfig}[ht]
% \begin{verbatim}
% \WAinstitution[id=case,partof=jacu,acronym=CASE,
%                 url=http://jacobs-university.de/ses/case]
%                {Center for Advanced Systems Engineering}
% \WAinstitution[id=jacu,url=http://jacobs-university.de]
%                {Jacobs University Bremen}
% \WAinstitution[id=skss,partof=dfki,url=http://dfki.de/sks,acronym=SKS]
%                {Safe and Secure Cognitive Systems}
% \WAinstitution[id=dfki,url=http://dfki.de,shortname=DFKI,acronym=DFKI]
%                {German Research Center for Artificial Intelligence}
% \end{verbatim}
% \caption{A small Database of Institutions and their Parts}
% \label{fig:institutions}
% \end{exfig}
% The \DescribeMacro{\WAinstitution}|\WAinstitution| macro allows to specify personal
% metadata\ednote{This should be synchronized with the FOAF
% specification~\cite{FOAF:spec}} with the following keys:
% \begin{center}
% \begin{tabular}{|l|l|l|}\hline
% key & value & comment\\\hline\hline
% id & string & identifier of this person\\\hline
% url & URI & primary home page \\\hline
% partof & Inst. identifier & parent institution\\\hline
% \end{tabular}
% \end{center}
% 
% \subsection{Applications}\label{sec:user.appl}
% 
% The data from the address database can be used in various ways. For instance, the
% \DescribeMacro{\WAauthorblock}|\WAauthorblock| macro creates a block of users and their
% affiliations. In the context of the database from Figures~\ref{fig:persons}
% and~\ref{fig:institutions}, |\WAauthorblock{miko,jdoe}| creates
% \begin{center}\WAauthorblock{miko,jdoe}\end{center}
%
% \DescribeMacro{\wa@institution@logo}|\wa@institution@logo| creates the logo of an
% institution from the database, and (if that is not there create a box and a message
% instead.)
% 
% \section{Limitations}\label{sec:limitations}
% 
% In this section we document known limitations. If you want to help alleviate them,
% please feel free to contact the package author. Some of them are currently discussed in
% the \sTeX GitHub repository~\cite{sTeX:github:on}. 
% \begin{compactenum}
% \item none reported yet
% \end{compactenum}
% 
% \StopEventually{\printbibliography}
% 
% \section{The Implementation}\label{sec:impl}
%
% \subsection{Package Options}\label{sec:impl.options}
% The first step is to declare (a few) package options that handle whether certain
% information is printed or not. They all come with their own conditionals that are set by
% the options.
%
%    \begin{macrocode}
%<*package>
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{sref}}
\ProcessOptions
%    \end{macrocode}
%
% The first measure is to ensure that the |KeyVal| package is loaded (in the right
% version). For {\latexml} we also initialize the package inclusions. 
%    \begin{macrocode}
\RequirePackage{sref}
%    \end{macrocode}
%
% \subsection{Persons}
% 
% To implement the |\WAperson| macro, we need to implement its keywords.
%
%    \begin{macrocode}
\addmetakey*{wa@person}{id}
\addmetakey*{wa@person}{birthdate}
\addmetakey*{wa@person}{email}
\addmetakey*{wa@person}{url}
\addmetakey*{wa@person}{affiliation}
\addmetakey*{wa@person}{personaltitle}
\addmetakey*{wa@person}{academictitle}
\addmetakey*{wa@person}{department}
\addmetakey*{wa@person}{workaddress}
\addmetakey*{wa@person}{privaddress}
\addmetakey*{wa@person}{worktel}
\addmetakey*{wa@person}{privtel}
\addmetakey*{wa@person}{workfax}
\addmetakey*{wa@person}{privfax}
\addmetakey*{wa@person}{worktelfax}
\addmetakey*{wa@person}{privtelfax}
%    \end{macrocode}
% 
% \begin{macro}{\wa@def}
%   The next macro is an auxiliary one that puts the value into an appropriate token
%   register. 
%    \begin{macrocode}
\def\wa@def#1#2#3#4{\expandafter\xdef\csname wa@#1@#2@#3\endcsname{#4}}
%    \end{macrocode}
% \end{macro}
% 
% 
% \begin{macro}{\wa@ref@test}
%   This macro tests whether the information specified is defined, and gives an error
%   message else.
%    \begin{macrocode}
\def\wa@ref@test#1#2#3{%
  \@ifundefined{wa@#1@#2@#3}{%
    \PackageError{workaddress}{reference to undefined #3 of #1 #2}%
    {you must define a #1 with #2=#3\MessageBreak% 
     via the macro \protect\WA#1, before you can use it!}
  }{}%
}%
%    \end{macrocode}
% \end{macro}
%
% With this, referencing is simple
%
% \begin{macro}{\wa@ref}
%    \begin{macrocode}
\def\wa@ref#1#2#3{%
  \wa@ref@test{#1}{#2}{#3}%
  \csname wa@#1@#2@#3\endcsname%
}%
%    \end{macrocode}
% \end{macro}
% 
% With this we can define the |\WAperson| macro, it just clears the keys, sets them
% again, and stores them in token registers. If course only if a |id| attribute is given,
% else we raise an error.
% 
% \begin{macro}{WAperson}
%    \begin{macrocode}
\let\wa@persons=\relax
\newcommand\WAperson[2][]{%
  \metasetkeys{wa@person}{#1}%
  \ifx\wa@person@id\@empty%
    \@latex@warning{key 'id' undefined in WAperson}%
  \else%
    \wa@def{person}\wa@person@id{id}{\wa@person@id}% redundant, but useful for checking
    \wa@def{person}\wa@person@id{name}{#2}
    \wa@def{person}\wa@person@id{email}{\wa@person@email}
    \wa@def{person}\wa@person@id{birthdate}{\wa@person@birthdate}
    \wa@def{person}\wa@person@id{url}{\wa@person@url}
    \wa@def{person}\wa@person@id{affiliation}{\wa@person@affiliation}
    \wa@def{person}\wa@person@id{workaddress}{\wa@person@workaddress}
    \wa@def{person}\wa@person@id{privaddress}{\wa@person@privaddress}
    \wa@def{person}\wa@person@id{personaltitle}{\wa@person@personaltitle}
    \wa@def{person}\wa@person@id{academictitle}{\wa@person@academictitle}
    \wa@def{person}\wa@person@id{department}{\wa@person@department}
    \wa@def{person}\wa@person@id{workaddress}{\wa@person@workaddress}
    \wa@def{person}\wa@person@id{privaddress}{\wa@person@privaddress}
    \wa@def{person}\wa@person@id{worktel}{\wa@person@worktel}
    \wa@def{person}\wa@person@id{privtel}{\wa@person@privtel}
    \wa@def{person}\wa@person@id{workfax}{\wa@person@workfax}
    \wa@def{person}\wa@person@id{privfax}{\wa@person@privfax}
    \wa@def{person}\wa@person@id{worktelfax}{\wa@person@worktelfax}
    \wa@def{person}\wa@person@id{privtelfax}{\wa@person@privtelfax}
    \@ifundefined{wa@persons}{%
      \xdef\wa@persons{\wa@person@id}%
    }{%
      \xdef\wa@persons{\wa@persons,\wa@person@id}%
    }%
  \fi%
}%
\newcommand\DCMperson[2][]{%
  \WAperson[#1]{#2}%
  \PackageWarning{workaddress}{\protect\DCMperson\space is deprecated, use \protect\WAperson\space instead}
}%
%    \end{macrocode}
% \end{macro}
%
% \subsection{Institutions}
% 
% To implement the |\WAinstitution| macro, we need to implement its keywords first.
%
%    \begin{macrocode}
\addmetakey*{wa@institution}{id}
\addmetakey*{wa@institution}{shortname}
\addmetakey*{wa@institution}{acronym}
\addmetakey*{wa@institution}{url}
\addmetakey*{wa@institution}{partof}
\addmetakey*{wa@institution}{countryshort}
\addmetakey*{wa@institution}{logo}
\addmetakey*{wa@institution}{streetaddress}
\addmetakey*{wa@institution}{townzip}
\addmetakey*{wa@institution}{type}
\addmetakey*{wa@institution}{country}
%    \end{macrocode}
% and we proceed as for |\WAperson|, 
%    \begin{macrocode}
\let\wa@institutions=\relax
%    \end{macrocode}
%
% \begin{macro}{WAinstitution}
%    \begin{macrocode}
\newcommand\WAinstitution[2][]{%
  \metasetkeys{wa@institution}{#1}%
  \ifx\wa@institution@id\@empty%
    \@latex@warning{key 'id' undefined in WAinstitution}%
  \else%
    \wa@def{institution}\wa@institution@id{id}{\wa@institution@id}% redundant, but useful for checking
    \wa@def{institution}\wa@institution@id{name}{#2}
    \wa@def{institution}\wa@institution@id{shortname}{\wa@institution@shortname}
    \wa@def{institution}\wa@institution@id{acronym}{\wa@institution@acronym}
    \wa@def{institution}\wa@institution@id{url}{\wa@institution@url}
    \wa@def{institution}\wa@institution@id{partof}{\wa@institution@partof}
    \wa@def{institution}\wa@institution@id{countryshort}{\wa@institution@countryshort}
    \wa@def{institution}\wa@institution@id{logo}{\wa@institution@logo}
    \wa@def{institution}\wa@institution@id{townzip}{\wa@institution@townzip}
    \wa@def{institution}\wa@institution@id{streetaddress}{\wa@institution@streetaddress}
    \wa@def{institution}\wa@institution@id{country}{\wa@institution@country}
    \wa@def{institution}\wa@institution@id{type}{\wa@institution@type}
    \@ifundefined{wa@institutions}{%
      \xdef\wa@institutions{\wa@institution@id}%
    }{%
      \xdef\wa@institutions{\wa@institutions,\wa@institution@id}%
    }%
  \fi%
}%
\newcommand\DCMinstitution[2][]{%
  \WAinstitution[#1]{#2}%
  \PackageWarning{workaddress}{\protect\DCMinstitution\space is deprecated, use \protect\WAinstitution\space instead}%
}%
%    \end{macrocode}
% \end{macro}
% 
%\subsection{Applications}\label{sec:impl.appl}
%
% \begin{macro}{\WAauthorblock}
%   This internal macro builds an author block from a list of |\WAperson| labels in
%   |\wa@creators|.
%    \begin{macrocode}
\addmetakey[false]{WAauthorblock}{dept}[true]
\addmetakey[false]{WAauthorblock}{aff}[true]
\addmetakey[false]{WAauthorblock}{url}[true]
\def\@true{true}
\newcounter{authors}
\newcommand\WAauthorblock[2][]{%
  \metasetkeys{WAauthorblock}{#1}
  {\let\tabularnewline\relax
   \@for\@I:=#2\do{\stepcounter{authors}}
   \def\@authors{}%
   \def\@affs{}%
   \def\@depts{}%
   \def\@urls{}%
   \@for\@I:=#2\do{%
     \xdef\@authors{\@authors&\wa@ref{person}\@I{name}}
     \xdef\@@dept{\wa@ref{person}\@I{department}}
     \xdef\@shortname{\csname wa@institution@\@@dept @shortname\endcsname}
     \xdef\@dept{\ifx\@shortname\@empty\wa@ref{institution}\@@dept{name}\else\@shortname\fi}
     \xdef\@depts{\@depts&\@dept}
     \xdef\@@aff{\wa@ref{person}\@I{affiliation}}
     \xdef\@shortname{\csname wa@institution@\@@aff @shortname\endcsname}
     \xdef\@aff{\ifx\@shortname\@empty\wa@ref{institution}\@@aff{name}\else\@shortname\fi}
     \xdef\@affs{\@affs&\@aff}
     \xdef\@urls{\@urls&\wa@ref{person}\@I{url}}
   }%
   \message{\theauthors authors: \@authors}%
  }%
  \begin{tabular}[t]{l*{\theauthors}{c}}
    \@authors\\
    \ifx\WAauthorblock@dept\@true\@depts\\\fi
    \ifx\WAauthorblock@aff\@true\@affs\\\fi
    \ifx\WAauthorblock@url\@true\@urls\\\fi
  \end{tabular}
}%
%    \begin{macrocode}
% \end{macro}
%
% \begin{macro}{\wapname}
%    \begin{macrocode}
\newcommand\wapname[1]{\wa@ref{person}{#1}{name}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\waptname}
%    \begin{macrocode}
\newcommand\waptname[1]{\wa@ref{person}{#1}{personaltitle} \wa@ref{person}{#1}{name}}
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\wa@institution@logo}
%    \begin{macrocode}
\newcommand\wa@institution@logo[2][]{%
  \IfFileExists{\wa@ref{institution}{#2}{logo}}{%
    \includegraphics{\wa@ref{institution}{#2}{logo}}%
  }{%
    \fbox{#2 logo}\message{still need logo for #2}%
  }%
}%
%</package>
%    \end{macrocode}
% \end{macro}
%
% \Finale
\endinput
% \iffalse
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi

% LocalWords:  RequirePackage birthdate personaltitle academictitle workaddress
% LocalWords:  privaddress worktel privtel workfax privfax worktelfax noDelim
% LocalWords:  privtelfax getKeyValue valuelist ToString getValue affill STDERR
% LocalWords:  ExportMetadata AssignValue WAperson DefConstructor afterDigest
% LocalWords:  getArg setValue FishOutMetadata keyvals foreach idlist tabline
% LocalWords:  LookupValue insertElement atabline bitabline shorttitle nc args
% LocalWords:  sharealike noderivativeworks DefMacro authorblock subsubsection
% LocalWords:  contribs OptionalKeyVals omgroup omdoc srcref xml RawTeX partof
% LocalWords:  openElement iffalse kohlhase Thu scsys sc sc latexml 
% LocalWords:  maketitle WAtitle texttt fileversion WAcreators miko jdoe impl
% LocalWords:  WAabstract setcounter tocdepth tableofcontents newpage dmt03
% LocalWords:  WAsection ednote WAsubsection exfig hline dcmblock Patashnik
% LocalWords:  DescribeEnv WAcontributors WAshorttitle WAshorttitle WAdate
% LocalWords:  WAsubject WAsubject WAdescription WAdescription WApublisher
% LocalWords:  WApublisher WAdate WAtype WAtype WAidentifier WAidentifier
% LocalWords:  WAsource WAsource WAlanguage WAlanguage WArelation ctancite
% LocalWords:  WArelation WArights WArights WAlicense WAlicense titlepage
% LocalWords:  WAlicensenotice WAlicensenotice WAcopyrightnotice titlepage
% LocalWords:  WAcopyrightnotice WAcclicense WAcclicense user.blockstyles
% LocalWords:  WAchapter WAchatper WAsubsubsection WAsubsubsection ltxml
% LocalWords:  user.conig makeatletter printbibliography expandafter showmeta
% LocalWords:  xdef csname endcsname newcommand ifx ifundefined affs showmeta
% LocalWords:  Semiverbatim whatsit newenvironment mtabline providecommand vfil
% LocalWords:  WAsubtitle cclicense defdcm impl.blockstyles newcounter vskip
% LocalWords:  stepcounter tabularnewline theauthors lineskip textbf noindent
% LocalWords:  omd omd srefaddidkey thechapter autoclose thesection ifnum ifnum
% LocalWords:  thesubsection thesubsubsection WAparagraph ISOtimestamp doctex
% LocalWords:  WAinstitution WAinstitution compactenum textsf langle textsf
% LocalWords:  langle metakeys addmetakey metasetkeys countryshort townzip aff
% LocalWords:  streetaddress depts