-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdtrt.sty
More file actions
1059 lines (951 loc) · 45.2 KB
/
Copy pathdtrt.sty
File metadata and controls
1059 lines (951 loc) · 45.2 KB
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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% PREPARING A CAMERA-READY VERSION? Passing the [camera] option to this package
% will turn off author notes and other effects that you may be worried about.
%
%
% This LaTeX package will Do The Right Thing, as defined ad hoc by its author and
% implemented in arbitrarily kludgy ways. See https://github.com/leisec/dtrt for an
% overview and the latest version.
%
% Author and margin notes:
% + Define a \dtnote[author]{text} command for nicely formatted author notes with
% margin marks (author name is optional), and similarly
% \dtcolornote[author]{color}{text}.
% + Define a \later macro that, when preceding a \dtnote, marks it as a "note for later".
% These can be turned off by option "[later=false]".
% + Define a \done macro that, when preceding a \dtnote, marks it as a "note for done"
% These can be turned off by option "[done=false]".
% + Define \XXX[text], which is similar to \dtnote{text} but aborts compilation
% if notes are disabled.
% + Define \ignore[comment]{text} which ignores the text but (in draft mode) adds
% a mark and an optional comment in the margin.
% + Defines a \sidenote{text} command which creates a margin note that work
% reasonably even inside footnotes, tabulars, titles and (sometimes) math,
% and can be disabled using "sidenotes=false".
% + Notes have the string "\NOTE" invisibly placed nearby, to make them easy to search
% when rendered to PDF. \XXX notes also have "\XXX" invisibly placed. Broken references
% also have "\ERROR".
%
% Page formatting:
% - Designate drafts as such, including time of compilation ("[draft]" option).
% + Enables page numbering on all pages except first.
% - Add a head at the top of every page with either the current chapter and section
% or current the section and subsection ("[head=...]" option).
% - Set page geometry as fraction of page width and height, in a
% package-independent way ("[width=...]" and "[height=...]" options).
%
% Local formatting:
% + Define a \parhead{text} command for paragraph-level headings (well-formatted
% bold text at beginning of paragraph) that always work. Periods are appended
% unless the header text already ends with a punctuation mark.
% + Define a "\footnotesymb{symbol}{text}" command for footnote with explicitly
% given symbol (possibly empty).
% + Define a "nestedbar" environment for indenting text and marking it with a vertical
% bar on the left.
% - Remove space after comma when used as decimal separator in math mode (option "[smartcomma]").
% - Add a horizontal line above figure captions (option "[captionrule]").
%
% Hyperlinks, references and TOC:
% + Define an "\emailref{user@host}" command for creating hyperlinked email addresses,
% and "\httpref{user@host}" command for creating hyperlinked URLs without rendering
% the "mailto://" or "http://".
% + Generate TOC entries and PDF bookmarks for "\section*", "\subsection*" etc.
% (including References), and also for the abstract.
% + Apply nice formatting to PDF bookmarks.
% + Allow footnotes in section titles without strange effects in TOC.
% + Define a "\dtbookmark{level}{text}" command for creating custom PDF bookmarks.
% + Automatic margin marks and highlights for broken references
% + Patch HyperRef's \autoref so that if \sectionautorefname etc. are redefined to
% a section mark ("\S") then they won't be followed by a space.
%
% Misc:
% + Patch LLNCS: fix TOC, PDF bookmarks, and the ", and" in the author list.
% - For LLNCS: add a \date{} feature to title block, similar to the article class.
% - For LLNCS: add a QED square at the end of llncs proof environments
% - For LLNCS: put subsubsection captions on dedicated lines, and number them
% - When asked to generate a standard-compliant submission, disable all relevant
% effects ("[camera]" option).
%
% (Above, featured marked by "+" are enabled by default, "-" require explicit activation.)
%
% Package options (use as follows: " \usepackage[foo,bar=baz]{dtrt} "):
% camera -- Disable most effects of this package (for camera-ready
% versions). Formatting tweaks and LLNCS overrides are disabled,
% and explicitly-invoked macros are still defined but have the least
% possible effect (e.g., \parhead works, \dtnote is ignored).
% draft -- Write "DRAFT" and time of compilation at page bottoms.
% notes=false -- Disable display of \dtnote{...} author notes, \XXX and \ignore marks.
% notes=xxx -- Disable display of \dtnote{...} author notes and \ignore marks. Keep \XXX.
% later=false -- Disable display of \later\dtnote{...} notes (but still leave a
% mark in the margin, unless also notes=false).
% done=false -- Disable display of \done\dtnote{...} notes (but still leave a mark, ditto)
% showignore=false -- Don't show \ignore marks even if notes=true
% sidenotes=false -- Discard all \sidenote{}s.
%
% geometry -- Alter page geometry.
% width=0.75 -- Specify width of text relative to physical page.
% height=0.70 -- Specify height of text relative to physical page.
% blankpages=true -- Add blank even or odd pages to align Sections, Parts etc.
% blankpages=false -- Don't use color in \dtnote, \XXX and draft marks.
% bindshift=1cm -- Prepare for two-sided printing and shift pages away from
% spine by the given distance.
% head=... -- Add a head at the top of every page, containing either the
% current chapter and section ("head=chaptersection") or the
% current section and subsection ("head=sectionsubsection").
% llncsdate -- add a \date{} feature to title block for the LLNCS class,
% similar to that of the 'article' class.
% llncsqed -- add a QED square at the end of LLNCS proof environments.
% llncssubsub -- make LLNCS subsubsection caption be be numbered and followed by a linebreak
% smartcomma -- Remove spaces after commas used as decimal separators.
% captionrule -- Add a horizontal line ("rule") above figure's caption
%
% Written by Eran Tromer <eran@tromer.org> except where noted otherwise.
% Distributed under the LaTeX Project Public License v1.3a or later; see
% http://www.latex-project.org/lppl.txt for details and (lack of) warranty.
% If you make corrections or improvements, please share them with the author.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\ProvidesPackage{dtrt}[2021/09/08 v0.95020]
\usepackage{amssymb}
\usepackage{keyval}
\usepackage{ifpdf}
\usepackage{url}
\usepackage{ifthen}
\usepackage{etoolbox}
\usepackage{xpatch}
\usepackage{xcolor}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Package options (documented above):
\newcommand{\dt@width}{0.7}
\newcommand{\dt@height}{0.75}
\newcommand{\dt@paper}{letterpaper} % must be a name supported by the 'geometry' package
\newcommand{\dt@head}{} % must be one of '', 'chaptersection' or 'sectionsubsection'
\newcommand{\dt@firstpagestyle}{empty} % must be a valid page style such as 'empty' or 'plain'
\newcommand{\dt@draftfootnote}{DRAFT --- compiled at \dt@datetime \@ifundefined{OSUserName}{}{ by \texttt{\OSUserName}}; not for distribution}
\@ifundefined{dt@linkcolor}{
\definecolor{dt@linkcolor}{rgb}{0.8 0.8 1}
}{}
\newif\ifdt@camera \dt@camerafalse
\newif\ifdt@smartcomma \dt@smartcommafalse
\newif\ifdt@notes \dt@notestrue
\newif\ifdt@later \dt@latertrue
\newif\ifdt@done \dt@donetrue
\newif\ifdt@showignore \dt@showignoretrue
\newif\ifdt@sidenotes \dt@sidenotestrue
\newif\ifdt@draft\dt@draftfalse
\newif\ifdt@geometry\dt@geometryfalse
\newif\ifdt@blankpages \dt@blankpagesfalse
\newif\ifdt@colornotes \dt@colornotestrue
\newif\ifdt@llncsdate \dt@llncsdatefalse
\newif\ifdt@llncsqed \dt@llncsqedfalse
\newif\ifdt@llncssubsub \dt@llncssubsubfalse
\newif\ifdt@llncs \@ifclassloaded{llncs}{\dt@llncstrue}{\dt@llncsfalse}
\newif\ifdt@acmart \@ifclassloaded{acmart}{\dt@acmarttrue}{\dt@acmartfalse}
\newif\ifdt@marginpars \dt@marginparstrue
\newif\ifdt@captionrule \dt@captionrulefalse
\newif\ifdt@xxxanyway \dt@xxxanywayfalse % show \XXX even if notes=false
\newcommand{\dt@notesxxx}{\dt@notesfalse\dt@xxxanywaytrue}
\newcommand{\dt@notesXXX}{\dt@notesfalse\dt@xxxanywaytrue}
% Some classes don't work well with marginpar
\@ifclassloaded{sig-alternate}{\dt@marginparsfalse}{}
\@ifclassloaded{sig-alternate-05-2015}{\dt@marginparsfalse}{}
\@ifclassloaded{acm_proc_article-sp}{\dt@marginparsfalse}{}
\define@key{dt@KV}{smartcomma}[true]{\csname dt@smartcomma#1\endcsname}
\define@key{dt@KV}{notes}[true]{\csname dt@notes#1\endcsname}
\define@key{dt@KV}{later}[true]{\csname dt@later#1\endcsname}
\define@key{dt@KV}{done}[true]{\csname dt@done#1\endcsname}
\define@key{dt@KV}{geometry}[true]{\csname dt@geometry#1\endcsname}
\define@key{dt@KV}{draft}[true]{\csname dt@draft#1\endcsname}
\define@key{dt@KV}{showignore}[true]{\csname dt@showignore#1\endcsname}
\define@key{dt@KV}{sidenotes}[true]{\csname dt@sidenotes#1\endcsname}
\define@key{dt@KV}{width}{\def\dt@width{#1}\dt@geometrytrue}
\define@key{dt@KV}{height}{\def\dt@height{#1}\dt@geometrytrue}
% \define@key{dt@KV}{linkcolor}{\def\dt@linkcolor{#1}}
% Broken -- can't pass {r g b} via keyval.
% Use \newcommand{\dt@linkcolor}{{0.6 0.6 1.0}} before \usepackage{dtrt} instead.
\define@key{dt@KV}{bindshift}{\def\dt@bindshift{#1}}
\define@key{dt@KV}{blankpages}[true]{\csname dt@blankpages#1\endcsname}
\define@key{dt@KV}{firstpagestyle}{\renewcommand{\dt@firstpagestyle}{#1}}
\define@key{dt@KV}{colornotes}[true]{\csname dt@colornotes#1\endcsname}
\define@key{dt@KV}{marginpar}[true]{\csname dt@marginpars#1\endcsname}
\define@key{dt@KV}{llncsdate}[true]{\csname dt@llncsdate#1\endcsname}
\define@key{dt@KV}{llncsqed}[true]{\csname dt@llncsqed#1\endcsname}
\define@key{dt@KV}{llncssubsub}[true]{\csname dt@llncssubsub#1\endcsname}
\define@key{dt@KV}{captionrule}[true]{\csname dt@captionrule#1\endcsname}
\define@key{dt@KV}{head}{\renewcommand{\dt@head}{#1}}
\define@key{dt@KV}{draftfootnote}{\renewcommand{\dt@draftfootnote}{#1}}
\define@key{dt@KV}{camera}[true]{\csname dt@camera#1\endcsname
\ifdt@camera
\dt@notesfalse
\dt@draftfalse
\dt@geometryfalse
\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Process package options (code copied from Walter Schmidt's "helvet.sty",
% http://www.tug.org/tex-archive/help/Catalogue/entries/psnfss.html).
\def\ProcessOptionsWithKV#1{%
\let\@tempc\relax
\let\dt@tempa\@empty
\@for\CurrentOption:=\@classoptionslist\do{%
\@ifundefined{KV@#1@\CurrentOption}%
{}%
{\edef\dt@tempa{\dt@tempa,\CurrentOption,}}%
}%
\edef\dt@tempa{%
\noexpand\setkeys{#1}{%
\dt@tempa\@ptionlist{\@currname.\@currext}%
}%
}%
\dt@tempa
}
\ProcessOptionsWithKV{dt@KV}
\AtEndOfPackage{\let\@unprocessedoptions\relax}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Functionality that's available only if camera=false:
\ifdt@camera
% Got "camera" option, so just define some empty macros and do sanity checks
\newcommand{\dtbookmark}[2]{}
% Sanity check for LLNCS font size:
\ifdt@llncs
\ifthenelse{\equal{\@ptsize}{0}}{}{
\@latex@error{LLNCS needs default 10pt for camera-ready, you seem to use 1\@ptsize pt. Fix your documentclass}\@ehd
}
\fi%dt@llncs
\else%dt@camera
% Not camera-ready, tweak stuff freely:
% Number all pages except title page:
\pagestyle{plain}
\AtBeginDocument{%
\thispagestyle{\dt@firstpagestyle}%
}
% Define a "\dtbookmark{level}{text}" command for custom PDF bookmarks:
\ifpdf
\newcounter{dtrtbk}
\newcommand{\dtbookmark}[2]{\pdfbookmark[#1]{#2}{\arabic{dtrtbk}}\addtocounter{dtrtbk}{1}}
\else%pdf
\newcommand{\dtbookmark}[2]{}
\fi%pdf
% set the Abstract bookmark higher up, at the title
\xpretocmd{\maketitle}{\dtbookmark{1}{Abstract}}{}{}
% Configure PDF bookmarks and links:
\ifpdf
% Configure PDF with colored links and nice bookmarks:
% Color the letters (but also in printout):
% \usepackage{color}
% \definecolor{LinkBlue}{rgb}{0,0,0.8}
% \usepackage[pdfpagemode=UseOutlines,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,pdfstartview=FitH,colorlinks,linkcolor=LinkBlue,citecolor=LinkBlue,urlcolor=LinkBlue,pagecolor=LinkBlue]{hyperref}
% Color the border (doesn't show in printout):
\usepackage[hyperindex=true]{hyperref}
\hypersetup{pdfpagemode=UseOutlines,bookmarksnumbered=true,bookmarksopen=true,bookmarksopenlevel=2,pdfstartview=FitH,pdfborder={0 0 1},linkbordercolor=dt@linkcolor,citebordercolor=dt@linkcolor,urlbordercolor=dt@linkcolor}
% Make PDF bookmarks for title+abstract:
\let\dt@oldtitle=\title
\renewcommand{\title}[1]{%
\hypersetup{pdftitle={#1}}%
\dt@oldtitle{#1}%
}
% Marks broken citations and make them searchable in PDF by "\NOTE" or "\ERROR"
\newcommand{\dt@brokenrefmark}[1]{%
% \smash{\rlap{\dt@colorize\LARGE$\bigcirc$}}% % hard to place this right, since \G@refundefinedtrue is invoked after the "?"
% force a \marginnote, even though \sidenote renders nicer, because many broken citations with \sidenote can cause `"Too many unprocessed floats" errors.
\marginnote%
[\dt@colorize\normalfont\smash{\large$\not\curvearrowleft $}\dt@invisibletiny{\textbackslash{}NOTE\textbackslash{}ERROR}%
\newline\baselineskip=0.5\baselineskip{\tiny{#1}}]%
{\dt@colorize\normalfont\smash{\dt@invisibletiny{\textbackslash{}NOTE\textbackslash{}ERROR}\large$\not\curvearrowright$}%
\newline\baselineskip=0.5\baselineskip{\tiny{#1}}}%
}
\newbool{dt@markundef} \booltrue{dt@markundef}
\xpretocmd{\G@refundefinedtrue}{\ifbool{dt@markundef}{\dt@brokenrefmark{\@ifundefined{@citeb}{}{\@citeb}}}{}}{}{}
\let\dt@old@setref=\@setref
\renewcommand{\@setref}[3]{%
\ifx#1\relax \dt@brokenrefmark{#3}\fi%
\dt@markundeffalse%
\dt@old@setref{#1}{#2}{#3}%
\dt@markundeftrue%
}
%Rewrote above but maybe broken because parameters:
%\xpretocmd{\@setref}{\ifx#1\relax \dt@brokenrefmark{#3}\fi \boolfalse{dt@markundef}}
%\xapptocmd{\@setref}{\booltrue{dt@markundef}}
% \let\dt@old@pagesetref=\@pagesetref
% \renewcommand{\@pagesetref}[3]{% \ifx#1\relax%
% \sidenote{\dt@colorize\centering\reset@font\LARGE$\not\curvearrowright$}%
% \fi\dt@old@pagesetref{#1}{#2}{#3}}
\else%pdf
%\usepackage[hyperindex=true]{hyperref}
\usepackage{hyperref}
\hypersetup{hyperindex=false}
\fi%pdf
\iftrue
% Add unnumbered sections (\section*, \subsection*, \subsubsection*, bibliography), to the
% TOC and bookmarks. LaTeX by default includes only non-starred sections.
% Hook into \@startsection to learn the section type and level:
\def\dt@lastsecttype{DTRT-UNINIT-SECT-TYPE}
\def\dt@lastsectlevel{0}
\let\dt@old@startsection=\@startsection
\renewcommand{\@startsection}[6]{% {name}{level}{indent}{beforeskip}{afterskip}{style}
\def\dt@lastsecttype{#1}%
\def\dt@lastsectlevel{#2}%
\dt@old@startsection{#1}{#2}{#3}{#4}{#5}{#6}%
}
% Hook into \tableofcontents so we'll know to ignore its own \chapter* command
\newif\ifdt@inTOC \dt@inTOCfalse % inside a table of contents?
\@ifundefined{tableofcontents}{}{
\let\dt@oldtableofcontents=\tableofcontents
\renewcommand{\tableofcontents}{{\dt@inTOCtrue \dt@oldtableofcontents}}
}
% Hook into IEEEtran's appendix generation command (\@IEEEprocessthesectionargument), which create a \section* but also call \addcontentsline
\newbool{dt@inIEEEappendix}\boolfalse{dt@inIEEEappendix}
\xpretocmd{\@IEEEprocessthesectionargument}{\booltrue{dt@inIEEEappendix}}{}{}
\xapptocmd{\@IEEEprocessthesectionargument}{\boolfalse{dt@inIEEEappendix}}{}{}
% Hook into IEEEtran's \thebibliography to avoid duplicate \addcontentsline for its \section*{References}:
\newbool{dt@inIEEEthebibliography}\boolfalse{dt@inIEEEthebibliography}
\@ifclassloaded{IEEEtran}{
\xpretocmd{\thebibliography}{\booltrue{dt@inIEEEthebibliography}}{}{}
\xapptocmd{\thebibliography}{\boolfalse{dt@inIEEEthebibliography}}{}{}
}{}
% Hook into \@ssect to add the TOC entry (\@ssect implements \section*, \subsection*, \subsubsection*)
\ifdt@acmart % skip if acmart.cls loaded, it already takes care of TOC lines and bookmarks for its favorite \section*s
\else
\let\dt@old@ssect=\@ssect
\renewcommand{\@ssect}[5]{% {indent}{beforeskip}{afterskip}{style}{text}
\ifthenelse{ \( \equal{\dt@lastsecttype}{section} \and \equal{#5}{Abstract} \) \or \boolean{dt@inIEEEappendix} \or \boolean{dt@inIEEEthebibliography} }{%
\dt@old@ssect{#1}{#2}{#3}{#4}{#5}% The \section*{Abstract}, and some IEEEtrans \section*s, are are handled elsewhere so don't try to add duplicate TOC entries
}{%
\dt@old@ssect{#1}{#2}{#3}{#4}{%
\phantomsection%
\ifthenelse{\boolean{dt@inTOC} \or \equal{\dt@lastsecttype}{DTRT-UNINIT-SECT-TYPE}}{%
\dtbookmark{\dt@lastsectlevel}{#5}% just a bookmark
}{%
\addcontentsline{toc}{\dt@lastsecttype}{#5}% contents line + bookmark
}%
#5}%
}%
% no need for "\dtbookmark{\dt@lastsectlevel}{#5}", the above already does it.
% TODO: respect TOC depth limit, like hyperref.
% TODO: give a way to disable TOC for some starred sections
% TODO: hyperref will increase depth by at most 1, so \section->{\subsubsection*,\subsubsection\*}
% will get depths 1,2,3 (see twirl.pdf).
% TODO: fix: the anchor is right after the title, instead of its beginning
}
\fi%dt@acmart
% Handle \chapter* (in book.cls) too:
% Hook into \@makeschapterhead to add the TOC entry:
\@ifclassloaded{book}{
\@ifundefined{@makeschapterhead}{}{
\xpretocmd{\@makeschapterhead}{%
\phantomsection%
\ifthenelse{\boolean{dt@inTOC}}{%
\dtbookmark{1}{\contentsname}% just a bookmark
}{%
\addcontentsline{toc}{chapter}{#1}% contents line + bookmark
}%
%\chaptermark{#1}%
}{}{}
}
}{}
\fi%true
% Ignore footnotes inside TOC entries
\let\dt@oldaddcontentsline=\addcontentsline
\renewcommand{\addcontentsline}[3]{%
\let\dt@oldfootnote=\footnote%
\renewcommand{\footnote}[1]{}%
\dt@oldaddcontentsline{#1}{#2}{#3}%
\let\footnote=\dt@oldfootnote%
}
% Some LLNCS-specific fixes:
\ifdt@llncs
% Fix the spurious comma in the default authors list: "Joe, John, and Jill".
% (Overrides LLNCS's \lastandauthor at the last moment since babel may restore it.)
\let\dt@oldauthor=\author
\renewcommand{\author}{%
\def\lastandname{ and}%
\dt@oldauthor%
}
% Bring back the PDF section bookmarks:
\setcounter{tocdepth}{3}
% Avoid llncs's author and title bookmarks:
\let\dt@@oldaddcontentsline=\addcontentsline
\renewcommand{\addcontentsline}[3]{% {table}{type}{text}
\ifthenelse{\equal{#2}{title}}{}{% don't use \or, it's buggy
\ifthenelse{\equal{#2}{author}}{}{%
\dt@@oldaddcontentsline{#1}{#2}{#3}%
}%
}%
}
\fi%dt@llncs
\fi%dt@camera
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page geometry
% Invoke geometry package (in v2 compatibility mode, if >v2):
\ifdt@geometry
% Set internal flags:
\@ifundefined{@twosidefalse}{}{\ifdt@blankpages\@twosidetrue\else\@twosidefalse\fi}
\@ifundefined{@twosidefalse}{}{\ifdt@blankpages\@mparswitchtrue\else\@mparswitchfalse\fi}
% Use geometry v2 interface:
\usepackage{geometry}
\@ifundefined{Gm@compatiitrue}{\def\dt@geomoptcompat{}}{\def\dt@geomoptcompat{compat2,}}
\@ifundefined{dt@bindshift}{\def\dt@geomoptbindshift{}}{\def\dt@geomoptbindshift{twosideshift=\dt@bindshift,}}
\edef\dt@makegeometry{\noexpand\geometry{
\dt@geomoptcompat
\dt@paper,
% verbose,
twoside=\ifdt@blankpages true\else false\fi,
% twosideshift=0pt, <-- don't do this, it turns on @mparswitch
\dt@geomoptbindshift
hscale=\dt@width,
vscale=\dt@height,
voffset=1.5ex, % shift down to re-center despite page numbers
headheight=0pt,
reversemp=false, % true = put margins on left (inner) side
marginparsep=1.5em,
marginparwidth=0.07\paperwidth,
headsep=0pt,
includemp=false
}}
\dt@makegeometry
% Set internal flags again:
% Using twosideshift turns on \@iftwoside, but we don't want blank even/odd pages:
\ifdt@blankpages\else
\@ifundefined{@twosidefalse}{}{\@mparswitchfalse}
\renewcommand{\cleardoublepage}{\clearpage}
\@ifundefined{@endpart}{}{
\let\old@endpart=\@endpart
\renewcommand{\@endpart}{\if@twoside \@twosidefalse \old@endpart \@twosidetrue \else \old@endpart \fi}
}
\fi
\fi%dt@geometry
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Smart comma for mathmode: if a comma is immediately followed by a digit,
% then it's probably a decimal separator so don't put a space after the comma.
% Based on Walter Schmidt's "icomma" package, (http://www.ctan.org/pkg/icomma)
% but modified to checks if next char is a digit rather than a non-space.
\ifdt@smartcomma
{\catcode`,=\active\gdef,{\futurelet\@let@token\dt@smartcomma}}
\def\dt@smartcomma{%
\ifx\@let@token0\mathord\fi \ifx\@let@token1\mathord\fi%
\ifx\@let@token2\mathord\fi \ifx\@let@token3\mathord\fi%
\ifx\@let@token4\mathord\fi \ifx\@let@token5\mathord\fi%
\ifx\@let@token6\mathord\fi \ifx\@let@token7\mathord\fi%
\ifx\@let@token8\mathord\fi \ifx\@let@token9\mathord\fi%
\dt@mathcomma%
}
\AtBeginDocument{%
\@ifundefined{sm@rtcomma}{}{%
\@latex@error{Package dtry cannot coexist with package icomma}\@ehd}%
\mathchardef\dt@mathcomma\mathcode`\,%
\mathcode`\,="8000 %
}
\fi%dt@smartcomma
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% \sidenote{text}: a margin note that works even in footnotes, tabulars, etc.
% We use \marginpar by default, since it provides better layout. But in many
% contexts (foonotes, tabulars, floats, etc.) we have to use the \marginnote instead.
%
% Like \marginnote and \marginpar, you can optionally specify text to use if the note
% ends up on the left margin:
% \sidenote[left-text]{right-text}
\ifdt@sidenotes
\usepackage[quiet]{marginnote}
\usepackage{morefloats} % our side notes are floats that eat up some of TeX's capacity
% The following handles various environments that don't support marginpar.
% We keep a flag for each of them, and whenever any of the flags
% is set, \sidenote uses \marginnote instead of \marginpar.
% Are we in a footnote?
\newbool{dt@infootnote}\boolfalse{dt@infootnote}
\let\dt@old@footnote=\footnote
\renewcommand{\footnote}[1]{{\booltrue{dt@infootnote}\dt@old@footnote{#1}\boolfalse{dt@infootnote}}}
% Are we in a tabular?
\newbool{dt@intabular}\boolfalse{dt@intabular}
\BeforeBeginEnvironment{tabular}{\booltrue{dt@intabular}}
\AfterEndEnvironment{tabular}{\boolfalse{dt@intabular}}
% Are we in a minipage?
\newbool{dt@inminipage}\boolfalse{dt@inminipage}
\BeforeBeginEnvironment{minipage}{\booltrue{dt@inminipage}}
\AfterEndEnvironment{minipage}{\boolfalse{dt@inminipage}}
% Are we in a @float or @dblfloat environment? (This usually includes figure and table environments, but we keep them explicitly below, in case they're redefined to not use @float/@dblfloat)
\newbool{dt@in@float}\boolfalse{dt@in@float}
%\BeforeBeginEnvironment{@float}{\booltrue{dt@in@float}}
%\BeforeBeginEnvironment{@xfloat}{\booltrue{dt@in@float}}
%\AfterEndEnvironment{@float}{\boolfalse{dt@in@float}}
\xpretocmd{\@xfloat}{\booltrue{dt@in@float}}{}{}
\xapptocmd{\end@float}{\boolfalse{dt@in@float}}{}{}
\newbool{dt@in@dblfloat}\boolfalse{dt@in@dblfloat}
%\BeforeBeginEnvironment{@dblfloat}{\booltrue{dt@in@dblfloat}}
%\AfterEndEnvironment{@dblfloat}{\boolfalse{dt@in@dblfloat}}
% Are we in a figure or figure*?
\newbool{dt@infigure}\boolfalse{dt@infigure}
%\BeforeBeginEnvironment{figure}{\booltrue{dt@infigure}}
%\AfterEndEnvironment{figure}{\boolfalse{dt@infigure}}
%\BeforeBeginEnvironment{figure*}{\booltrue{dt@infigure}}
%\AfterEndEnvironment{figure*}{\boolfalse{dt@infigure}}
% Are we in a table?
\newbool{dt@intable}\boolfalse{dt@intable}
%\BeforeBeginEnvironment{table}{\booltrue{dt@intable}}
%\AfterEndEnvironment{table}{\boolfalse{dt@intable}}
% Are we in a \maketitle{}?
\newbool{dt@inmaketitle}\boolfalse{dt@inmaketitle}
\xpretocmd{\maketitle}{\booltrue{dt@inmaketitle}}{}{}
\xapptocmd{\maketitle}{\boolfalse{dt@inmaketitle}}{}{}
% Are we in a top float or a bottom float? (Based on code from fancyhdr)
\let\dt@old@makecol\@makecol
\def\@makecol{\let\dt@topfloat\@toplist\let\dt@botfloat\@botlist\dt@old@makecol}
\def\ifdt@intopfloat#1#2{\ifx\dt@topfloat\empty #2\else #1\fi}
\def\ifdt@inbotfloat#1#2{\ifx\dt@botfloat\empty #2\else #1\fi}
% Are we in a 'framed' environment of the 'framed' package?
\newbool{dt@inframed}\boolfalse{dt@inframed}
\AtBeginDocument{%
\xpretocmd{\MakeFramed}{\booltrue{dt@inframed}}{}{}%
\xapptocmd{\endMakeFramed}{\boolfalse{dt@inframed}}{}{}%
}
% Are we in an 'algorithm' environment of the 'algorithm' package?
\newbool{dt@inalgorithm}\boolfalse{dt@inalgorithm}
\AtBeginDocument{%
\BeforeBeginEnvironment{algorithm}{\booltrue{dt@inalgorithm}}
\AfterEndEnvironment{algorithm}{\boolfalse{dt@inalgorithm}}
}
\newcommand{\sidenote}{%
% Convert top/bottom float detection to regular "if" so it will work reliably in the following.
\newif\ifdt@xinbotfloat \ifdt@inbotfloat\dt@xinbotfloatfalse\dt@xinbotfloattrue%
\newif\ifdt@xintopfloat \ifdt@intopfloat\dt@xintopfloatfalse\dt@xintopfloattrue%
%
% Create either a \marginpar if it will work, otherwise a \marginnote
\ifthenelse{\boolean{mmode} \OR \boolean{inner} \OR \boolean{dt@infootnote} \OR \boolean{dt@intabular} \OR \boolean{dt@in@float} \OR \boolean{dt@in@dblfloat} \OR \boolean{dt@infigure} \OR \boolean{dt@intable} \OR \boolean{dt@inmaketitle} \OR \boolean{dt@inminipage} \OR \boolean{dt@xintopfloat} \OR \boolean{dt@xinbotfloat} \OR \boolean{dt@inframed} \OR \not{\boolean{dt@marginpars}} \OR \boolean{dt@inalgorithm}}%
{\marginnote}% \marginnote will then consume the [left-text]{right-text} arguments that follow \sidenote
{\marginpar}% \marginpar will then consume the [left-text]{right-text} arguments that follow \sidenote
}
% Silence superfluous ``Marginpar on page ... moved'' warnings
\usepackage{silence}
\WarningFilter*{latex}{Marginpar on page \thepage\space moved}
\else%dt@sidenotes
\newcommand{\sidenote}[2][]{}
\fi%dt@sidenotes
% Define the \dt@colorize command:
% \dt@colorize{text} colors in dt@color (only if dt@colornotes is true)
% \dt@colorize[magenta]{text} colors in magenta (only if dt@colornotes is true)
\ifdt@colornotes
\usepackage{xcolor}
\definecolor{dt@notecolor}{rgb}{0.7,0,0}
\newcommand{\dt@colorize}[1][dt@notecolor]{\color{#1}}
\else
\newcommand{\dt@colorize}[1][]{}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define:
% \dtnote[author][color]{text} command for nicely formatted author notes (can be disabled by notes=false)..
% \dtcolornote[author]{color}{text} is similar but also lets you set the color.
% Also define \XXX[text], which yields an error if notes are disabled.
\usepackage{amssymb}
\usepackage{pifont} % for \ding{51}
\usepackage{relsize}
\newcommand{\dt@rendernote}[2]{% \dt@rendernote{color}{text} -- render inline note in designated style
{ \dt@colorize[#1]\smaller\sffamily\bfseries\boldmath[#2] }%
}
\newcommand{\dt@invisibletiny}[1]{% % \dt@invisibletiny[foo] puts foo in the PDF in invisible, tiny that can still searched in PDF
\ifpdf{\tiny\makebox[1pt][c]{\pdfliteral page{q 3 Tr}#1\pdfliteral page{Q}}}\fi%
}
\ifdt@notes
\newbool{dt@nextnoteislater} % Is the next \dtcolornote preceded by a \later?
\boolfalse{dt@nextnoteislater}
\newcommand{\later}{\booltrue{dt@nextnoteislater}\ignorespaces}
\newbool{dt@nextnoteisdone} % Is the next \dtcolornote preceded by a \done?
\boolfalse{dt@nextnoteisdone}
\newcommand{\done}{\booltrue{dt@nextnoteisdone}\ignorespaces}
\newbool{dt@inlinenote}
\newcommand{\dtcolornote}[3][]{% \dtcolornote[authorname]{color}{text} -- add an inline note with mark at margin
% Is the current note supposed to put anything inline (inside the text)?
\ifthenelse{ \( \boolean{dt@later} \OR \NOT \boolean{dt@nextnoteislater} \) \AND \( \boolean{dt@done} \OR \NOT \boolean{dt@nextnoteisdone} \) }{\booltrue{dt@inlinenote}}{\boolfalse{dt@inlinenote}}%
\ifbool{dt@inlinenote}{ \mbox{} }{}%
% Put a mark in the margins:
\sidenote{\dt@colorize[#2]\centering\normalfont\footnotesize%
\ifthenelse{\boolean{dt@nextnoteislater}}{$\diamondsuit$}{% diamondsuit in margin for later
\ifthenelse{\boolean{dt@nextnoteisdone}}{\ding{51}}{% vee checkmark for done
$\bigstar$}}% star for regular notes
\dt@invisibletiny{\textbackslash{}NOTE} % add invisible "\NOTE" text that can be searched in PDF
}
% Emit the inline part:
\ifbool{dt@inlinenote}{%
\ifmmode\expandafter\mbox\fi{%
\ifthenelse{\equal{#1}{}}{%
\dt@rendernote{#2}{\ignorespaces #3}% anonymous author comment
}{%
\dt@rendernote{#2}{\ignorespaces #3{\mdseries\itshape~---\ignorespaces#1}}% named author comment
}%
}%
}{}%
% Turn off flags that were supposed to affect only one note
\boolfalse{dt@nextnoteislater}%
\boolfalse{dt@nextnoteisdone}%
% Absorb subsequent spaces, to avoid a double space if the inline part is turned off
\ifbool{dt@inlinenote}{}{\ignorespaces}%
}
\newcommand{\dtnote}[2][]{% \dtnote[authorname]{text} (color is fixed)
\dtcolornote[#1]{dt@notecolor}{#2}%
}
\else
% Define empty versions of note commands.
% We use \ignorespaces to avoid a double space in "before \dtcolornote{red}{note} after" rendered as "before after"
\newcommand{\dtcolornote}[3][]{\ignorespaces}
\newcommand{\dtnote}[2][]{\ignorespaces}
\newcommand{\later}{\ignorespaces}
\newcommand{\done}{\ignorespaces}
\fi%dt@notes
\ifthenelse{\boolean{dt@notes} \OR \boolean{dt@xxxanyway}}{
\newcommand{\XXX}[1][XXX]{% \XXX or \XXX[text] -- a note that cannot be ignored by setting notes=false
% Triangle in margin, and invisible "\NOTE\XXX" text that can be searched in PDF
\sidenote[\mbox{\dt@colorize\centering\normalfont\Large$\rhd$\hskip-0.6em$\blacktriangleright$}\dt@invisibletiny{\textbackslash{}NOTE\textbackslash{}XXX}]%
{\mbox{\dt@colorize\centering\normalfont\Large$\lhd$\hskip-0.6em$\blacktriangleleft $}\dt@invisibletiny{\textbackslash{}NOTE\textbackslash{}XXX}}%
\ifmmode%
\;\mbox{\dt@rendernote{dt@notecolor}{#1}}\;%
\else
\mbox{}{\dt@rendernote{dt@notecolor}{#1}}%
\fi
}
}{
% Don't let \XXX be silently turned off.
\newcommand{\XXX}[1][XXX]{%
\@latex@error{You have an "\\XXX" command but you said "notes=false" to dtrt. This won't end well, aborting. Use "notes=xxx" instead to override.}\@ehd%
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Write "DRAFT" and time of compilation at page bottoms (larger on first page):
% To include the username (optional), run:
% latex "\def\OSUserName{`whoami`}\input MYFILE.tex"
\ifdt@draft
\usepackage{scrtime}
\usepackage{prelim2e}
\newcommand{\dt@datetime}{\the\year-\ifthenelse{\the\month < 10}{0}{}\the\month-\ifthenelse{\the\day < 10}{0}{}\the\day{} \thistime}
\renewcommand{\PrelimText}{%
\dt@colorize\normalfont\sffamily \ifthenelse{\equal{\thepage}{1}}{\bfseries}{\tiny}%
[\dt@draftfootnote]%
}
\fi%dt@draft
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define \ignore which puts an "ignored" mark and optional comment in margin (unless already defined):
\ifdt@notes%
\ifdt@showignore%
\newcommand{\dtignore}[2][]{% first argument is optional
\sidenote[\dt@colorize\centering{\normalfont\Large\boldmath \mbox{}\lower1ex\hbox{$\looparrowright$}}\\ \scriptsize\textsc{#1}]
{\dt@colorize\centering{\normalfont\Large\boldmath \mbox{}\lower1ex\hbox{$\looparrowleft $}}\\ \scriptsize\textsc{#1}}%
}
\else%
\newcommand{\dtignore}[2][]{\ignorespaces}%
\fi
\else%
\newcommand{\dtignore}[2][]{\ignorespaces}%
\fi%
% if \ignore not defined by anyone, make it an alias to \dtignore
\AtBeginDocument{%
\@ifundefined{ignore}{\let\ignore=\dtignore}{}%
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define \parhead (paragraph-level headings):
% First, a macro for adding a period at the end of a string if it doesn't already end with a punctuation mark (based on code by Uwe Lueck at http://tug.org/mailman/htdig/texhax/2010-January/014189.html):
\def\dt@TestPunct#1{\ifx\dt@TestPunct#1\dt@TestPunct\else\dt@Puncttrue\fi}
\def\dt@TestDot#1.\dt@TestEnd#2\dt@TestStop{\dt@TestPunct{#2}}
\def\dt@TestQuestM#1?\dt@TestEnd#2\dt@TestStop{\dt@TestPunct{#2}}
\def\dt@TestExclaM#1!\dt@TestEnd#2\dt@TestStop{\dt@TestPunct{#2}}
\def\dt@TestColonM#1:\dt@TestEnd#2\dt@TestStop{\dt@TestPunct{#2}}
\newif\ifdt@Punct
\def\dt@MaybeAddPunct#1{%
\dt@Punctfalse%
\dt@TestDot#1\dt@TestEnd.\dt@TestEnd\dt@TestStop%
\dt@TestQuestM#1\dt@TestEnd?\dt@TestEnd\dt@TestStop%
\dt@TestExclaM#1\dt@TestEnd!\dt@TestEnd\dt@TestStop%
\dt@TestColonM#1\dt@TestEnd:\dt@TestEnd\dt@TestStop%
#1\ifdt@Punct \else .\fi%
}
% Macros for ignoring spaces and paragraphs. The first ignores all spaces and implicit paragraphs (empty separation line), the second also explicit \par.
% (Source: http://tex.stackexchange.com/questions/23100/looking-for-an-ignorespacesandpars)
\def\dt@ignorespacesandimplicitepars{%
\begingroup
\catcode13=10
\@ifnextchar\relax
{\endgroup}%
{\endgroup}%
}
\def\dt@ignorespacesandallpars{%
\begingroup
\catcode13=10
\@ifnextchar\par
{\endgroup\expandafter\ignorespacesandallpars\@gobble}%
{\endgroup}%
}
% \parheadnoperiod{text} generates a parhead without any extra punctuation. Useful, e.g., if you put a footnote at the end of your parhead text.
\newcommand{\parheadnoperiod}[1]{\smallskip \noindent {\bfseries\boldmath\ignorespaces {#1}}\hskip 0.9em plus 0.3em minus 0.3em \dt@ignorespacesandimplicitepars}
% \parhead{text} automatically appends a period if the text doesn't already end with punctuation. You should usually use this one.
\newcommand{\parhead}[1]{\parheadnoperiod{\dt@MaybeAddPunct{#1}}\dt@ignorespacesandimplicitepars}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define \footnotesymb{symbol}{text} -- footnote with explicitly given symbol
% (can be empty}
\newcommand{\footnotesymb}[2]{%
\def\@tempa{#1}%
\ifx\@tempa\@empty%
\let\dt@oldmakefntext=\@makefntext
\long\def\@makefntext##1{\parindent 1em\noindent##1}%
{\unrestored@protected@xdef\@thefnmark{}}%
\@footnotetext{#2}%
\let\@makefntext=\dt@oldmakefntext
\else
{\unrestored@protected@xdef\@thefnmark{#1}}%
\@footnotemark%
\@footnotetext{#2}%
\fi
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define an "\emailref{user@host}" command for creating hyperlinked email addresses without rendering the "mailto://",
% and "\httpref{user@host}" command for creating hyperlinked URLs without rendering the "http://".
\ifdt@camera
% We're in camera=true mode, so don't load hyperref. If it's already loaded, use it. Otherwise use lightweight versions.
\AtBeginDocument{
\ifthenelse{\isundefined{\href} \OR \isundefined{\nolinkurl}}{%
\newcommand{\emailref}[1]{#1}%
\newcommand{\httpref}[1]{\texttt{#1}}%
}{%
\newcommand{\emailref}[1]{\href{mailto:#1}{\nolinkurl{#1}}}%
\newcommand{\httpref}[1]{\href{http://#1}{\nolinkurl{#1}}}%
}
}
\else
\newcommand{\emailref}[1]{\href{mailto:#1}{\nolinkurl{#1}}}
\newcommand{\httpref}[1]{\href{http://#1}{\nolinkurl{#1}}}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% If HyperRef is loaded, patch its \autoref so that if \sectionautorefname etc. are
% redefined to \S then they won't be followed by a space.
\@ifundefined{test@reftype}{}{
\let\dt@oldtest@reftype=\test@reftype
\def\test@reftype#1.#2\\{%
\dt@oldtest@reftype#1.#2\\%
\ifthenelse{\equal{\@currentHtag}{\S~}} {\def\@currentHtag{\S}} {}%
}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Page heads:
%
% If head=chaptersection then add chapter and section name at the top of every page.
% By default the chapter and section name as shown on one line.
% If there's no room for both, you can move the section to its own line as follows:
% \twolinehdrsection
% \section{Long section name}
%
% If head=sectionsubsection then add section and subsection name at the top of every page.
% By default the section and subsection name as shown on one line.
% If there's no room for both, you can move the subsection to its own line as follows:
% \twolinehdrsubsection
% \subsection{Long subsection name}
\ifthenelse{\equal{\dt@head}{}}{}{
\usepackage{fancyhdr}\pagestyle{fancy}\headsep=3.9ex
\voffset=-0.38in % shift up
\headheight=26.4542pt % otherwise will be enlarged halfway through document
\def\dt@thechapterhead{}
\def\dt@thesectionhead{}
\def\dt@thesectionheadprefix@pending{}
\def\dt@thesubsectionhead{}
\def\dt@thesubsectionheadprefix@pending{}
\renewcommand{\sectionmark}[1]{
\def\dt@thesectionhead{\thesection.\ #1}
\def\dt@thesubsectionhead{}
\def\dt@thesubsectionheadprefix{}
\markheads
}
\newcommand{\twolinehdrsection}{
\def\dt@thesectionheadprefix@pending{\\ \mbox{}}
}
\renewcommand{\subsectionmark}[1]{
\def\dt@thesubsectionhead{\thesubsection.\ #1}
\let\dt@thesubsectionheadprefix=\dt@thesubsectionheadprefix@pending
\def\dt@thesubsectionheadprefix@pending{}
\markheads
}
\newcommand{\twolinehdrsubsection}{
\def\dt@thesubsectionheadprefix@pending{\\ \mbox{}}
}
}
% Specific to head=chaptersection:
\ifthenelse{\equal{\dt@head}{chaptersection}}{
\def\markheads{\markboth{}{\small \dt@thechapterhead \dt@thesectionheadprefix \hfill \dt@thesectionhead}}
\renewcommand{\chaptermark}[1]{
\def\dt@thechapterhead{\thechapter.\ #1}
\def\dt@thesectionhead{}
\def\dt@thesectionheadprefix{}
\def\dt@thesubsectionhead{}
\def\dt@thesubectionheadprefix{}
\markheads
}
\newcommand{\chapterstarmark}[1]{
\def\dt@thechapterhead{#1}
\def\dt@thesectionhead{}
\def\dt@thesectionheadprefix{}
\def\dt@thesubsectionhead{}
\def\dt@thesubectionheadprefix{}
\markheads
}
}{}
% Specific to head=sectionsubsection:
\ifthenelse{\equal{\dt@head}{sectionsubsection}}{
\def\markheads{\markboth{}{\small \dt@thesectionhead \dt@thesubsectionheadprefix \hfill \dt@thesubsectionhead}}
}{}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Teach llncs about dates.
% The following code is copied from llncs, except the strongly indented lines.
\ifdt@llncsdate
\ifdt@llncs
\def\@maketitle{\newpage
\markboth{}{}%
\def\lastand{\ifnum\value{@inst}=2\relax
\unskip{} \andname\
\else
\unskip \lastandname\
\fi}%
\def\and{\stepcounter{@auth}\relax
\ifnum\value{@auth}=\value{@inst}%
\lastand
\else
\unskip,
\fi}%
\begin{center}%
\let\newline\\
{\Large \bfseries\boldmath
\pretolerance=10000
\@title \par}\vskip .8cm
\if!\@subtitle!\else {\large \bfseries\boldmath
\vskip -.65cm
\pretolerance=10000
\@subtitle \par}\vskip .8cm\fi
\setbox0=\vbox{\setcounter{@auth}{1}\def\and{\stepcounter{@auth}}%
\def\thanks##1{}\@author}%
\global\value{@inst}=\value{@auth}%
\global\value{auco}=\value{@auth}%
\setcounter{@auth}{1}%
{\lineskip .5em
\noindent\ignorespaces
\@author\vskip.35cm}%
{\small\institutename}
{\ifthenelse{\equal{\@date}{}}{}{\vskip 2em\large%
\vskip -.65cm%
\pretolerance=10000%
\normalsize \@date \par}\vskip 1em}%
\end{center}%
}
\fi%dt@llncs
\fi%dt@llncsdate
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For the LLNCS class, add a QED square at the end of llncs proof environments.
\ifdt@llncsqed
\ifdt@llncs
\let\oldendproof=\endproof
\renewcommand{\endproof}{\qed\oldendproof}
\fi%dt@llncs
\fi%dt@llncsqed
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% For the LLNCS class, make \subsubsection generate captions with subsubsection
% numbers and followed by linebreaks. (Default is similar to our \parhead.)
\ifdt@llncssubsub
\ifdt@llncs
\renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-4\p@ \@plus -2\p@ \@minus -2\p@}%
{3\p@ \@plus 1\p@ \@minus 1\p@}%
{\normalfont\normalsize\bfseries\boldmath
\rightskip=\z@ \@plus 8em\pretolerance=10000 }}
\setcounter{secnumdepth}{3}
\fi%dt@llncs
\fi%dt@llncssubsub
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Add a horizontal line ("rule") above figure captions.
% Tested with llncs, should work with most classes.
\@ifclassloaded{sigplanconf}{\dt@captionrulefalse}{} % sigplanconf already has caption rules
\ifdt@captionrule
\xpretocmd{\@makecaption}{
\hrule width \hsize height .33pt
\vspace{4pt}
\@ifundefined{abovecaptionskip}{}{%
\setlength\abovecaptionskip{0pt}%
}
}{}{}
\fi
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Defines the "nestedbar" environment, which indents the text and puts
% a vertical bar to its left (with little corners at top and bottom).
% Useful for nested theorem/proof environments..
% This is a subtler version of the 'leftbar'/'oframed' environment from package 'framed'.
% Copies some code from 'framed', to add a degree of freedom.
% http://www.ctan.org/pkg/framed
\usepackage{framed}
% \dt@CustomFBox tweaks the \CustomFBox of 'framed' by adding
% parameter: length of the top/bottom rules, and space between
% left rule and text.
% Parameter #1 is inserted (in vmode) right after the top rule
% (useful for a title or assignments), and #2 is similar, but
% inserted right above the bottom rule.
% The thicknesses of the top, bottom, left, and right rules are
% given as parameters #3,#4,#5,#6 respectively. They should be
% \fboxrule or \z@ (or some other thickness).
% Argument #7 is the length of the bottom and right rules.
% is the width
% The text argument is #8.
% An instance of this can be used for the frame of \fcolorbox by
% locally defining \fbox before \fcolorbox; e.g.,
% \def\fbox{\CustomFBox{}{}\z@\z@\fboxrule\fboxrule}\fcolorbox
\long\def\dt@CustomFBox#1#2#3#4#5#6#7#8#9{%
\leavevmode\begingroup
\setbox\@tempboxa\hbox{%
\color@begingroup
\kern\fboxsep{#9}\kern\fboxsep
\color@endgroup}%
\hbox{%
% Here we calculate and shift for the depth. Done in
% a group because one of the arguments might be \@tempdima
% (we could use \dimexpr instead without grouping).
\begingroup