-
Notifications
You must be signed in to change notification settings - Fork 37
/
tufte-common.def
1872 lines (1584 loc) · 65.2 KB
/
tufte-common.def
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
%%
%% This file contains the code that's common to the Tufte-LaTeX document classes.
%%
\ProvidesFile{tufte-common.def}[2009/12/11 v3.5.0 Common code for the Tufte-LaTeX styles]
%%
% The `xkeyval' package simplifies the user interface for the document class options
\RequirePackage{xkeyval}
%%
% We use the `xifthen' package to handle our package option switches
\RequirePackage{xifthen}
%%
% Define some shortcut macros for error/warning/info logging.
\newcommand{\TufteWarning}[1]{\ClassWarning{\@tufte@pkgname}{#1}}
\newcommand{\TufteWarningNL}[1]{\ClassWarningNoLine{\@tufte@pkgname}{#1}}
\newcommand{\TufteInfo}[1]{\ClassInfo{\@tufte@pkgname}{#1}}
\newcommand{\TufteInfoNL}[1]{\ClassInfo{\@tufte@pkgname}{#1\@gobble}}
\newcommand{\TufteDebugInfo}[1]{\ifthenelse{\boolean{@tufte@debug}}{\TufteInfo{#1}}{}}
\newcommand{\TufteDebugInfoNL}[1]{\ifthenelse{\boolean{@tufte@debug}}{\TufteInfoNL{#1}}{}}
\newcommand{\TufteError}[2]{\ClassError{\@tufte@pkgname}{#1}{#2}}
%%
% `debug' option -- provides more information in the .log file for use in
% troubleshooting problems
\newboolean{@tufte@debug}
\DeclareOptionX[tufte]<common>{debug}{\setboolean{@tufte@debug}{true}}
%%
% `nofonts' option -- doesn't load any fonts
% `fonts' option -- tries to load fonts
\newboolean{@tufte@loadfonts}\setboolean{@tufte@loadfonts}{true}
\DeclareOptionX[tufte]<common>{fonts}{\setboolean{@tufte@loadfonts}{true}}
\DeclareOptionX[tufte]<common>{nofonts}{\setboolean{@tufte@loadfonts}{false}}
%%
% `nols' option -- doesn't configure letterspacing
% `ls' option -- configures letterspacing
\newboolean{@tufte@letterspace}\setboolean{@tufte@letterspace}{true}
\DeclareOptionX[tufte]<common>{ls}{\setboolean{@tufte@letterspace}{true}}
\DeclareOptionX[tufte]<common>{nols}{\setboolean{@tufte@letterspace}{false}}
%%
% `titlepage' option -- creates a full title page with \maketitle
\newboolean{@tufte@titlepage}
\DeclareOptionX[tufte]<common>{titlepage}{\setboolean{@tufte@titlepage}{true}}
\DeclareOptionX[tufte]<common>{notitlepage}{\setboolean{@tufte@titlepage}{false}}
%%
% `a4paper' option
\newboolean{@tufte@afourpaper}
\DeclareOptionX[tufte]<common>{a4paper}{\setboolean{@tufte@afourpaper}{true}}
%%
% `b5paper' option
\newboolean{@tufte@bfivepaper}
\DeclareOptionX[tufte]<common>{b5paper}{\setboolean{@tufte@bfivepaper}{true}}
%%
% `sfsidenotes' option -- typesets sidenotes in sans serif typeface
\newboolean{@tufte@sfsidenotes}
\DeclareOptionX[tufte]<common>{sfsidenotes}{\setboolean{@tufte@sfsidenotes}{true}}
%%
% `symmetric' option -- puts marginpar space to the outside edge of the page
% Note: this option forces the twoside option (see the .cls files)
\newboolean{@tufte@symmetric}
\DeclareOptionX[tufte]<common>{symmetric}{
\setboolean{@tufte@symmetric}{true}
\TufteInfoNL{The `symmetric' option implies `twoside'}
\ExecuteOptionsX[tufte]<common>{twoside}
}
%%
% `twoside' option -- alternates running heads
\newboolean{@tufte@twoside}
\DeclareOptionX[tufte]<common>{twoside}{%
\setboolean{@tufte@twoside}{true}
\TufteInfoNL{Passing the `twoside' option to the `\@tufte@class' class}
\PassOptionsToClass{twoside}{\@tufte@class}
}
%%
% `notoc' option -- suppresses the Tufte-style table of contents
\newboolean{@tufte@toc}
\setboolean{@tufte@toc}{true}
\DeclareOptionX[tufte]<common>{notoc}{\setboolean{@tufte@toc}{false}}
\DeclareOptionX[tufte]<common>{toc}{\setboolean{@tufte@toc}{true}}
%%
% `justified' option -- uses fully justified text (flush left and flush
% right) instead of ragged right.
\newboolean{@tufte@justified}
\DeclareOptionX[tufte]<common>{justified}{\setboolean{@tufte@justified}{true}}
%%
% `bidi' option -- loads the bidi package for bi-directional text
\newboolean{@tufte@loadbidi}
\DeclareOptionX[tufte]<common>{bidi}{\setboolean{@tufte@loadbidi}{true}}
\DeclareOptionX[tufte]<common>{nobidi}{\setboolean{@tufte@loadbidi}{false}}
%%
% `nohyper' option -- suppresses loading of the hyperref package
\newboolean{@tufte@loadhyper}
\setboolean{@tufte@loadhyper}{true}
\DeclareOptionX[tufte]<common>{hyper}{\setboolean{@tufte@loadhyper}{true}}
\DeclareOptionX[tufte]<common>{nohyper}{\setboolean{@tufte@loadhyper}{false}}
%%
% `sidenote', `marginnote', `caption', `citation', `marginals' options
% Each allows one of {justified,raggedleft,raggedright,raggedouter,auto}.
\newcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}
\define@choicekey*+[tufte]{common}{sidenote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
\ifcase\@tufte@kvnum\relax
\renewcommand*{\@tufte@sidenote@justification}{\justifying}% justified
\or
\renewcommand*{\@tufte@sidenote@justification}{\RaggedLeft}% ragged left
\or
\renewcommand*{\@tufte@sidenote@justification}{\RaggedRight}% ragged right
\or
\renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
\or
\renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
\fi
}{%
\TufteWarningNL{Invalid option `#1' for sidenote key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
\renewcommand*{\@tufte@sidenote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
}
\newcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}
\define@choicekey*+[tufte]{common}{marginnote}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
\ifcase\@tufte@kvnum\relax
\renewcommand*{\@tufte@marginnote@justification}{\justifying}% justified
\or
\renewcommand*{\@tufte@marginnote@justification}{\RaggedLeft}% ragged left
\or
\renewcommand*{\@tufte@marginnote@justification}{\RaggedRight}% ragged right
\or
\renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
\or
\renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
\fi
}{%
\TufteWarningNL{Invalid option `#1' for marginnote key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
\renewcommand*{\@tufte@marginnote@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
}
\newcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}
\define@choicekey*+[tufte]{common}{caption}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
\ifcase\@tufte@kvnum\relax
\renewcommand*{\@tufte@caption@justification}{\justifying}% justified
\or
\renewcommand*{\@tufte@caption@justification}{\RaggedLeft}% ragged left
\or
\renewcommand*{\@tufte@caption@justification}{\RaggedRight}% ragged right
\or
\renewcommand*{\@tufte@caption@justification}{\@tufte@justification@caption@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
\or
\renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
\fi
}{%
\TufteWarningNL{Invalid option `#1' for caption key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
\renewcommand*{\@tufte@caption@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
}
\newcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}
\define@choicekey*+[tufte]{common}{citation}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
\ifcase\@tufte@kvnum\relax
\renewcommand*{\@tufte@citation@justification}{\justifying}% justified
\or
\renewcommand*{\@tufte@citation@justification}{\RaggedLeft}% ragged left
\or
\renewcommand*{\@tufte@citation@justification}{\RaggedRight}% ragged right
\or
\renewcommand*{\@tufte@citation@justification}{\@tufte@justification@outer}% ragged outer (flush right on verso pages, flush left on recto pages)
\or
\renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
\fi
}{%
\TufteWarningNL{Invalid option `#1' for citation key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
\renewcommand*{\@tufte@citation@justification}{\@tufte@justification@autodetect}% autodetects best justification mode based on all class options
}
% The ``marginals'' key simultaneously sets the same justification for all marginal material
\define@choicekey*+[tufte]{common}{marginals}[\@tufte@kvtext\@tufte@kvnum]{justified,raggedleft,raggedright,raggedouter,auto}[auto]{%
\ifcase\@tufte@kvnum\relax
\ExecuteOptionsX[tufte]<common>{citation=justified,sidenote=justified,caption=justified,marginnote=justified}% justified
\or
\ExecuteOptionsX[tufte]<common>{citation=raggedleft,sidenote=raggedleft,caption=raggedleft,marginnote=raggedleft}% ragged left
\or
\ExecuteOptionsX[tufte]<common>{citation=raggedright,sidenote=raggedright,caption=raggedright,marginnote=raggedright}% ragged right
\or
\ExecuteOptionsX[tufte]<common>{citation=raggedouter,sidenote=raggedouter,caption=raggedouter,marginnote=raggedouter}% ragged outer (flush right on verso pages, flush left on recto pages)
\or
\ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options
\fi
}{%
\TufteWarningNL{Invalid option `#1' for marginals key.\MessageBreak Must be one of: justified, raggedleft,\MessageBreak raggedright, raggedouter, auto}
\ExecuteOptionsX[tufte]<common>{citation=auto,sidenote=auto,caption=auto,marginnote=auto}% autodetects best justification mode based on all class options
}
%%
% Unsupported options
\newcommand{\@tufte@unsupported@option}[1]{\TufteWarningNL{Option `#1' is not supported -- \MessageBreak ignoring option}\OptionNotUsed}
\DeclareOptionX[tufte]<common>{10pt}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{11pt}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{12pt}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{a5paper}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{executivepaper}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{legalpaper}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{landscape}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{onecolumn}{\@tufte@unsupported@option{\CurrentOption}}
\DeclareOptionX[tufte]<common>{twocolumn}{\@tufte@unsupported@option{\CurrentOption}}
%%
% Default `book' and `handout' options
\ifthenelse{\equal{\@tufte@pkgname}{tufte-book}}
{\ExecuteOptionsX[tufte]<common>{titlepage}}
{\ExecuteOptionsX[tufte]<common>{notitlepage}}
\DeclareOptionX*{%
\TufteInfoNL{Passing \CurrentOption\space to the `\@tufte@class' class.}%
\PassOptionsToClass{\CurrentOption}{\@tufte@class}%
}
\ProcessOptionsX*[tufte]<common>\relax
%%
% Load the appropriate base class
\TufteInfoNL{Loading the base class `\@tufte@class'}
\LoadClass{\@tufte@class}
%%
% Detect whether we're in two-side mode or not. (Used to set up running
% heads later.)
\ifthenelse{\boolean{@twoside}}
{\setboolean{@tufte@twoside}{true}}
{}
%%
% Detect if we're using pdfLaTeX
\newboolean{@tufte@pdf}
\IfFileExists{ifpdf.sty}{%
\RequirePackage{ifpdf}
\ifthenelse{\boolean{pdf}}
{\setboolean{@tufte@pdf}{true}}
{\setboolean{@tufte@pdf}{false}}
}{% assume we're not using pdfTex?
\setboolean{@tufte@pdf}{false}
}
%%
% Detect if we're using XeLaTeX
\newboolean{@tufte@xetex}
\IfFileExists{ifxetex.sty}{%
\RequirePackage{ifxetex}
\ifthenelse{\boolean{xetex}}
{\setboolean{@tufte@xetex}{true}}
{\setboolean{@tufte@xetex}{false}}
}{% not using xelatex
\setboolean{@tufte@xetex}{false}
}
%%
% Globally sets the length
\newcommand*{\gsetlength}[2]{%
\setlength{#1}{#2}%
\global#1=#1\relax%
}
%%
% Globally sets a boolean
\newcommand*{\gsetboolean}[2]{% based on code from ifthen pkg
\lowercase{\def\@tempa{#2}}%
\@ifundefined{@tempswa\@tempa}%
{\PackageError{ifthen}{You can only set a boolean to `true' or `false'}\@ehc}%
{\@ifundefined{#1\@tempa}%
{\PackageError{ifthen}{Boolean #1 undefined}\@ehc}%
{\global\csname#1\@tempa\endcsname}%
}%
}
%%
% The titlesec and titletoc packages are used to change the style of the
% section headings. These packages should be loaded before the hyperref
% package.
\RequirePackage{titlesec,titletoc}
%%%
%% Loads the hyperref package and sets some default options.
\newcommand{\TufteLoadHyperref}{%
\ifthenelse{\boolean{@tufte@xetex}}
{\RequirePackage[unicode,hyperfootnotes=false,xetex]{hyperref}}
{\RequirePackage[unicode,hyperfootnotes=false]{hyperref}}
\hypersetup{%
pdfborder = {0 0 0},
bookmarksdepth = section,
citecolor = DarkGreen,
linkcolor = DarkBlue,
pagecolor = DarkBlue,
urlcolor = DarkGreen,
}%
}
%%%
%% Load the `hyperref' package.
\ifthenelse{\boolean{@tufte@loadhyper}}{%
\TufteLoadHyperref%
}{% hyperfootnotes override our modifications to the \footnote* and \@footnote* commands.
\PassOptionsToPackage{hyperfootnotes=false}{hyperref}
}
%%
% Set the font sizes and baselines to match Tufte's books
\renewcommand\normalsize{%
\@setfontsize\normalsize\@xpt{14}%
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@
\abovedisplayshortskip \z@ \@plus3\p@
\belowdisplayshortskip 6\p@ \@plus3\p@ \@minus3\p@
\belowdisplayskip \abovedisplayskip
\let\@listi\@listI}
\normalbaselineskip=14pt
\normalsize
\renewcommand\small{%
\@setfontsize\small\@ixpt{12}%
\abovedisplayskip 8.5\p@ \@plus3\p@ \@minus4\p@
\abovedisplayshortskip \z@ \@plus2\p@
\belowdisplayshortskip 4\p@ \@plus2\p@ \@minus2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 4\p@ \@plus2\p@ \@minus2\p@
\parsep 2\p@ \@plus\p@ \@minus\p@
\itemsep \parsep}%
\belowdisplayskip \abovedisplayskip
}
\renewcommand\footnotesize{%
\@setfontsize\footnotesize\@viiipt{10}%
\abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
\abovedisplayshortskip \z@ \@plus\p@
\belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
\def\@listi{\leftmargin\leftmargini
\topsep 3\p@ \@plus\p@ \@minus\p@
\parsep 2\p@ \@plus\p@ \@minus\p@
\itemsep \parsep}%
\belowdisplayskip \abovedisplayskip
}
\renewcommand\scriptsize{\@setfontsize\scriptsize\@viipt\@viiipt}
\renewcommand\tiny{\@setfontsize\tiny\@vpt\@vipt}
\renewcommand\large{\@setfontsize\large\@xipt{15}}
\renewcommand\Large{\@setfontsize\Large\@xiipt{16}}
\renewcommand\LARGE{\@setfontsize\LARGE\@xivpt{18}}
\renewcommand\huge{\@setfontsize\huge\@xxpt{30}}
\renewcommand\Huge{\@setfontsize\Huge{24}{36}}
\setlength\leftmargini {1pc}
\setlength\leftmarginii {1pc}
\setlength\leftmarginiii {1pc}
\setlength\leftmarginiv {1pc}
\setlength\leftmarginv {1pc}
\setlength\leftmarginvi {1pc}
\setlength\labelsep {.5pc}
\setlength\labelwidth {\leftmargini}
\addtolength\labelwidth{-\labelsep}
%%
% \RaggedRight allows hyphenation
\RequirePackage{ragged2e}
\setlength{\RaggedRightRightskip}{\z@ plus 0.08\hsize}
\setlength{\RaggedRightParindent}{0pc}
% Paragraph indentation and separation for normal text
\newcommand{\@tufte@reset@par}{%
\setlength{\RaggedRightParindent}{0pc}%
\setlength{\parindent}{0pc}%
\setlength{\parskip}{0.3pc}%
}
\@tufte@reset@par
% Paragraph indentation and separation for marginal text
\newcommand{\@tufte@margin@par}{%
\setlength{\RaggedRightParindent}{0pc}%
\setlength{\parindent}{0pt}%
\setlength{\parskip}{0.3pc}%
}
%%
% Set page layout geometry
\RequirePackage[letterpaper,left=1in,top=1in,headsep=2\baselineskip,textwidth=26pc,marginparsep=2pc,marginparwidth=12pc,textheight=44\baselineskip,headheight=\baselineskip]{geometry}
\ifthenelse{\boolean{@tufte@afourpaper}}
{\geometry{a4paper,left=24.8mm,top=27.4mm,headsep=2\baselineskip,textwidth=107mm,marginparsep=8.2mm,marginparwidth=49.4mm,textheight=49\baselineskip,headheight=\baselineskip}}
{}
\ifthenelse{\boolean{@tufte@bfivepaper}}
{\geometry{paperwidth=176mm,paperheight=250mm,left=14.66mm,top=13.88mm,textwidth=102.66mm,marginparsep=7.33mm,marginparwidth=36.66mm,textheight=38\baselineskip,includehead}}
{}
\ifthenelse{\boolean{@tufte@symmetric}}
{}
{\geometry{asymmetric}}% forces internal LaTeX `twoside'
%%
% Separation marginpars by a line's worth of space.
\setlength\marginparpush{10pt}
%%
% Font for margin items
\ifthenelse{\boolean{@tufte@sfsidenotes}}
{\newcommand{\@tufte@marginfont}{\normalfont\footnotesize\sffamily}}
{\newcommand{\@tufte@marginfont}{\normalfont\footnotesize}}
\newcommand*{\@tufte@sidenote@font}{\@tufte@marginfont}
\newcommand*{\@tufte@caption@font}{\@tufte@marginfont}
\newcommand*{\@tufte@marginnote@font}{\@tufte@marginfont}
\newcommand*{\@tufte@citation@font}{\@tufte@marginfont}
\newcommand*{\setsidenotefont}[1]{\renewcommand*{\@tufte@sidenote@font}{#1}}
\newcommand*{\setcaptionfont}[1]{\renewcommand*{\@tufte@caption@font}{#1}}
\newcommand*{\setmarginnotefont}[1]{\renewcommand*{\@tufte@marginnote@font}{#1}}
\newcommand*{\setcitationfont}[1]{\renewcommand*{\@tufte@citation@font}{#1}}
%%
% Set the justification baesed on the `justified' class option
\newcommand{\@tufte@justification}{%
\ifthenelse{\boolean{@tufte@justified}}%
{\justifying}%
{\RaggedRight}%
}
%%
% Turn off section numbering
\setcounter{secnumdepth}{-1}
%%
% Tighten up space between displays (e.g., a figure or table) and make symmetric
\setlength\abovedisplayskip{6pt plus 2pt minus 4pt}
\setlength\belowdisplayskip{6pt plus 2pt minus 4pt}
%%
% To implement full-width display environments
\newboolean{@tufte@changepage}
\IfFileExists{changepage.sty}{%
\TufteDebugInfoNL{Found changepage.sty}
\RequirePackage[strict]{changepage}
\setboolean{@tufte@changepage}{true}
}{%
\TufteDebugInfoNL{Found chngpage.sty}
\RequirePackage[strict]{chngpage}
\setboolean{@tufte@changepage}{false}
}
% Write our own aliases for the \checkoddpage and \ifoddpage or \ifcpoddpage commands
\newboolean{@tufte@odd@page}
\setboolean{@tufte@odd@page}{true}
\newcommand*{\@tufte@checkoddpage}{%
\checkoddpage%
\ifthenelse{\boolean{@tufte@changepage}}{%
\ifoddpage%
\setboolean{@tufte@odd@page}{true}%
\else%
\setboolean{@tufte@odd@page}{false}%
\fi%
}{%
\ifcpoddpage%
\setboolean{@tufte@odd@page}{true}%
\else%
\setboolean{@tufte@odd@page}{false}%
\fi%
}%
}
%%
% Compute lengths used for full-width displays
\newlength{\@tufte@overhang}% used by the fullwidth environment and the running heads
\newlength{\@tufte@fullwidth}
\newlength{\@tufte@caption@fill}
\newcommand{\TufteRecalculate}{%
\setlength{\@tufte@overhang}{\marginparwidth}
\addtolength{\@tufte@overhang}{\marginparsep}
\setlength{\@tufte@fullwidth}{\textwidth}
\addtolength{\@tufte@fullwidth}{\marginparsep}
\addtolength{\@tufte@fullwidth}{\marginparwidth}
\setlength{\@tufte@caption@fill}{\textwidth}
\addtolength{\@tufte@caption@fill}{\marginparsep}
}
\AtBeginDocument{\TufteRecalculate}
%%
% Modified \title, \author, and \date commands. These store the
% (footnote-less) values in \plaintitle, \plainauthor, and \thedate, respectively.
\newcommand{\plaintitle}{}% plain-text-only title
\newcommand{\plainauthor}{}% plain-text-only author
\newcommand{\plainpublisher}{}% plain-text-only publisher
\newcommand{\thanklesstitle}{}% full title text minus \thanks{}
\newcommand{\thanklessauthor}{}% full author text minus \thanks{}
\newcommand{\thanklesspublisher}{}% full publisher minus \thanks{}
\newcommand{\@publisher}{}% full publisher with \thanks{}
\newcommand{\thedate}{\today}
% TODO Fix it so that \thanks is not spaced out (with `soul') and can be
% used in \maketitle when the `sfsidenotes' option is provided.
\renewcommand{\thanks}[1]{\NoCaseChange{\footnote{#1}}}
\renewcommand{\title}[2][]{%
\gdef\@title{#2}%
\begingroup%
% TODO store contents of \thanks command
\renewcommand{\thanks}[1]{}% swallow \thanks contents
\protected@xdef\thanklesstitle{#2}%
\endgroup%
\ifthenelse{\isempty{#1}}%
{\renewcommand{\plaintitle}{\thanklesstitle}}% use thankless title
{\renewcommand{\plaintitle}{#1}}% use provided plain-text title
\@ifpackageloaded{hyperref}{\hypersetup{pdftitle={\plaintitle}}}{}% set the PDF metadata title
}
\def\@author{}% default author is empty (suppresses LaTeX's ``no author'' warning)
\renewcommand*{\author}[2][]{%
\gdef\@author{#2}%
\begingroup%
% TODO store contents of \thanks command
\renewcommand{\thanks}[1]{}% swallow \thanks contents
\protected@xdef\thanklessauthor{#2}%
\endgroup%
\ifthenelse{\isempty{#1}}
{\renewcommand{\plainauthor}{\thanklessauthor}}% use thankless author
{\renewcommand{\plainauthor}{#1}}% use provided plain-text author
\@ifpackageloaded{hyperref}{\hypersetup{pdfauthor={\plainauthor}}}{}% set the PDF metadata author
}
\renewcommand*{\date}[1]{%
\gdef\@date{#1}%
\begingroup%
% TODO store contents of \thanks command
\renewcommand{\thanks}[1]{}% swallow \thanks contents
\protected@xdef\thedate{#1}%
\endgroup%
}
%%
% Provides a \publisher command to set the publisher
\newcommand{\publisher}[2][]{%
\gdef\@publisher{#2}%
\begingroup%
\renewcommand{\thanks}[1]{}% swallow \thanks contents
\protected@xdef\thanklesspublisher{#2}%
\endgroup%
\ifthenelse{\isempty{#1}}
{\renewcommand{\plainpublisher}{\thanklesspublisher}}% use thankless publisher
{\renewcommand{\plainpublisher}{#1}}% use provided plain-text publisher
}
% TODO: Test \hypersetup{pdfauthor,pdftitle} with DVI and XeTeX
%%
% Require paralist package for tighter lists
\RequirePackage{paralist}
% Add rightmargin to compactenum
\def\@compactenum@{%
\expandafter\list\csname label\@enumctr\endcsname{%
\usecounter{\@enumctr}%
\rightmargin=2em% added this
\parsep\plparsep
\itemsep\plitemsep
\topsep\pltopsep
\partopsep\plpartopsep
\def\makelabel##1{\hss\llap{##1}}}}
%%
% Improved letterspacing of small caps and all-caps text.
%
% First, try to use the `microtype' package, if it's available.
% Failing that, try to use the `soul' package, if it's available.
% Failing that, well, I give up.
\DeclareTextFontCommand{\textsmallcaps}{\scshape}
\RequirePackage{textcase} % provides \MakeTextUppercase and \MakeTextLowercase
\def\allcapsspacing{\TufteWarning{Proper spacing of ALL-CAPS letters has not been set up.}}
\def\smallcapsspacing{\TufteWarning{Proper spacing of small-caps letters has not been set up.}}
\newcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{#1}}}
\newcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{#1}}}
% If we're using pdfLaTeX v1.40+, use the letterspace package.
% If we're using pdfLaTex < v1.40, use the soul package.
% If we're using XeLaTeX, use XeLaTeX letterspacing options.
% Otherwise fall back on the soul package.
\ifthenelse{\boolean{@tufte@pdf}}
{\TufteDebugInfoNL{ifpdf = true}}
{\TufteDebugInfoNL{ifpdf = false}}
\ifthenelse{\boolean{@tufte@xetex}}
{\TufteDebugInfoNL{ifxetex = true}}
{\TufteDebugInfoNL{ifxetex = false}}
% Check pdfLaTeX version
\def\@tufte@pdftexversion{0}
\ifx\normalpdftexversion\@undefined \else
\let\pdftexversion \normalpdftexversion
\let\pdftexrevision\normalpdftexrevision
\let\pdfoutput \normalpdfoutput
\fi
\ifx\pdftexversion\@undefined \else
\ifx\pdftexversion\relax \else
\def\@tufte@pdftexversion{6}
\ifnum\pdftexversion < 140
\def\@tufte@pdftexversion{5}
\fi
\fi
\fi
\newboolean{@tufte@letterspace@pkg@prereqs}
\setboolean{@tufte@letterspace@pkg@prereqs}{true}
\ifnum\@tufte@pdftexversion<6
\setboolean{@tufte@letterspace@pkg@prereqs}{false}
\fi
\ifthenelse{\boolean{@tufte@letterspace}}{%
\ifthenelse{\boolean{@tufte@pdf}\AND\boolean{@tufte@letterspace@pkg@prereqs}\AND\NOT\boolean{@tufte@xetex}}{%
% load letterspace pkg
\IfFileExists{letterspace.sty}{%
\TufteDebugInfoNL{Modern version of pdfTeX detected. \MessageBreak Using `letterspace' package}
\RequirePackage{letterspace}
% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}
\renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
\renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}
\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}}
}{}%
}{}%
% load soul pkg
\@ifpackageloaded{letterspace}{}{%
\IfFileExists{soul.sty}{%
\RequirePackage{soul}
\sodef\allcapsspacing{}{0.15em}{0.65em}{0.6em}
\sodef\smallcapsspacing{}{0.075em}{0.5em}{0.6em}
\sodef\sotextsc{\scshape}{0.075em}{0.5em}{0.6em}
\renewcommand{\allcaps}[1]{\allcapsspacing{\MakeTextUppercase{##1}}}
\renewcommand{\smallcaps}[1]{\smallcapsspacing{\scshape\MakeTextLowercase{##1}}}
\renewcommand{\textsc}[1]{\sotextsc{##1}}
}{
\TufteWarningNL{Couldn't locate `soul' package}
}% soul not installed... giving up.
}%
}{}
%\ifthenelse{\boolean{@tufte@letterspace}}{%
%\ifthenelse{\boolean{pdf}}{%
%\ifthenelse{\NOT\boolean{@tufte@letterspace@pkg@prereqs}}{%
%% pdfLaTeX version is too old or not using pdfLaTeX
%\ifthenelse{\boolean{@tufte@xetex}}{%
%% TODO use xetex letterspacing
%\TufteDebugInfoNL{XeTeX detected. \MessageBreak Reverting to `soul' package for letterspacing}%
%\@tufte@loadsoul%
%}{%
%% use `soul' package for letterspacing
%\TufteDebugInfoNL{Old version of pdfTeX detected. \MessageBreak Reverting to `soul' package for letterspacing}%
%\@tufte@loadsoul%
%}
%}{%
%\IfFileExists{letterspace.sty}{%
%\TufteDebugInfoNL{Modern version of pdfTeX detected. \MessageBreak Using `letterspace' package}
%\RequirePackage{letterspace}
%% Set up letterspacing (using microtype package) -- requires pdfTeX v1.40+
%\renewcommand{\allcapsspacing}[1]{\textls[200]{##1}}
%\renewcommand{\smallcapsspacing}[1]{\textls[50]{##1}}
%\renewcommand{\allcaps}[1]{\textls[200]{\MakeTextUppercase{##1}}}
%\renewcommand{\smallcaps}[1]{\smallcapsspacing{\MakeTextLowercase{##1}}}
%\renewcommand{\textsc}[1]{\smallcapsspacing{\textsmallcaps{##1}}}
%}{% microtype failed, check for soul
%\TufteDebugInfoNL{Modern version of pdfTeX detected, but `letterspace' \MessageBreak package not installed. \MessageBreak Reverting to `soul' package for letterspacing}
%\@tufte@loadsoul
%}%
%}%
%}{%
%\TufteDebugInfoNL{Plain LaTeX detected. \MessageBreak Using `soul' package for letterspacing}
%\@tufte@loadsoul
%}
%}{%
%% we're not to load letterspacing, so do nothing
%}
%%
% An environment for paragraph-style section
\providecommand\newthought[1]{%
\addvspace{1.0\baselineskip plus 0.5ex minus 0.2ex}%
\noindent\textsc{#1}%
}
%%
% Redefine the display environments (quote, quotation, etc.)
\renewenvironment{verse}
{\let\\\@centercr
\list{}{\itemsep \z@
\itemindent -1pc%
\listparindent\itemindent
\rightmargin \leftmargin
\advance\leftmargin 1pc}%
\small%
\item\relax}
{\endlist}
\renewenvironment{quotation}
{\list{}{\listparindent 1pc%
\itemindent \listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\small%
\item\relax\noindent\ignorespaces}
{\endlist}
\renewenvironment{quote}
{\list{}{\rightmargin\leftmargin}%
\small%
\item\relax}
{\endlist}
%%
% Italicize description run-in headings (instead of the default bold)
\renewcommand*\descriptionlabel[1]{\hspace\labelsep\normalfont\em #1}
%%
% Used for doublespacing, and other linespacing
\RequirePackage{setspace}
%%
% Load the bidi package if instructed to do so. This package must be loaded
% prior to our redefining the \footnote and \cite commands.
\ifthenelse{\boolean{@tufte@loadbidi}}{\RequirePackage{bidi}}{}
%%
% A function that removes leading and trailling spaces from the supplied macro.
% Based on code written by Michael Downes (See ``Around the Bend'', #15.)
% Executing \@tufte@trim@spaces\xyzzy will result in the contents of \xyzzy
% being trimmed of leading and trailing white space.
\catcode`\Q=3
\def\@tufte@trim@spaces#1{%
% Use grouping to emulate a multi-token afterassignment queue
\begingroup%
% Put `\toks 0 {' into the afterassignment queue
\aftergroup\toks\aftergroup0\aftergroup{%
% Apply \trimb to the replacement text of #1, adding a leading
% \noexpand to prevent brace stripping and to serve another purpose
% later.
\expandafter\@tufte@trim@b\expandafter\noexpand#1Q Q}%
% Transfer the trimmed text back into #1.
\edef#1{\the\toks0}%
}
% \trimb removes a trailing space if present, then calls \@tufte@trim@c to
% clean up any leftover bizarre Qs, and trim a leading space. In
% order for \trimc to work properly we need to put back a Q first.
\def\@tufte@trim@b#1 Q{\@tufte@trim@c#1Q}
% Execute \vfuzz assignment to remove leading space; the \noexpand
% will now prevent unwanted expansion of a macro or other expandable
% token at the beginning of the trimmed text. The \endgroup will feed
% in the \aftergroup tokens after the \vfuzz assignment is completed.
\def\@tufte@trim@c#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1}
\catcode`\Q=11
%%
% Citations should go in the margin as sidenotes
\RequirePackage{natbib}
\RequirePackage{bibentry} % allows bibitems to be typeset outside thebibliography environment
% Redefine the \BR@b@bibitem command to fix a bug with bibentry+chicago style
\renewcommand\BR@b@bibitem[2][]{%
\ifthenelse{\isempty{#1}}%
{\BR@bibitem{#2}}%
{\BR@bibitem[#1]{#2}}%
\BR@c@bibitem{#2}%
}
\nobibliography* % pre-loads the bibliography keys
\providecommand{\doi}[1]{\textsc{doi:} #1}% pre-defining this so it may be used before the \bibliography command it issued
%%
% Normal \cite behavior
\newcounter{@tufte@num@bibkeys}%
\newcommand{\@tufte@normal@cite}[2][0pt]{%
% Snag the last bibentry in the list for later comparison
\let\@temp@last@bibkey\@empty%
\@for\@temp@bibkey:=#2\do{\let\@temp@last@bibkey\@temp@bibkey}%
\sidenote[][#1]{%
% Loop through all the bibentries, separating them with semicolons and spaces
\normalsize\normalfont\@tufte@citation@font%
\setcounter{@tufte@num@bibkeys}{0}%
\@for\@temp@bibkeyx:=#2\do{%
\ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
{\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
\bibentry{\@temp@bibkeyx}}%
{\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
\bibentry{\@temp@bibkeyx};\ }%
\stepcounter{@tufte@num@bibkeys}%
}%
}%
}
%%
% Macros for holding the list of cite keys until after the \sidenote
\gdef\@tufte@citations{}% list of cite keys
\newcommand\@tufte@add@citation[1]{\relax% adds a new bibkey to the list of cite keys
\ifx\@tufte@citations\@empty\else
\g@addto@macro\@tufte@citations{,}% separate by commas
\fi
\g@addto@macro\@tufte@citations{#1}
}
\newcommand{\@tufte@print@citations}[1][0pt]{% puts the citations in a margin note
% Snag the last bibentry in the list for later comparison
\let\@temp@last@bibkey\@empty%
\@for\@temp@bibkey:=\@tufte@citations\do{\let\@temp@last@bibkey\@temp@bibkey}%
\marginpar{%
\hbox{}\vspace*{#1}%
\@tufte@citation@font%
\@tufte@citation@justification%
\@tufte@margin@par% use parindent and parskip settings for marginal text
\vspace*{-1\baselineskip}%
% Loop through all the bibentries, separating them with semicolons and spaces
\setcounter{@tufte@num@bibkeys}{0}%
\@for\@temp@bibkeyx:=\@tufte@citations\do{%
\ifthenelse{\equal{\@temp@last@bibkey}{\@temp@bibkeyx}}%
{\ifthenelse{\equal{\value{@tufte@num@bibkeys}}{0}}{}{and\ }%
\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
\bibentry{\@temp@bibkeyx}}%
{\@tufte@trim@spaces\@temp@bibkeyx% trim spaces around bibkey
\bibentry{\@temp@bibkeyx};\ }%
\stepcounter{@tufte@num@bibkeys}%
}%
\@tufte@reset@par% use parindent and parskip settings for body text
}%
}
%%
% \cite behavior when executed within a sidenote
\newcommand{\@tufte@sidenote@citations}{}% contains list of \cites in sidenote
\newcommand{\@tufte@infootnote@cite}[1]{%
\@tufte@add@citation{#1}
}
%%
% Set the default \cite style. This is set and reset by the \sidenote command.
\let\cite\@tufte@normal@cite
%%
% Transform existing \footnotes into \sidenotes
% Sidenote: ``Where God meant footnotes to go.'' ---Tufte
\RequirePackage{optparams}% for our new sidenote commands -- provides multiple optional arguments for commands
\providecommand*{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification}
\renewcommand{\footnotelayout}{\@tufte@sidenote@font\@tufte@sidenote@justification}
% Override footmisc's definition to set the sidenote marks (numbers) inside the
% sidenote's text block.
\long\def\@makefntext#1{\@textsuperscript{\@tufte@sidenote@font\tiny\@thefnmark}\,\footnotelayout#1}
% Set the in-text footnote mark in the same typeface as the body text itself.
\def\@makefnmark{\hbox{\@textsuperscript{\normalfont\footnotesize\@thefnmark}}}
\providecommand*{\multiplefootnotemarker}{3sp}
\providecommand*{\multfootsep}{,}
\renewcommand*\@footnotemark{%
\leavevmode%
\ifhmode%
\edef\@x@sf{\the\spacefactor}%
\@tufte@check@multiple@sidenotes%
\nobreak%
\fi%
\@makefnmark%
\ifhmode\spacefactor\@x@sf\fi%
\relax%
}
\newcommand{\@tufte@check@multiple@sidenotes}{%
\ifdim\lastkern=\multiplefootnotemarker\relax%
\edef\@x@sf{\the\spacefactor}%
\unkern%
\textsuperscript{\multfootsep}%
\spacefactor\@x@sf\relax%
\fi
}
\renewcommand\@footnotetext[2][0pt]{%
\marginpar{%
\hbox{}\vspace*{#1}%
\def\baselinestretch {\setspace@singlespace}%
\ifthenelse{\boolean{@tufte@loadbidi}}{\if@rl@footnote\@rltrue\else\@rlfalse\fi}{}%
\reset@font\footnotesize%
\@tufte@margin@par% use parindent and parskip settings for marginal text
\vspace*{-1\baselineskip}\noindent%
\protected@edef\@currentlabel{%
\csname p@footnote\endcsname\@thefnmark%
}%
\color@begingroup%
\@makefntext{%
\ignorespaces#2%
}%
\color@endgroup%
}%
\@tufte@reset@par% use parindent and parskip settings for body text
}%
%
% Define \sidenote command. Can handle \cite.
\newlength{\@tufte@sidenote@vertical@offset}
\setlength{\@tufte@sidenote@vertical@offset}{0pt}
% #1 = footnote num, #2 = vertical offset, #3 = footnote text
\long\def\@tufte@sidenote[#1][#2]#3{%
\let\cite\@tufte@infootnote@cite% use the in-sidenote \cite command
\gdef\@tufte@citations{}% clear out any old citations
\ifthenelse{\NOT\isempty{#2}}{%
\gsetlength{\@tufte@sidenote@vertical@offset}{#2}%
}{%
\gsetlength{\@tufte@sidenote@vertical@offset}{0pt}%
}%
\ifthenelse{\isempty{#1}}{%
% no specific footnote number provided
\stepcounter\@mpfn%
\protected@xdef\@thefnmark{\thempfn}%
\@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
}{%
% specific footnote number provided
\begingroup%
\csname c@\@mpfn\endcsname #1\relax%
\unrestored@protected@xdef\@thefnmark{\thempfn}%
\endgroup%
\@footnotemark\@footnotetext[\@tufte@sidenote@vertical@offset]{#3}%
}%
\@tufte@print@citations% print any citations
\let\cite\@tufte@normal@cite% go back to using normal in-text \cite command
\unskip\ignorespaces% remove extra white space
\kern-\multiplefootnotemarker% remove \kern left behind by sidenote