-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathtufte.cfg
More file actions
133 lines (107 loc) · 4.5 KB
/
tufte.cfg
File metadata and controls
133 lines (107 loc) · 4.5 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
% tufte.cfg - TeX4ht configuration for Tufte-LaTeX to Tufte-CSS HTML conversion
% Based on: https://tex.stackexchange.com/questions/570630/can-a-tufte-latex-file-output-tufte-css-html
% Reference: https://edwardtufte.github.io/tufte-css/
\Preamble{xhtml}
\Configure{AddCss}{tufte.css}
% Helper macro to close current paragraph
\def\endparagraph{\ifvmode\IgnorePar\fi\EndP}
% Configure body to use article wrapper (tufte-css convention)
\Configure{@BODY}{\endparagraph\HCode{<article>}}
\Configure{@/BODY}{\endparagraph\HCode{</article>}}
% Configure sections (Tufte LaTeX makes \section and \subsection behave like starred versions)
\Configure{likesection}
{\endparagraph\HCode{<section>}}{\endparagraph\HCode{</section>}}
{\HCode{<h2 class="chapterHead">}}{\HCode{</h2>}\par\ShowPar}
\Configure{likesubsection}
{\endparagraph\HCode{<section>}}{\endparagraph\HCode{</section>}}
{\HCode{<h3 class="subsectionHead">}}{\HCode{</h3>}\par\ShowPar}
% Simple table of contents - will be populated by JavaScript
\renewcommand\tableofcontents{%
\endparagraph%
\HCode{<nav id="toc" class="toc"><h2>Contents</h2><ul id="toc-list"></ul></nav>}%
\HCode{<script src="toc.js"></script>}%
\HCode{<script src="checklist.js"></script>}%
}
\makeatletter
% Configure title page
\renewcommand{\maketitle}{%
\begingroup%
\endparagraph\HCode{<h1>}\@title\HCode{</h1>}%
\HCode{<p class="subtitle publisher">}\@publisher\HCode{</p>}%
\HCode{<p class="subtitle">}\@author\HCode{</p>}%
\HCode{<p class="subtitle">}\@date\HCode{</p>}%
\endgroup
}
% Configure image dimensions
\Configure{Gin-dim}{}
\Css{img {
max-width: 100\%;
height: auto;
}}
% Fix soul package compatibility (for \allcaps, \smallcaps)
\@ifpackageloaded{soul}{%
\renewcommand{\allcaps}[1]{\MakeTextUppercase{#1}}%
\renewcommand{\smallcaps}[1]{{\scshape\MakeTextLowercase{#1}}}%
\renewcommand{\textsc}[1]{\textcaps{#1}}%
}{}
% Configure sidenotes with tufte-css checkbox toggle pattern
\long\def\@tufte@sidenote[#1][#2]#3{%
\stepcounter\@mpfn%
\bgroup%
\HCode{<label for="sidenote-\thempfn" class="margin-toggle sidenote-number"></label><input type="checkbox" id="sidenote-\thempfn" class="margin-toggle" />}%
\HCode{<span class="sidenote">}#3\HCode{</span>}%
\egroup%
}
% Configure margin notes (unnumbered)
% Use Unicode character directly for the circle-plus symbol
% Use \leavevmode to ensure we're in horizontal mode (fixes issues in lists)
\renewcommand\marginnote[2][0pt]{%
\leavevmode%
\stepcounter\@mpfn%
\bgroup%
\HCode{<label for="marginnote-\thempfn" class="margin-toggle">⊕</label><input type="checkbox" id="marginnote-\thempfn" class="margin-toggle" />}%
\HCode{<span class="marginnote">}#2\HCode{</span>}%
\egroup%
}
% Configure verbatim environments
\ConfigureEnv{verbatim}{\endparagraph\HCode{<pre><code>}\NoFonts}{\EndNoFonts\endparagraph\HCode{</code></pre>}}{}{}
% Configure fullwidth environment
\ConfigureEnv{fullwidth}{\endparagraph\HCode{<div class="fullwidth">}%
\ConfigureList{list}{}{}{}{}%
\par\ShowPar\indent%
}
{\endparagraph\HCode{</div>}}{}{}
% Configure margin floats (marginfigure)
\NewConfigure{marginfloat}{2}
\renewenvironment{@tufte@margin@float}[2][-1.2ex]%
{\FloatBarrier%
\begingroup%
\let\textwidth\marginparwidth%
\def\@captype{#2}%
\par%
\Configure{HtmlPar}{\EndP\csname a:marginfloat\endcsname}{\EndP\csname a:marginfloat\endcsname}{\csname b:marginfloat\endcsname}{\csname b:marginfloat\endcsname}%
}
{\endgroup}
\Configure{marginfloat}{\HCode{<p><span class="marginnote">}%
\Configure{caption}{\HCode{<span class="figure">}}{:\space}{}{\HCode{</span>}}%
}{\HCode{</span></p>}}{}{}
\Css{.marginnote .figure{display:block;}}
% Configure regular floats
\renewenvironment{@tufte@float}[3][htbp]%
{\@float{#2}[#1]}{\end@float}
% Configure captions
\Configure{caption}{\HCode{<span class="marginnote">}}{:\space}{}{\HCode{</span>}}
% Configure fullwidth figures (figure*)
\ConfigureEnv{figure*}{
\Configure{float}{}{\endparagraph\HCode{<figure class="fullwidth">}}{\endparagraph\HCode{</figure>}\csname par\endcsname\ShowPar}
\Configure{caption}{\endparagraph\HCode{<span class="figure">}}{:\space}{}{\HCode{</span>}}
}{}{}{}
% Configure margin tables
\ConfigureEnv{margintable}{\endparagraph\HCode{<div class="margintable">}\Configure{caption}{}{:\space}{}{}}{\endparagraph\HCode{</div>}}{}{}
% Configure math display width to match tufte-css article width
\Css{div.math-display, div.par-math-display {width: 55\%}}
% Add custom stylesheet (loaded after tufte.css)
\Configure{AddCss}{lab-manual.css}
\makeatother
\begin{document}
\EndPreamble