summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/dccpaper/dccpaper-base.tex
blob: eeefb6c6f88f2331a4703added3ff56e91de07d4 (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
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
%%
%% This is file `dccpaper-base.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% dccpaper.dtx  (with options: `base')
%% 
%% ----------------------------------------------------------------
%% The dccpaper bundle: Classes for submissions to IJDC and IDCC
%% Author:  Alex Ball
%% E-mail:  a.ball@ukoln.ac.uk
%% License: Released under the LaTeX Project Public License v1.3c or later
%% See:     http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
%% 
\def\Version{2014/08/07 v1.3}
\ProvidesFile{dccpaper-base.tex}
    [\Version\space Common class code for IJDC and IDCC papers.]
%
% The \textsf{dccpaper} classes are deliberately very similar. This file
% contains the common code. All the classes are based on the \textsf{article}
% class, and use A4 paper.
%
\LoadClass[a4paper,12pt,twoside]{article}

%
% We use British English orthography.
%
\RequirePackage[british]{babel}
%
% The macro patching commands from \textsf{etoolbox} come in useful for handling
% author and date information, and also for compatibility with \textsf{apacite}.
%
\RequirePackage{etoolbox}
%
% The \textsf{dccpaper} classes use Times as the main text font. We prefer
% \textsf{newtx} as it provides support for mathematics, but the standard
% \textsf{times} package will do. In case they are needed, we also provide
% Helvetica for the sans serif font and Computer Modern Teletype for the
% monospaced.
%
\RequirePackage[T1]{fontenc}
\IfFileExists{newtxtext.sty}%
  {\RequirePackage{newtxtext,newtxmath}}%
  {\RequirePackage{times}}
\RequirePackage[scaled=0.92]{helvet}
\renewcommand{\ttdefault}{cmtt}
%
% We will need support for included graphics and colour. The structural elements
% are a medium turquoise, while the links are slightly darker to make them
% easier to read on screen.
%
\RequirePackage{graphicx}
\IfFileExists{xcolor.sty}%
  {\RequirePackage{xcolor}}%
  {\RequirePackage{color}}
\definecolor[named]{struct}{rgb}{0,0.5,0.5}
\definecolor[named]{links}{rgb}{0,0.4,0.4}
%
% We will calculate some lengths later.
%
\RequirePackage{calc}

%
% Ragged right text is easier to read on screen, but fully justified text looks
% better. The |\raggedyright| layout from Peter Wilson's \textsf{memoir} class
% (2005/09/25 v1.618) is an excellent compromise. The code below replicates it.
%
% First we save the original definitions of |\\| and |\parindent| as
% |\OrigLineBreak| and |\RaggedParindent| respectively.
%
\let\OrigLineBreak\\
\newdimen\RaggedParindent
\setlength{\RaggedParindent}{\parindent}

%
% The |\raggedyright| layout more or less lays text out as with full
% justification, but then lets the shorter lines relax a bit from the right
% margin. It is the default for DCC papers.
%
\newcommand{\raggedyright}[1][2em]{%
  \let\\\@centercr\@rightskip \z@ \@plus #1\relax
  \rightskip\@rightskip
  \leftskip\z@skip
  \parindent\RaggedParindent}
\AtBeginDocument{\raggedyright}

%
% The |\flushleftright| layout restores full justification, in case it is
% needed.
%
\newcommand*{\flushleftright}{%
  \let\\\OrigLineBreak
  \leftskip\z@skip
  \rightskip\leftskip
  \parfillskip\@flushglue
  \everypar{}}

%
% The classes have some special metadata requirements. We start with the author
% information.
%
% The macro |\thecorrespondence| is used in the title page footer for the name,
% postal address and email address of the corresponding author.
%
\def\thecorrespondence{}
\newcommand*{\correspondence}[1]{\def\thecorrespondence{#1}}
%
% The handling of authors here is inspired by Patrick W Daly's \textsf{authblk},
% (2001/02/27 1.3), and defines the familiar user commands. Authors are
% presented in blocks, one affiliation but perhaps several authors per block.
%
% We make the presentation of the author information configurable (just in case)
% with some hooks and lengths:
% \begin{itemize}
% \item |\Authfont| is the font used for author names;
% \item |\Affilfont| is the font used for affiliations;
% \item |\affilsep| is the line spacing between author names and affiliations;
% \item |\authblksep| is the line spacing between author name/affiliation
%       blocks.
% \end{itemize}
%
\newcommand*{\Authfont}{\normalfont}
\newcommand*{\Affilfont}{\normalfont\small}
\newlength{\affilsep}\setlength{\affilsep}{0pt}
\newlength{\authblksep}\setlength{\authblksep}{1.5\baselineskip}
%
% The |\AuthorBlock| command will be used to collect all the author information.
%
\newcommand{\AuthorBlock}{}
%
% The |\MainAuthor| command collects abbreviated author information for use in
% the headers.
%
\newcommand{\MainAuthor}{}
%
% The |\dccp@author| command, meanwhile, collects a full list of authors for the
% PDF metatdata.
%
\newcommand{\dccp@author}{}
%
% We define counters for
% \begin{itemize}
% \item the total number of authors defined;
% \item the number of authors in the current block;
% \item the number of blocks defined.
% \end{itemize}
%
\newcounter{authors}
\newcounter{authorsinblock}
\newcounter{block}
%
% The |block| counter will increase once in the preamble, and again when the
% information is typeset, so we need to reset it at the beginning of the
% document.
%
\AtBeginDocument{\setcounter{block}{0}}
%
% The new definition of the author command starts here.
%
\renewcommand{\author}[1]{%
%
% If this is the first or second |\author| command, we add the name to our
% abbreviated list of authors. Otherwise, we replace the name of the second
% and subsequent authors with `et al.' in that list.
%
% At the same time, we use a simpler technique to populate |\dccp@author|.
%
  \ifnum\theauthors=0
    \def\dccp@author{#1}%
    \def\MainAuthor{#1}%
  \else
    \appto\dccp@author{, #1}%
    \ifnum\theauthors=1%
      \def\OtherMainAuthors{ and #1}%
      \appto\MainAuthor{\OtherMainAuthors}%
    \else
      \ifnum\theauthors=2%
        \def\OtherMainAuthors{ et al.}%
      \fi
    \fi
  \fi
  \stepcounter{authors}%
%
% Each block has its author names collected in a macro like |\blocki@auth|,
% and its affiliation collected in a macro like |\blocki@affil| (the `i' is a
% serial number).
%
% If this is the first author in a block, we need to create the block and add it
% to |\AuthorBlock|; second and subsequent blocks are preceded by a |\quad| of
% space.
%
  \ifnum\theauthorsinblock=0%
    \stepcounter{block}%
    \expandafter\def\csname block\roman{block}@auth\endcsname{#1}%
    \ifnum\theblock>1\appto\AuthorBlock{\quad}\fi
    \appto\AuthorBlock{%
      \stepcounter{block}%
      \begin{minipage}[t]{0.45\textwidth}\centering
      \csname block\roman{block}@auth\endcsname
      \ifx\undefined\csname block\roman{block}@affil\endcsname
      \else
        \\[\affilsep]\csname block\roman{block}@affil\endcsname
      \fi
      \end{minipage}%
      \rule{0pt}{2\baselineskip}%
      }
  \else
%
% Otherwise we just add the name to the right |\blocki@auth|-style macro.
%
    \csappto{block\roman{block}@auth}{, #1}%
  \fi
  \stepcounter{authorsinblock}%
}
%
% The |\affil| command adds an affiliation to the current block and closes it by
% resetting the |authorsinblock| counter.
%
\newcommand{\affil}[1]{%
  \expandafter\def\csname block\roman{block}@affil\endcsname{\Affilfont#1}%
  \setcounter{authorsinblock}{0}%
}

%
% The |\HeadTitle| collects the abbreviated title for use in the headers.
%
\newcommand*{\HeadTitle}{}
%
% We wrap the normal |\title| command with code to populate |\HeadTitle| with
% the optional argument if provided, or the mandatory one otherwise. We also
% provide a persistent |\thetitle| macro, stripped of any |\thanks|.
%
\let\ProperTitle=\title
\renewcommand{\title}[2][\empty]{
  \ifx\empty #1%
    \renewcommand*{\HeadTitle}{#2}%
  \else
    \renewcommand*{\HeadTitle}{#1}%
  \fi%
  \begingroup\let\footnote\@gobble
  \ProperTitle{#2}%
  \begingroup
    \renewcommand{\thanks}[1]{}
    \protected@xdef\thetitle{#2}
  \endgroup\endgroup
}

%
% We make |\thedate| persistent, borrowing the technique used in Peter Wilson's
% \textsf{memoir} class (2005/09/25 v1.618).
%
\pretocmd{\date}{\begingroup\let\footnote\@gobble}{}{}%
\apptocmd{\date}{%
  \begingroup
    \renewcommand{\thanks}[1]{}
    \protected@xdef\thedate{#1}
  \endgroup\endgroup%
}{}{}
%
% We ensure |\thedate| is defined using a dummy date.
%
\date{20xx}

%
% IJDC articles have extra bibliographic information:
% \begin{itemize}
% \item |\volume| sets the volume number, |\thevolume|;
% \item |\issue| sets the issue number, |\theissue|;
% \item |\subno| sets the submission number, |\thesubno|.
% \end{itemize}
%
% These numbers are used to build the DOI, |\thedoi|.
%
\newcommand*{\thevolume}{0}
\newcommand*{\volume}[1]{\renewcommand*{\thevolume}{#1}}
\newcommand*{\theissue}{0}
\newcommand*{\issue}[1]{\renewcommand*{\theissue}{#1}}
\newcommand*{\thesubno}{0}
\newcommand*{\subno}[1]{\renewcommand*{\thesubno}{#1}}
\newcommand*{\thedoi}{10.2218/ijdc.v\thevolume i\theissue .\thesubno}
%
% They also display the page range. The following code was borrowed from Peter
% Wilson's \textsf{memoir} class (2005/09/25 v1.618). It defines a counter
% |lastpage| which, on the second run, will contain the number of the last page.
%
\newcounter{lastpage}
\setcounter{lastpage}{0}
\newcommand{\dol@stpage}{%
  \if@filesw
    \addtocounter{page}{-1}%
    \immediate\write\@auxout%
      {\string\setcounter{lastpage}{\the\c@page}}%
    \stepcounter{page}%
  \fi
}
\AtBeginDocument{\AtEndDocument{\clearpage\dol@stpage}}

%
% DCC papers display some important dates. We collect these in |\dccp@dates|,
% initially setting the value to something sensible for papers in draft.
%
\def\dccp@dates{\emph{Draft from} \today}
%
% Several types of date can be added:
% \begin{itemize}
% \item |\submitted| for when the authors submitted the paper (intended for
%       IDCC papers).
% \item |\received| for when the paper was received by the editorial board
%       (intended for IJDC papers).
% \item |\revised| for when the most recent version was received by the
%       editorial board.
% \item |\accepted| for when the paper was accepted by the editorial board.
% \end{itemize}
%
\newcommand*{\submitted}[1]{%
  \def\dccp@dates{\emph{Submitted} #1}}
\newcommand*{\received}[1]{%
  \def\dccp@dates{\emph{Received} #1}}
\newcommand*{\revised}[1]{%
  \appto\dccp@dates{%
    \space\space\space\textbar\space\space\space
    \emph{Revision received} #1}%
  }
\newcommand*{\accepted}[1]{%
  \appto\dccp@dates{%
    \space\space\space\textbar\space\space\space
    \emph{Accepted} #1}%
  }
%
% IJDC papers need to say if they had a previous life as a conference paper.
% This statement goes in |\dccp@conf|, which is initially empty. The user
% command for setting this text is |\conference|.
%
\let\dccp@conf=\empty
\newcommand*{\conference}[1]{%
  \renewcommand*{\dccp@conf}{An earlier version of this paper was presented at #1.}%
}

%
% The macro |\FixTextHeight| will be useful when switching from the first page
% geometry to the regular geometry for the rest of the paper. It is based on
% code from  Hideo Umeki's \textsf{geometry} package (2002/07/08 v3.2).
%
\newcommand{\FixTextHeight}{%
  \setlength\@tempdima{\textheight}%
  \addtolength\@tempdima{-\topskip}%
  \@tempcnta\@tempdima
  \@tempcntb\baselineskip
  \divide\@tempcnta\@tempcntb
  \setlength\@tempdimb{\baselineskip}%
  \multiply\@tempdimb\@tempcnta
  \advance\@tempdima-\@tempdimb
  \global\advance\footskip\@tempdima
  \multiply\@tempdima\tw@
  \ifdim\@tempdima>\baselineskip
    \addtolength\@tempdimb{\baselineskip}%
    \global\advance\footskip-\baselineskip
  \fi
  \addtolength\@tempdimb{\topskip}%
  \global\textheight\@tempdimb
}

%
% The width of the textblock (on all pages) is 150mm, which on A4 paper implies
% margins of 30mm each. (Making both horizontal margins the same in a two-sided
% context makes the paper more pleasant to read on screen).
%
\setlength{\textwidth}{150mm}
\setlength{\oddsidemargin}{30mm - \hoffset - 1in}
\setlength{\evensidemargin}{30mm - \hoffset - 1in}
%
% It is rare to have marginal notes, but in case we ever do, we centre them in
% the margin.
%
\setlength{\marginparwidth}{30mm - 2\marginparsep}
%
% We also want a distance of 15mm from the top of the page to the top of the
% header, and two blank lines between the bottom of the header and the top of
% the textblock.
%
\setlength{\topmargin}{15mm - \voffset - 1in}
\setlength{\headsep}{2\baselineskip}

%
% IJDC editorials have slightly different headers and footers. This requires
% testing for |\dccp@editorial| if it exists. In case it doesn't, we provide it.
%
\providecommand{\dccp@editorial}{Editorial}
%
% The height of the footer can vary a lot. To keep it a fixed distance from the
% bottom of the page rather than the top, we need to vary the |\textheight|
% accordingly. This means we need to measure the height of the footer. (The
% header is more predictable but we may as well measure it while we are at it).
%
% Here we define the header and footer of the title page (i.e.\ the
% \textsf{title} page style), making sure we save them to auxiliary macros
% |\TitleHead| and |\TitleFoot| so we can measure them.
%
\def\ps@title{%
  \def\@oddhead{%
    \begin{minipage}{\textwidth}%
      \centering
      \LARGE\bfseries\color{struct}%
      \ifx\dccp@type\dccp@editorial
        \dccp@publ@long
      \else
        \dccp@publ@short\space\space\textbar\space\space\emph{\dccp@type}%
      \fi
      \par
    \end{minipage}%
  }%
  \let\@evenhead=\@oddhead
  \let\TitleHead=\@oddhead
  \def\@oddfoot{%
    \begin{minipage}[b]{\textwidth}%
      \fontsize{9pt}{11pt}\selectfont
      \ifx\dccp@type\dccp@editorial
      \else
        {\centering\dccp@dates\par}
        \bigskip
        Correspondence should be addressed to \thecorrespondence\par
        \bigskip
      \fi
      \ifx\empty\dccp@conf
      \else
        \dccp@conf\par
        \bigskip
      \fi
      \dccp@publ@msg\par
      \bigskip
      \begin{minipage}[b]{\linewidth - 25mm}
      Copyright rests with the authors. This work is released under a Creative
      Commons Attribution 4.0 International Licence. For details please see
      \url{http://creativecommons.org/licenses/by/4.0/}%
      \end{minipage}\hfill
      \begin{minipage}[b]{19mm}
        \href{http://creativecommons.org/licenses/by/4.0/}%
          {\includegraphics[width=\hsize]{dccpaper-by}}%
      \end{minipage}
      \par
      \bigskip
      \makebox[0pt][l]{\parbox{0.4\hsize}{%
        \ifx\undefined\dccp@titlefoot@bib\else\dccp@titlefoot@bib\fi
      }}\hfill
      \makebox[0pt][c]{\normalsize\thepage}\hfill
      \makebox[0pt][r]{\parbox{0.4\hsize}{%
        \raggedleft\ifx\undefined\dccp@titlefoot@doi\else\dccp@titlefoot@doi\fi
      }}%
    \end{minipage}%
  }%
  \let\@evenfoot=\@oddfoot
  \let\TitleFoot=\@oddfoot
}
%
% We set the normal page style to \textsf{title} here so that |\TitleHead| and
% |\TitleFoot| are defined, but we will override it with the \textsf{dccpaper}
% page style later.
%
\pagestyle{title}
%
% The first page should use the \textsf{title} page style, however.
%
\AtBeginDocument{\thispagestyle{title}}

%
% Here are the normal headers and footers (i.e.\ the \textsf{dccpaper} page
% style). We save them to |\NormalHead| and |\NormalFoot|, again so we can
% measure them.
%
\def\ps@dccpaper{%
  \def\@oddhead{%
    \begin{minipage}{\textwidth}\frenchspacing
      {%
        \fontsize{9pt}{11pt}\selectfont
        \ifx\undefined\dccp@normhead@doi\else\dccp@normhead@doi\fi
      }\hfill
      {\MainAuthor}\space\space\space
      \textcolor{struct}{\textbar}\space\space\space
      \thepage\par
      \vskip6pt\color{struct}{\hrule height 1bp}\par
    \end{minipage}
  }%
  \def\@evenhead{%
    \begin{minipage}{\textwidth}
      \thepage\space\space\space
      \textcolor{struct}{\textbar}\space\space\space
      {\HeadTitle}\hfill
      {%
        \fontsize{9pt}{11pt}\selectfont
        \ifx\undefined\dccp@normhead@doi\else\dccp@normhead@doi\fi
      }\par
      \vskip6pt\color{struct}{\hrule height 1bp}\par
    \end{minipage}
  }%
  \let\NormalHead=\@oddhead
  \def\@oddfoot{\begin{minipage}[b]{\textwidth}
    \centering\bfseries\normalsize\color{struct}
    \ifx\dccp@type\dccp@editorial
      \dccp@publ@long
    \else
      \dccp@publ@short\space\space\textbar\space\space\emph{\dccp@type}%
    \fi
    \par
  \end{minipage}}%
  \let\@evenfoot=\@oddfoot
  \let\NormalFoot=\@oddfoot
}
\pagestyle{dccpaper}

%
% We need to wait until the author has supplied the necessary information before
% we can do our measuring and set the remainder of the geometry, so we do it at
% the end of the preamble. First we put our saved macros into boxes we can
% measure (i.e.\ |\dccp@firstpagehead|, |\dccp@firstpagefoot|,
% |\dccp@restpagehead|, |\dccp@restpagefoot|).
%
\AtEndPreamble{
  \newsavebox{\dccp@firstpagehead}
  \sbox\dccp@firstpagehead{\normalfont\TitleHead}
  \newsavebox{\dccp@firstpagefoot}
  \sbox\dccp@firstpagefoot{\normalfont
    \def\email#1{#1}\def\url#1{#1}\def\href#1#2{#2}\TitleFoot}
  \newsavebox{\dccp@restpagehead}
  \sbox\dccp@restpagehead{\normalfont\NormalHead}
  \newsavebox{\dccp@restpagefoot}
  \sbox\dccp@restpagefoot{\normalfont\NormalFoot}
%
% We can now set the geometry of the title page\dots
%
  \setlength{\headheight}{\ht\dccp@firstpagehead + \dp\dccp@firstpagehead}
  \setlength{\footskip}{%
    2\baselineskip + \ht\dccp@firstpagefoot + \dp\dccp@firstpagefoot
  }
  \setlength{\textheight}{%
    \paperheight
    - 30mm % 15mm top and bottom
    - \headheight
    - \headsep
    - \footskip
  }
%
% {\dots}and provide a macro that will reset the geometry for the remaining
% pages.
%
  \def\dccp@resetgeometry{%
    \setlength{\headheight}{\ht\dccp@restpagehead + \dp\dccp@restpagehead}
    \global\headheight=\headheight
    \setlength{\footskip}{%
      2\baselineskip + \ht\dccp@restpagefoot
    }
    \global\footskip=\footskip
    \setlength{\textheight}{%
      \paperheight
      - 30mm % 15mm top and bottom
      - \headheight
      - \headsep
      - \footskip
    }
    \FixTextHeight
    \global\textheight=\textheight
  }
}

%
% The |\maketitle| command is redefined to the correct formatting. At the end it
% sets a hook that will reset the geometry when the first page is shipped out,
% i.e.\ with effect from the second page. It is here rather than at the end of
% the abstract in case the abstract itself spills over to the second page.
%
\RequirePackage{atbegshi}
\renewcommand{\maketitle}{%
  \null\nobreak\vspace*{-0.528\baselineskip}%
  \begingroup
    \centering
    {\Large\thetitle\par}
    \vspace{0.7\baselineskip}
    \AuthorBlock\par
    \vspace{1.7\baselineskip}
  \endgroup
  \AtBeginShipoutNext{\dccp@resetgeometry}%
}

%
% The \textsf{abstract} environment is redefined in terms of an environment
% \textsf{widequote}, which mimics the \textsf{quote} environment, but is a bit
% wider. We also provide a hook, |\afterabstract|, so that if some annotation
% needs to be appended to the title page after the abstract, we can do that.
%
\newenvironment{widequote}{%
  \list{}{%
    \setlength{\rightmargin}{2\parindent}%
    \setlength{\leftmargin}{2\parindent}%
  }%
  \flushleftright\item[]%
}{%
    \endlist
}
\def\afterabstract{}
\renewenvironment{abstract}{%
  \vskip1em%
  \begin{center}%
    {\bfseries\abstractname\vspace{-.5em}\vspace{\z@}}%
  \end{center}%
  \widequote\footnotesize
}{%
  \endwidequote\afterabstract\newpage
}

%
% We use the \textsf{titlesec} package to give headings the correct formatting.
% The settings below try to space out headings so they occupy an integer number
% of normal lines (an attempt at grid typesetting). They are a little
% complicated because we want it to work even if the heading appears at the top
% of the page.
%
\RequirePackage{titlesec}
\titlespacing*{\section}{0pt}{0pt}{\baselineskip}
\titlespacing*{\subsection}{0pt}{0pt}{0.6\baselineskip}
\titlespacing{\subsubsection}{\parindent}{\baselineskip}{0pt}
\titlespacing{\paragraph}{\parindent}{\baselineskip}{0pt}
\titlespacing{\subparagraph}{\parindent}{\baselineskip}{0pt}
%
% An unfortunate side effect of spacing headings like this is that if a
% |\subsection| immediately follows a |\section| it forms an unsightly gap. To
% remedy this, we count how many paragraphs there have been since the last
% |\section|. Note that as we do not normally number the sections, an automatic
% reset of the |sectionpars| counter within the |section| counter won't work.
%
\newcounter{sectionpars}
\let\dccp@old@ep\everypar
\newtoks\everypar
\dccp@old@ep{\the\everypar\stepcounter{sectionpars}}
%
% We need to manually reset |sectionpars| when |\section| is called. Also,
% the normal font size is 12pt/14.5pt, while |\Large| is 17pt/22pt;
% so the |\Large| line height = 1.5172 $\times$ normal line height. Nevertheless
% it seems to work better if we let the heading eat 0.528|\baselineskip| into
% the 2|\baselineskip| of padding above it.
%
\titleformat{\section}
  [block]
  {%
    \vspace{2\baselineskip}%
    \nobreak
    \vspace*{-0.528\baselineskip}%
    \setcounter{sectionpars}{0}%
    \filcenter\normalfont\Large\bfseries
  }
  {\thesection}
  {\quad}
  {}
%
% The others use a |\normalsize| font so that makes life easier. The format
% for |\subsection| command includes conditional spacing: if the |sectionpars|
% counter equals 2, this means the heading immediately follows a |\section|, so
% less white space is needed.
%
\titleformat{\subsection}
  {%
    \ifnum\thesectionpars>2%
      \vspace{2\baselineskip}%
    \else
      \vspace{\baselineskip}%
    \fi\nobreak
    \vspace*{-0.6\baselineskip}%
    \normalfont\normalsize\bfseries
  }
  {\thesubsection}
  {\quad}
  {}
\titleformat{\subsubsection}
  [block]
  {\normalfont\normalsize\bfseries}
  {\thesubsubsection}
  {\quad}
  {}
\titleformat{\paragraph}
  [block]
  {\normalfont\normalsize\bfseries\itshape}
  {\thesubsubsection}
  {\quad}
  {}
\titleformat{\subparagraph}
  [block]
  {\normalfont\normalsize\itshape}
  {\thesubsubsection}
  {\quad}
  {}
%
% DCC papers do not typically number their sections.
%
\setcounter{secnumdepth}{0}

%
% To help with the display of tables we load the \textsf{array} and
% \textsf{booktabs} packages. As we don't like lines between rows in the table
% body, we stretch them out a bit so that white space does the job instead.
%
\RequirePackage{array,booktabs}
\renewcommand{\arraystretch}{1.25}

%
% We use the \textsf{caption} package to give captions the right format.
%
\RequirePackage
  [ format=hang
  , labelsep=period
  , font=small
  , labelfont=bf
  , figureposition=bottom
  , tableposition=top
  ]{caption}

%
% Footnotes should be set right up against the left margin. They should be
% set hung and in the same half-ragged style as the main text. They should also,
% for neatness, be at the bottom of the page regardless of how short it is. The
% \textsf{footmisc} package helps here.
%
\RequirePackage[hang,bottom]{footmisc}
\settowidth{\footnotemargin}{\footnotesize\textsuperscript{99}\space}
\renewcommand{\footnotelayout}{\raggedyright}
%
% Also, if multiple footnotes are set at once, the markers should be separated
% with superscript commas. The \textsf{footmisc} package should help here but
% its solution is clobbered by \textsf{hyperref}. So after a footnote is set,
% we check to see if the next token is also a footnote, and if so, slip a comma
% in before it.\footnote{This solution was provided at
% \url{http://tex.stackexchange.com/q/40072}} This tweak needs to be done late,
% |\AtBeginDocument|. Note that the \textsf{newtx} superior figures are a bit
% lower than normal superscript text.
%
\AtBeginDocument{
  \let\dccp@footnote\footnote
  \def\dccp@next@token{\relax}%
  \def\dccp@supercomma{\textsuperscript{,}}%
  \IfFileExists{newtxtext.sty}%
    {\def\dccp@supercomma{\raisebox{-0.2ex}{\textsuperscript{,}}}}%
    {}

  \newcommand\dccp@check@for@footnote{%
    \ifx\footnote\dccp@next@token
      \dccp@supercomma
    \fi
  }

  \renewcommand\footnote[1]{%
    \dccp@footnote{#1}%
    \futurelet\dccp@next@token\dccp@check@for@footnote
  }
}

%
% By default lists are quite loose. These settings help to tighten them.
%
\topsep = \z@
\partopsep = \z@
\appto{\enumerate}{\itemsep = 0.5ex plus 0.25ex minus 0.25ex}
\appto{\itemize}{\itemsep = 0.5ex plus 0.25ex minus 0.25ex}

%
% A DCC paper should either be using \textsf{biblatex} or \textsf{apacite} for
% references.
%
% If \textsf{biblatex} is used, we need to ensure that the reference list
% heading is a normal section rather than a starred one so it appears in the
% PDF bookmarks.
%
\AtBeginDocument{
  \@ifpackageloaded{biblatex}{%
    \defbibheading{bibliography}[\refname]{\section{#1}}%
  }{%
%
% If \textsf{apacite} is used, we can do the same with a package option (see
% below). But there are a few other adaptations we need to make.
%
    \@ifpackageloaded{apacite}{%
%
% With \textsf{hyperref} loaded, \textsf{apacite} makes the whole of a citation
% a link to the reference list item. We patch |\@ifauthorsunequalc@de| so only
% the year portion gets linked.
%
      \def\@ifauthorsunequalc@de#1{%
        \if@F@cite
          \@F@citefalse
        \else
          \if@Y@cite
              {\@BAY}%
          \fi
          {\@BBC}%
        \fi
        \edef\@cite@undefined{?}%
        \def\BBA{\@BBA}%
        \if@A@cite
          %%\hyper@natlinkstart{#1}% We remove this line...
          {\csname b@\@citeb\APAC@extra@b@citeb\endcsname}%
          %%\hyper@natlinkend% ...and this one.
          \if@Y@cite
              {\@BBAY}%
          \fi
        \fi
        \if@Y@cite
          \hyper@natlinkstart{#1}%
          {\csname Y@\@citeb\APAC@extra@b@citeb\endcsname}%
          \hyper@natlinkend
        \fi
        \let\BBA\relax
      }
%
% The Spanish language support file defines a different version of
% |\@ifauthorsunequalc@de|, which might override the patch we have just
% introduced. So we employ the same test that \textsf{apacite} uses when
% deciding whether to load that file; if successful, we patch the Spanish
% version. Note that as \textsf{apacite} loads language support files
% |\AtBeginDocument|, we have to do our thing after that, |\AfterEndPreamble|.
%
% (Note that as we set the language to British English earlier, this should
% never be needed, but we try to be resilient to tinkering!)
%
      \AfterEndPreamble{%
        \@ifundefined{iflanguage}{%
          \relax
        }{%
          \edef\APAC@tmp{nohyphenation}%
          \ifx\languagename\APAC@tmp
          \else
            \edef\APAC@tmp{spanish}%
            \ifx\languagename\APAC@tmp
              \def\@ifauthorsunequalc@de#1{%
                \if@F@cite
                  \@F@citefalse
                \else
                  \if@Y@cite
                      {\@BAY}%
                  \fi
                  {\@BBC}%
                \fi
                \edef\@cite@undefined{?}%
                \def\BBA{\@BBA}%
                \@ifundefined{spanishe@\@citeb\APAC@extra@b@citeb}%
                  {}% skip
                  {{% Use `e' instead of `y' in Spanish
                  \global\let\oldBBA\BBA
                  \global\def\BBA{e\global\let\BBA\oldBBA}%
                  }}%
                \if@A@cite
                  %%\hyper@natlinkstart{#1}% We remove this line...
                  {\csname b@\@citeb\APAC@extra@b@citeb\endcsname}%
                  %%\hyper@natlinkend% ...and this one.
                  \if@Y@cite
                      {\@BBAY}%
                  \fi
                \fi
                \if@Y@cite
                  \hyper@natlinkstart{#1}%
                  {\csname Y@\@citeb\APAC@extra@b@citeb\endcsname}%
                  \hyper@natlinkend
                \fi
                \let\BBA\relax
              }%
            \fi
          \fi
        }%
%
% Another thing \textsf{apacite} does |\AtBeginDocument| is set the URL style
% to monospaced. So we reset it back to normal roman type |\AfterEndPreamble|.
%
        \urlstyle{APACrm}
       }%
%
% We pre-empt \textsf{apacite}'s |\providecommand| of |\doi| with our own
% definition that includes the `doi' URI scheme label in the link, remembering
% to remove the one inserted by |\doiprefix|.
%
      \newcommand{\doi}[1]{\href{http://dx.doi.org/#1}{\nolinkurl{doi:#1}}}%
      \renewcommand{\doiprefix}{\unskip}%
    }{}%
  }%
%
% Both \textsf{biblatex} and \textsf{apacite} use |\bibitemsep| for the space
% between bibliography items. Just in case they haven't been loaded, though, we
% protect our setting of that length with an |\ifx| test.
%
  \ifx\undefined\bibitemsep
  \else
    \setlength{\bibitemsep}{1em plus 1ex minus 1ex}%
  \fi
}
%
% As mentioned above, if \textsf{apacite} is used, we can use a package option
% to ensure that the reference list heading appears in the PDF bookmarks.
%
\PassOptionsToPackage{numberedbib}{apacite}

%
% We, of course, use \textsf{hyperref} for enhancing the PDF with working links,
% bookmarks, metadata, etc.
%
\usepackage
  [ colorlinks=true
  , linkcolor=black
  , anchorcolor=black
  , citecolor=links
  , filecolor=black
  , menucolor=black
  , runcolor=black
  , urlcolor=links
  ]{hyperref}
%
% Links should be in roman type, not monospaced.
%
\urlstyle{rm}
%
% We provide an |\email| command for displaying the email address of the
% corresponding author.
%
\newcommand*{\email}[1]{\href{mailto:#1}{#1}}
%
% Once the user has had a chance to provide the metadata, we can add it to the
% PDF metadata.
%
\AtBeginDocument{%
  \hypersetup
    { pdftitle={\thetitle}
    , pdfauthor={\dccp@author}
    , pdfsubject={\dccp@subject}
    }
%
% The APA has its own style for line breaks in URLs. The \textsf{apacite}
% package provides the code for this, but in case \textsf{biblatex} is used
% instead, we repeat the settings (from 2013/07/21 v6.03) here.
%
  \@ifundefined{Url@force@Tilde}{\def\Url@force@Tilde{\relax}}{}%
  \def\url@apa@dot{\mathchar"2E }%
  \def\url@apa@comma{\mathchar"2C }%
  \def\url@apa@questionmark{\mathchar"3F }%
  \def\url@apa@exclamation{\mathchar"21 }%
  \def\url@apa@hyphen{\mathchar"2D }%
  \def\url@apa@underscore{\_}%
  \def\UrlBreaks{\do\@\do\\\do\|\do\;\do\>\do\]\do\)\do\'\do+\do\=\do\#}%
  \def\UrlBigBreaks{\do\/\do\:\do@url@hyp}%
  \def\UrlNoBreaks{\do\(\do\[\do\{\do\<}% \)}
  \def\UrlOrds{\do\*\do\~\do\'\do\"}%
  \def\UrlSpecials{%
    \do\.{\mathbin{}\url@apa@dot }%
    \do\,{\mathbin{}\url@apa@comma }%
    \do\-{\mathbin{}\url@apa@hyphen }%
    \do\?{\mathbin{}\url@apa@questionmark }%
    \do\!{\mathbin{}\url@apa@exclamation }%
    \do\_{\mathbin{}\url@apa@underscore }%
    \do\ {\Url@space}\do\%{\Url@percent}\do\^^M{\Url@space}%
    \Url@force@Tilde}%
  \def\Url@OTnonTT{\do\<{\langle}\do\>{\mathbin{\rangle}}\do
    \_{\mathbin{}\_}\do\|{\mid}\do\{{\lbrace}\do\}{\mathbin{\rbrace}}\do
    \\{\mathbin{\backslash}}\UrlTildeSpecial}
}

%
% We now embed the Creative Commons licence information in the PDF using an XMP
% packet. To do this, we employ the same technique as Scott Pakin's
% \textsf{hyperxmp} (2014/01/02 v2.4). In order to avoid avoid a bug whereby
% Adobe Acrobat confuses the XMP author information and the regular author
% information, though, we \emph{only} embed the licence information.
%
% We need to make sure that any characters to appear verbatim in the XMP packet
% are treated as ordinary characters and not active ones. The likely active
% characters are symbols and punctuation, so should be treated as `other'
% (category 12).
%
\begingroup
\catcode`\"=12
\catcode`\&=12
\catcode`\#=12
\catcode`\<=12
\catcode`\>=12
\catcode`\_=12
%
% We construct the XMP packet as the document begins.
%
\AtBeginDocument{%
%
% For convenience we define |\sp| to be a level of indent, translating to three
% spaces.
%
  \def\sp{\space\space\space}
%
% The text of the XMP packet is recorded in |\cc@xmp@packet|. We use |^^J| to
% break lines.
%
  \long\gdef\cc@xmp@packet{%
<?xpacket begin='' id=''?>^^J%
<x:xmpmeta xmlns:x='adobe:ns:meta/'>^^J%
<rdf:RDF xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'>^^J%
\sp<rdf:Description rdf:about=''^^J%
\sp\sp xmlns:xapRights='http://ns.adobe.com/xap/1.0/rights/'>^^J%
\sp\sp<xapRights:Marked>True</xapRights:Marked>^^J%
\sp</rdf:Description>^^J%
\sp<rdf:Description rdf:about=''^^J%
\sp\sp xmlns:dc='http://purl.org/dc/elements/1.1/'>^^J%
\sp\sp<dc:rights>^^J%
\sp\sp\sp<rdf:Alt>^^J%
\sp\sp\sp\sp<rdf:li xml:lang='x-default'>This work is licensed under a Creative Commons Attribution 4.0 International Licence.</rdf:li>^^J%
\sp\sp\sp</rdf:Alt>^^J%
\sp\sp</dc:rights>^^J%
\sp</rdf:Description>^^J%
\sp<rdf:Description rdf:about=''^^J%
\sp\sp xmlns:cc='http://creativecommons.org/ns#'>^^J%
\sp\sp<cc:license rdf:resource='http://creativecommons.org/licenses/by/4.0/'/>^^J%
\sp</rdf:Description>^^J%
</rdf:RDF>^^J%
</x:xmpmeta>^^J%
<?xpacket end='r'?>^^J%
  }%
}
\endgroup
%
% Different workflows require the XMP packet to be embedded in different ways.
%
% Pdf\TeX\ can inject objects into PDFs natively.
%
\newcommand*{\ccxmp@embed@packet@pdftex}{%
  \bgroup
    \pdfcompresslevel=0
    \immediate\pdfobj stream attr {%
      /Type /Metadata
      /Subtype /XML
    }{\cc@xmp@packet}%
    \pdfcatalog {/Metadata \the\pdflastobj\space 0 R}%
  \egroup
}
%
% The |\pdfmark| command defined by \textsf{hyperref} is respected by tools such
% as Dvipdf, Dvips, Dvipsone, etc.
%
\newcommand*{\ccxmp@embed@packet@pdfmark}{%
  \pdfmark{%
    pdfmark=/NamespacePush
  }%
  \pdfmark{%
    pdfmark=/OBJ,
    Raw={/_objdef \string{ccxmp@packet\string} /type /stream}%
  }%
  \pdfmark{%
    pdfmark=/PUT,
    Raw={\string{ccxmp@packet\string}
      2 dict begin
        /Type /Metadata def
        /Subtype /XML def
        currentdict
      end
    }%
  }%
  \pdfmark{%
    pdfmark=/PUT,
    Raw={\string{ccxmp@packet\string} (\cc@xmp@packet)}%
  }%
  \pdfmark{%
    pdfmark=/Metadata,
    Raw={\string{Catalog\string} \string{ccxmp@packet\string}}%
  }%
  \pdfmark{%
    pdfmark=/NamespacePop
  }%
}
%
% Dvipdfm has its own |\special| command for inserting PDF objects, but
% it is a bit basic and requires advance knowledge of how long (in characters)
% the object is.
%
% The |\ccxmp@count@spaces| macro counts the number of spaces in its parameter
% through a process of iteration, adding this figure to |\@tempcnta|.
%
\def\ccxmp@count@spaces#1 {%
  \def\ccxmp@one@token{#1}%
  \ifx\ccxmp@one@token\@empty
    \advance\@tempcnta by -1
  \else
    \advance\@tempcnta by 1
    \expandafter\ccxmp@count@spaces
  \fi
}
%
% The |\ccxmp@count@non@spaces| command counts the number of non-spaces in its
% argument through a process of iteration, adding this figure to |\@tempcnta|.
%
\newcommand*{\ccxmp@count@non@spaces}[1]{%
  \def\ccxmp@one@token{#1}%
  \ifx\ccxmp@one@token\@empty
  \else
    \advance\@tempcnta by 1
    \expandafter\ccxmp@count@non@spaces
  \fi
}
%
% The |\ccxmp@string@len| command sets |\@tempcnta| to the number of characters
% (spaces + non-spaces) in its argument.
%
\newcommand*{\ccxmp@string@len}[1]{%
  \@tempcnta=0
  \expandafter\ccxmp@count@spaces#1 {} %
  \expandafter\ccxmp@count@non@spaces#1{}%
}
%
% So now, finally, is the command for embedding the packet using Dvipdfm.
%
\newcommand*{\ccxmp@embed@packet@dvipdfm}{%
  \ccxmp@string@len{\cc@xmp@packet}%
  \special{pdf: object @ccxmp@packet
    <<
      /Type /Metadata
      /Subtype /XML
      /Length \the\@tempcnta
    >>
    stream^^J\cc@xmp@packet endstream%
  }%
  \special{pdf: docview
    <<
      /Metadata @ccxmp@packet
    >>
  }%
}
%
% \XeTeX\ creates PDFs with Xdvipdfmx, which supports a simpler |\special| for
% inserting objects that does not require us to count characters.
%
\newcommand*{\ccxmp@embed@packet@xetex}{%
  \special{pdf:stream @ccxmp@packet (\cc@xmp@packet)
    <<
      /Type /Metadata
      /Subtype /XML
    >>
  }%
  \special{pdf:put @catalog
    <<
      /Metadata @ccxmp@packet
    >>
  }%
}
%
% We rely on \textsf{hyperref} to tell us how the PDF will be generated (after
% all, it may not be done in the current pass) and use the respective technique
% to embed the XMP packet.
%
\AtBeginDocument{%
  \begingroup
  \def\ccxmp@driver{hpdftex}%
  \ifx\ccxmp@driver\Hy@driver
    \ccxmp@embed@packet@pdftex
  \else
    \def\ccxmp@driver{hdvipdfm}%
    \ifx\ccxmp@driver\Hy@driver
      \ccxmp@embed@packet@dvipdfm
    \else
      \def\ccxmp@driver{hxetex}%
      \ifx\ccxmp@driver\Hy@driver
        \ccxmp@embed@packet@xetex
      \else
        \@ifundefined{pdfmark}{}{%
          \ccxmp@embed@packet@pdfmark
        }%
      \fi
    \fi
  \fi
  \endgroup
}
%% 
%% Copyright (C) 2014 Digital Curation Centre, University of Edinburgh
%% <info@dcc.ac.uk>
%%
%% End of file `dccpaper-base.tex'.