Debian Codegraph @

texmf-dist/doc/support/texdoc/texdoc-doc.cls

raw
1 % Document style for Texdoc user manual
2 % Copyright 2008-2023 Manuel Pégourié-Gonnard and Takuto Asakura
3 % distributed under the terms of GPL v3 or later
4 \NeedsTeXFormat{LaTeX2e}
5 \ProvidesClass{texdoc-doc}
6 [2023-02-17 Document class for Texdoc user manual]
7
8 % class options
9 \DeclareOption{draft}{\setlength\overfullrule{5pt}}
10 \ProcessOptions\relax
11
12 % remove "draft" from global options list
13 % (code from https://tex.stackexchange.com/questions/33245/)
14 \def\@clearglobaloption#1{%
15 \def\@tempa{#1}%
16 \def\@tempb{\@gobble}%
17 \@for\next:=\@classoptionslist\do
18 {\ifx\next\@tempa
19 \message{Cleared option \next\space from global list}%
20 \else
21 \edef\@tempb{\@tempb,\next}%
22 \fi}%
23 \let\@classoptionslist\@tempb
24 \expandafter\ifx\@tempb\@gobble
25 \let\@classoptionslist\@empty
26 \fi}
27 \@clearglobaloption{draft}
28
29 % basic dependency
30 \LoadClass[a4paper,oneside,parskip=half-]{scrartcl}
31 \RequirePackage[british]{babel}
32 \RequirePackage{needspace}
33 \RequirePackage{xunicode}
34 \RequirePackage{fancyvrb}
35 \RequirePackage{xparse}
36
37 % font settings
38 \RequirePackage{fontspec}
39 \defaultfontfeatures{Ligatures=TeX}
40 \setmainfont{DejaVuSerif}
41 \setsansfont{DejaVuSans}
42 \setmonofont{DejaVuSansMono}
43 \renewcommand{\familydefault}{\sfdefault}
44
45 % for math
46 %\RequirePackage{unicode-math}
47 %\setmathfont[math-style=ISO,bold-style=ISO]{TeX Gyre DejaVu Math}
48
49 \setkomafont{title}{}
50 \setkomafont{subtitle}{\Large}
51 \deffootnote[1.5em]{1.5em}{1em}{\textsuperscript{\thefootnotemark}\thinspace}
52
53 % headers
54 \RedeclareSectionCommand[
55 runin=false,
56 afterindent=false,
57 beforeskip=\baselineskip,
58 afterskip=.5\baselineskip]{section}
59 \RedeclareSectionCommand[
60 runin=false,
61 afterindent=false,
62 beforeskip=\baselineskip,
63 afterskip=.3\baselineskip]{subsection}
64
65 % colors
66 \RequirePackage{xcolor}
67 \definecolor{links}{named}{violet}
68 \definecolor{special}{rgb}{0,0.5,0}
69 \definecolor{code}{rgb}{0,0,0.6}
70
71 % list environments
72 \RequirePackage{enumitem}
73 \newlength\lssep \setlength\lssep{\smallskipamount}
74 \setlist{noitemsep, topsep=\lssep, partopsep=\lssep}
75
76 % hyperref and bookmark
77 \RequirePackage[
78 colorlinks=true, linkcolor=links, urlcolor=links, citecolor=links,
79 bookmarks=true, bookmarksnumbered=true, bookmarksopen=true,
80 bookmarksopenlevel=2]{hyperref}
81 \RequirePackage{bookmark}
82
83 % text styles
84 \DeclareUrlCommand\path{\urlstyle{tt}\color{links}}
85 \DeclareTextFontCommand{\emph}{\color{code}}
86
87 % for metadata
88 \AtBeginDocument{%
89 \bgroup
90 \def\and{, }%
91 \hypersetup{%
92 pdftitle={\@title: \@subtitle},
93 pdfauthor={\@author},
94 pdfsubject={Texdoc's user manual},
95 pdfkeywords={Texdoc, TeX Live, manual, documentation}}
96 \egroup}
97 \RequirePackage[yyyymmdd]{datetime}
98 \renewcommand{\dateseparator}{-}
99
100 % title (overwrite \@maketitle from scrartcl)
101 \newcommand*{\pkgurl}[1]{\gdef\@pkgurl{\url{#1}}}
102 \renewcommand*{\@maketitle}{%
103 \global\@topnum=\z@
104 \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
105 \ifx\@titlehead\@empty \else
106 \begin{minipage}[t]{\textwidth}
107 \usekomafont{titlehead}{\@titlehead\par}%
108 \end{minipage}\par
109 \fi
110 \null
111 \vskip 2em%
112 \begin{center}%
113 \ifx\@subject\@empty \else
114 {\usekomafont{subject}{\@subject \par}}%
115 \vskip 1.5em
116 \fi
117 {\usekomafont{title}{\huge \@title \par}}%
118 \vskip .5em
119 {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
120 \vskip .1em
121 {\ifx\@pkgurl\@empty\else\usekomafont{subtitle}\@pkgurl\par\fi}%
122 \vskip 1em
123 {%
124 \usekomafont{author}{%
125 \lineskip .5em%
126 \begin{tabular}[t]{c}
127 \@author
128 \end{tabular}\par
129 }%
130 }%
131 \vskip 1em%
132 {\usekomafont{date}{\@date \par}}%
133 \vskip \z@ \@plus 1em
134 {\usekomafont{publishers}{\@publishers \par}}%
135 \ifx\@dedication\@empty \else
136 \vskip 2em
137 {\usekomafont{dedication}{\@dedication \par}}%
138 \fi
139 \end{center}%
140 \par
141 \vskip 2em
142 }
143
144 % Low layer settings
145 \lastlinefit=500 % e-TeX powered
146 \catcode`\ 10\relax % take care of non-breakable spaces
147
148 % some macros
149 \DeclareRobustCommand{\TL}{\texorpdfstring{\TeX\,\,Live}{TeX Live}}
150 \newcommand*{\TexdocML}
151 {\href{http://lists.tug.org/texdoc}{mailing list}}
152 \newcommand*{\TexdocRepo}
153 {\href{https://github.com/TeX-Live/texdoc}{GitHub repository}}
154 \newcommand*{\ie}{i.e.,\,}
155 \newcommand*{\eg}{e.g.,\,}
156 \newcommand*{\hyph}{-}
157 \newcommand*{\meta}[1]{\bgroup
158 \normalfont\color{special}$\langle$\textit{#1}$\rangle$\egroup}
159 \newcommand*{\metatab}{\code{\char`\\t}}
160 \newcommand*{\choice}[1]{\bgroup
161 \def\@delim{\def\@delim{\space\char`\|\space}}%
162 \normalfont\color{special}%
163 \@for\@item:=#1\do{\@delim\@item}%
164 \egroup}
165 \newcommand*{\code}[1]{\bgroup
166 \chardef\_=`\_\chardef\~=`\~\code@font #1\egroup}
167 \newcommand*{\sopt}[1]{\hyperlink{cl:#1}{\code{\hyph#1}}}
168 \newcommand*{\lopt}[1]{\hyperlink{cl:#1}{\code{\hyph{}\hyph#1}}}
169 \newcommand*{\ci}[1]{\bgroup
170 \def\_{-}\def\meta##1{##1}%
171 \edef\x{\noexpand\def\noexpand\@tmp@hyname{cf:#1}}%
172 \expandafter\egroup\x
173 \hyperlink{\@tmp@hyname}{\code{#1}}}
174
175 % verbatim
176 \def\code@font{% code
177 \color{code}\normalfont\ttfamily}
178 \fvset{%
179 formatcom=\code@font,
180 defineactive=\makeallfancy,
181 commandchars=\\\{\},
182 codes=\fancyactives}
183 \newcommand{\fancyactives}{\catcode`\«\active}
184 \newcommand{\makeallfancy}{\makefancyog}
185 \bgroup
186 \catcode`\«\active
187 \gdef\makefancyog{\def«##1»{\meta{##1}}}
188 \egroup
189
190 % manual entries
191 \newenvironment{manual@entry}{\begin{list}{}{%
192 \setlength{\leftmargin}{2em}%
193 \setlength{\itemindent}{0pt}%
194 \setlength{\itemsep}{0pt}%
195 \setlength{\parsep}{0pt}%
196 \setlength{\rightmargin}{0em}%
197 }\item}{\end{list}}
198
199 \NewDocumentEnvironment{clopt}{ m o }
200 {%
201 \par\vskip\baselineskip
202 \bgroup
203 \def\sopt##1{\hypertarget{cl:##1}{\code{\hyph##1}}}%
204 \def\lopt##1{\hypertarget{cl:##1}{\code{\hyph{}\hyph##1}}}%
205 \needspace{3ex}\noindent #1\egroup
206 \IfNoValueF{#2}{\hfill (#2)}%
207 \begin{manual@entry}%
208 }
209 {\ifvmode\else\unskip\fi\end{manual@entry}}
210
211 \NewDocumentEnvironment{confitem}{ m m o }
212 {%
213 \par\vskip\baselineskip
214 \bgroup
215 \def\_{-}\def\meta##1{##1}%
216 \edef\x{\noexpand\def\noexpand\@tmp@hyname{cf:#1}}%
217 \expandafter\egroup\x
218 \needspace{3ex}\noindent
219 \hypertarget{\@tmp@hyname}{\code{#1 = #2}}%
220 \IfNoValueF{#3}{\hfill (#3)}%
221 \begin{manual@entry}%
222 \bgroup%
223 \def\meta##1{##1}%
224 \def\_{\string_}%
225 \edef\conf@title{#1}%
226 \belowpdfbookmark{\conf@title}{\conf@title}%
227 \egroup%
228 }
229 {\ifvmode\else\unskip\fi\end{manual@entry}}
230
231 % code in hors-text
232 \newenvironment{htcode}
233 {\SaveVerbatim[samepage]{verbmat}}
234 {%
235 \endSaveVerbatim
236 \par\medskip\noindent\hspace*{2em}%
237 \BUseVerbatim{verbmat}%
238 \par\medskip\@endpetrue
239 }
240
241 \DefineShortVerb{\|}
242 % EOF