summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/support/texdoc/texdoc-doc.cls
blob: a9d229b6a716a77e65b0f144abf0029e4f578d23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
% Document style for Texdoc user manual
% Copyright 2008-2020 Manuel Pégourié-Gonnard and Takuto Asakura
% distributed under the terms of GPL v3 or later
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{texdoc-doc}
  [2020/02/02 Document class for Texdoc user manual]

% class options
\DeclareOption{draft}{\setlength\overfullrule{5pt}}
\ProcessOptions\relax

% remove "draft" from global options list
% (code from https://tex.stackexchange.com/questions/33245/)
\def\@clearglobaloption#1{%
  \def\@tempa{#1}%
  \def\@tempb{\@gobble}%
  \@for\next:=\@classoptionslist\do
    {\ifx\next\@tempa
       \message{Cleared  option \next\space from global list}%
     \else
       \edef\@tempb{\@tempb,\next}%
     \fi}%
  \let\@classoptionslist\@tempb
  \expandafter\ifx\@tempb\@gobble
    \let\@classoptionslist\@empty
  \fi}
\@clearglobaloption{draft}

% basic dependency
\LoadClass[a4paper,oneside,parskip=half-]{scrartcl}
\RequirePackage[british]{babel}
\RequirePackage{needspace}
\RequirePackage{xunicode}
\RequirePackage{fancyvrb}
\RequirePackage{xparse}

% font settings
\RequirePackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\setmainfont{DejaVuSerif}
\setsansfont{DejaVuSans}
\setmonofont{DejaVuSansMono}
\renewcommand{\familydefault}{\sfdefault}

% for math
%\RequirePackage{unicode-math}
%\setmathfont[math-style=ISO,bold-style=ISO]{TeX Gyre DejaVu Math}

\setkomafont{title}{}
\setkomafont{subtitle}{\Large}
\deffootnote[1.5em]{1.5em}{1em}{\textsuperscript{\thefootnotemark}\thinspace}

% headers
\RedeclareSectionCommand[
  runin=false,
  afterindent=false,
  beforeskip=\baselineskip,
  afterskip=.5\baselineskip]{section}
\RedeclareSectionCommand[
  runin=false,
  afterindent=false,
  beforeskip=\baselineskip,
  afterskip=.3\baselineskip]{subsection}

% colors
\RequirePackage{xcolor}
\definecolor{links}{named}{violet}
\definecolor{special}{rgb}{0,0.5,0}
\definecolor{code}{rgb}{0,0,0.6}

% list environments
\RequirePackage{enumitem}
\newlength\lssep \setlength\lssep{\smallskipamount}
\setlist{noitemsep, topsep=\lssep, partopsep=\lssep}

% hyperref and bookmark
\RequirePackage[
  colorlinks=true, linkcolor=links, urlcolor=links, citecolor=links,
  bookmarks=true, bookmarksnumbered=true, bookmarksopen=true,
  bookmarksopenlevel=2]{hyperref}
\RequirePackage{bookmark}

% text styles
\DeclareUrlCommand\path{\urlstyle{tt}\color{links}}
\DeclareTextFontCommand{\emph}{\color{code}}

% for metadata
\AtBeginDocument{%
  \bgroup
  \def\and{, }%
  \hypersetup{%
    pdftitle={\@title: \@subtitle},
    pdfauthor={\@author},
    pdfsubject={Texdoc's user manual},
    pdfkeywords={Texdoc, TeX Live, manual, documentation}}
  \egroup}
\RequirePackage[yyyymmdd]{datetime}
\renewcommand{\dateseparator}{-}

% title (overwrite \@maketitle from scrartcl)
\newcommand*{\pkgurl}[1]{\gdef\@pkgurl{\url{#1}}}
\renewcommand*{\@maketitle}{%
  \global\@topnum=\z@
  \setparsizes{\z@}{\z@}{\z@\@plus 1fil}\par@updaterelative
  \ifx\@titlehead\@empty \else
    \begin{minipage}[t]{\textwidth}
      \usekomafont{titlehead}{\@titlehead\par}%
    \end{minipage}\par
  \fi
  \null
  \vskip 2em%
  \begin{center}%
    \ifx\@subject\@empty \else
      {\usekomafont{subject}{\@subject \par}}%
      \vskip 1.5em
    \fi
    {\usekomafont{title}{\huge \@title \par}}%
    \vskip .5em
    {\ifx\@subtitle\@empty\else\usekomafont{subtitle}\@subtitle\par\fi}%
    \vskip .1em
    {\ifx\@pkgurl\@empty\else\usekomafont{subtitle}\@pkgurl\par\fi}%
    \vskip 1em
    {%
      \usekomafont{author}{%
        \lineskip .5em%
        \begin{tabular}[t]{c}
          \@author
        \end{tabular}\par
      }%
    }%
    \vskip 1em%
    {\usekomafont{date}{\@date \par}}%
    \vskip \z@ \@plus 1em
    {\usekomafont{publishers}{\@publishers \par}}%
    \ifx\@dedication\@empty \else
      \vskip 2em
      {\usekomafont{dedication}{\@dedication \par}}%
    \fi
  \end{center}%
  \par
  \vskip 2em
}

% Low layer settings
\lastlinefit=500 % e-TeX powered
\catcode`\ 10\relax % take care of non-breakable spaces

% some macros
\DeclareRobustCommand{\TL}{\texorpdfstring{\TeX\,\,Live}{TeX Live}}
\newcommand*{\TexdocML}
  {\href{http://lists.tug.org/texdoc}{mailing list}}
\newcommand*{\TexdocRepo}
  {\href{https://github.com/TeX-Live/texdoc}{GitHub repository}}
\newcommand*{\ie}{i.e.,\,}
\newcommand*{\eg}{e.g.,\,}
\newcommand*{\hyph}{-}
\newcommand*{\meta}[1]{\bgroup
  \normalfont\color{special}$\langle$\textit{#1}$\rangle$\egroup}
\newcommand*{\metatab}{\code{\char`\\t}}
\newcommand*{\choice}[1]{\bgroup
  \def\@delim{\def\@delim{\space\char`\|\space}}%
  \normalfont\color{special}%
  \@for\@item:=#1\do{\@delim\@item}%
  \egroup}
\newcommand*{\code}[1]{\bgroup
  \chardef\_=`\_\code@font #1\egroup}
\newcommand*{\sopt}[1]{\hyperlink{cl:#1}{\code{\hyph#1}}}
\newcommand*{\lopt}[1]{\hyperlink{cl:#1}{\code{\hyph{}\hyph#1}}}
\newcommand*{\ci}[1]{\bgroup
  \def\_{-}\def\meta##1{##1}%
  \edef\x{\noexpand\def\noexpand\@tmp@hyname{cf:#1}}%
  \expandafter\egroup\x
  \hyperlink{\@tmp@hyname}{\code{#1}}}

% verbatim
\def\code@font{% code
  \color{code}\normalfont\ttfamily}
\fvset{%
  formatcom=\code@font,
  defineactive=\makeallfancy,
  commandchars=\\\{\},
  codes=\fancyactives}
\newcommand{\fancyactives}{\catcode`\«\active}
\newcommand{\makeallfancy}{\makefancyog}
\bgroup
  \catcode`\«\active
  \gdef\makefancyog{\def«##1»{\meta{##1}}}
\egroup

% manual entries
\newenvironment{manual@entry}{\begin{list}{}{%
  \setlength{\leftmargin}{2em}%
  \setlength{\itemindent}{0pt}%
  \setlength{\itemsep}{0pt}%
  \setlength{\parsep}{0pt}%
  \setlength{\rightmargin}{0em}%
  }\item}{\end{list}}

\NewDocumentEnvironment{clopt}{ m o }
  {%
    \par\vskip\baselineskip
    \bgroup
    \def\sopt##1{\hypertarget{cl:##1}{\code{\hyph##1}}}%
    \def\lopt##1{\hypertarget{cl:##1}{\code{\hyph{}\hyph##1}}}%
    \needspace{3ex}\noindent #1\egroup
    \IfNoValueF{#2}{\hfill (#2)}%
    \begin{manual@entry}%
  }
  {\ifvmode\else\unskip\fi\end{manual@entry}}

\NewDocumentEnvironment{confitem}{ m m o }
  {%
    \par\vskip\baselineskip
    \bgroup
    \def\_{-}\def\meta##1{##1}%
    \edef\x{\noexpand\def\noexpand\@tmp@hyname{cf:#1}}%
    \expandafter\egroup\x
    \needspace{3ex}\noindent
    \hypertarget{\@tmp@hyname}{\code{#1 = #2}}%
    \IfNoValueF{#3}{\hfill (#3)}%
    \begin{manual@entry}%
  }
  {\ifvmode\else\unskip\fi\end{manual@entry}}

% code in hors-text
\newenvironment{htcode}
  {\SaveVerbatim[samepage]{verbmat}}
  {%
    \endSaveVerbatim
    \par\medskip\noindent\hspace*{2em}%
    \BUseVerbatim{verbmat}%
    \par\medskip\@endpetrue
  }

\DefineShortVerb{\|}
% EOF