summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/tcolorbox/tcbdocumentation.code.tex
blob: 38107a7732710db0b278e10db0185255a2f3cc81 (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
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
%% The LaTeX package tcolorbox - version 2.60 (2013/12/17)
%% tcbdocumentation.code.tex: Code for LaTeX documentations
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2006-2013 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `author-maintained'.
%%
%% This work consists of all files listed in README
%%
\tcb@set@library@version{2.60}

\tcbuselibrary{listings}

\RequirePackage{doc}[2010/02/04]
\RequirePackage{pifont}[2005/04/12]
\RequirePackage{marvosym}[2011/07/20]
\RequirePackage{hyperref}[2012/02/06]
\RequirePackage{makeidx}[2000/03/29]
\RequirePackage{refcount}[2011/10/16]

\definecolor{Option}{rgb}{0.118,0.546,0.222}
\definecolor{Definition}{rgb}{0.784,0.06,0.176}
\definecolor{ExampleFrame}{rgb}{0.628,0.705,0.942}
\definecolor{ExampleBack}{rgb}{0.963,0.971,0.994}
\definecolor{Hyperlink}{rgb}{0.281,0.275,0.485}

\def\colDef#1{\textcolor{\kvtcb@coldef}{#1}}
\def\colOpt#1{\textcolor{\kvtcb@colopt}{#1}}

\lstdefinestyle{tcbdocumentation}{language={[LaTeX]TeX},
    aboveskip={0\p@ \@plus 6\p@},
    belowskip={0\p@ \@plus 6\p@},
    columns=fullflexible,
    keepspaces=true,
    breaklines=true,
    prebreak={\Righttorque},
    postbreak={\space\Lefttorque},
    breakatwhitespace=true,
    basicstyle=\ttfamily\footnotesize,
    extendedchars=true,
    moredelim={[is][\itshape\rmfamily]{§}{§}},
    nolol,inputencoding=\kvtcb@listingencoding}

% The following macros are taken from ltxdoc
\DeclareRobustCommand\cs[1]{\texttt{\char`\\#1}}
\def\marg#1{%
  {\ttfamily\char`\{}{\rmfamily\meta{#1}}{\ttfamily\char`\}}}
\def\oarg#1{%
  \colOpt{{\ttfamily[}{\rmfamily\meta{#1}}{\ttfamily]}}}

% language specific texts
\tcbset{
  doclang/.cd,
  color/.store in=\kvtcb@text@color,
  colors/.store in=\kvtcb@text@colors,
  environment content/.store in=\kvtcb@text@envcontent,
  environment/.store in=\kvtcb@text@env,
  environments/.store in=\kvtcb@text@envs,
  key/.store in=\kvtcb@text@key,
  index/.store in=\kvtcb@text@index,
  pageshort/.store in=\kvtcb@text@pageshort,
}

% documentation options
\tcbset{
  documentation listing options/.store in=\kvtcb@doclistingoptions,%
  documentation listing style/.style={documentation listing options={style=#1}},%
  documentation minted style/.store in=\kvtcb@docmintstyle,
  documentation minted options/.store in=\kvtcb@docmintoptions,
  color option/.store in=\kvtcb@colopt,
  color definition/.store in=\kvtcb@coldef,
  color hyperlink/.store in=\kvtcb@colhyper,
  color frame/.store in=\kvtcb@colhyper,
  color hyperlink/.store in=\kvtcb@colhyper,
  before example/.store in=\kvtcb@beforeexample,
  after example/.store in=\kvtcb@afterexample,
  index actual/.store in=\idx@actual,
  index quote/.store in=\idx@quote,
  index level/.store in=\idx@level,
  index format/.store in=\idx@format,
}

% styles
\tcbset{
  docexample/.style={colframe=ExampleFrame,colback=ExampleBack,fontlower=\footnotesize},
  documentation minted style=,
  documentation minted options={tabsize=2,fontsize=\small},
  index default settings/.style={index actual={@},index quote={"},index level={!}},
  index german settings/.style={index actual={=},index quote={!},index level={>}},
  english language/.code={\tcbset{doclang/.cd,
    color=color,
    colors=Colors,
    environment content=environment content,
    environment=environment,
    environments=Environments,
    key=key,
    index=Index,
    pageshort={P.}}},
}

\AtBeginDocument{%
  \csname tcb@doc@index@\idx@format\endcsname%
  \hypersetup{
  citecolor=\kvtcb@colhyper,
  linkcolor=\kvtcb@colhyper,
  urlcolor=\kvtcb@colhyper,
  filecolor=\kvtcb@colhyper,
  menucolor=\kvtcb@colhyper
}}


\def\dispExample{\tcbset{docexample}\tcbwritetemp}

\def\enddispExample{%
  \endtcbwritetemp%
  \kvtcb@beforeexample\begin{tcolorbox}%
  \tcb@doc@usetemplisting%
  \tcblower%
  \tcbusetemp%
  \end{tcolorbox}\kvtcb@afterexample%
}

\newenvironment{dispExample*}[1]{%
  \tcbset{docexample,#1}\tcbwritetemp%
  }{\enddispExample}

\def\dispListing{\tcb@layer@pushup\tcbset{docexample}\tcbwritetemp}

\def\enddispListing{%
  \endtcbwritetemp%
  \kvtcb@beforeexample\begin{tcolorbox}%
  \tcb@doc@usetemplisting%
  \end{tcolorbox}\kvtcb@afterexample%
}

\newenvironment{dispListing*}[1]{%
  \tcb@layer@pushup\tcbset{docexample,#1}\tcbwritetemp%
  }{\enddispListing}


% index auxiliary macros
\def\index@Col#1{\index{#1\idx@actual\texttt{#1} \kvtcb@text@color}\index{\kvtcb@text@colors\idx@level#1\idx@actual\texttt{#1}}}
\def\index@Com#1{\index{#1\idx@actual\cs{#1}}}
\def\index@Env#1{\index{#1\idx@actual\texttt{#1} \kvtcb@text@env}\index{\kvtcb@text@envs\idx@level#1\idx@actual\texttt{#1}}}
\def\index@Key#1{\index{#1\idx@actual\texttt{#1} \kvtcb@text@key}}%
\def\index@KeyPath#1#2{\index@Key{#2}\index{#1\idx@actual\texttt{/#1/}\idx@level#2\idx@actual\texttt{#2}}}%

\def\disp@com#1{\colDef{\ttfamily\bfseries#1}}

\def\brackets#1{{\ttfamily\char`\{}#1{\ttfamily\char`\}}}

\newenvironment{manual@entry}{\list{}{\leftmargin=2em\itemindent-\leftmargin\def\makelabel##1{\hss##1}}}{\endlist}

\def\manual@top#1{\itemsep=0pt\parskip=0pt\item\strut{#1}\par\topsep=0pt}

% main documentation environments
\newenvironment{docCommand}[3][]{\begin{manual@entry}%
  \tcbset{#1}\hypertarget{com:#2}{\manual@top{\disp@com{\cs{#2}}\index@Com{#2}\protected@edef\@currentlabel{\noexpand\cs{#2}}\label{com:#2}{\ttfamily #3}}}}%
  {\end{manual@entry}}

\newenvironment{docEnvironment}[3][]{\begin{manual@entry}%
  \tcbset{#1}\hypertarget{env:#2}{\manual@top{\cs{begin}\brackets{\disp@com{#2}}\index@Env{#2}\protected@edef\@currentlabel{#2}\label{env:#2}{\ttfamily #3}}}%
  \manual@top{~~\meta{\kvtcb@text@envcontent}}%
  \manual@top{\cs{end}\brackets{\disp@com{#2}}}}%
  {\end{manual@entry}}

\newenvironment{docKey}[4][\@empty]{\begin{manual@entry}%
  \ifx#1\@empty%
  \hypertarget{key:#2}{\manual@top{\disp@com{#2}\index@Key{#2}\protected@edef\@currentlabel{#2}\label{key:#2}{\ttfamily #3}\hfill(#4)}}
  \else\hypertarget{key:/#1/#2}{\manual@top{\disp@com{/#1/#2}\index@KeyPath{#1}{#2}\protected@edef\@currentlabel{/#1/#2}\label{key:/#1/#2}#3\hfill(#4)}}\fi}%
  {\end{manual@entry}}

\def\tcbmakedocSubKey#1#2{%
  \newenvironment{#1}[4][\@empty]{%
    \ifx##1\@empty\def\tcb@key@path{#2}\else\def\tcb@key@path{#2/##1}\fi%
    \begin{docKey}[\tcb@key@path]{##2}{##3}{##4}}%
      {\end{docKey}}%
}

\def\docColor#1{\disp@com{#1}\index@Col{#1}}%
\def\docAuxCommand#1{\disp@com{\cs{#1}}\index@Com{#1}}%

\setrefcountdefault{-1}
\def\ref@doc#1{\hyperlink{#1}{\texttt{\ref*{#1}}%
  \ifnum\getpagerefnumber{#1}=\thepage\else%
  \textsuperscript{\ding{213}\,\kvtcb@text@pageshort\,\pageref*{#1}}\fi}}

\def\ref@doc@star#1{\hyperlink{#1}{\texttt{\ref*{#1}}}}

\def\refCom@#1{\ref@doc{com:#1}}
\def\refCom@star#1{\ref@doc@star{com:#1}}
\def\refCom{\@ifstar\refCom@star\refCom@}

\def\refEnv@#1{\ref@doc{env:#1}}
\def\refEnv@star#1{\ref@doc@star{env:#1}}
\def\refEnv{\@ifstar\refEnv@star\refEnv@}

\def\refKey@#1{\ref@doc{key:#1}}
\def\refKey@star#1{\ref@doc@star{key:#1}}
\def\refKey{\@ifstar\refKey@star\refKey@}

\newenvironment{absquote}
               {\list{}{\leftmargin2cm\rightmargin\leftmargin}%
                \item\relax\footnotesize}
               {\endlist}

%--- index macros taken from pgfmanual-en-macros
\def\tcb@doc@index@pgf@{%
  \c@IndexColumns=2%
  \def\theindex{\@restonecoltrue
    \columnseprule \z@  \columnsep 29\p@
    \twocolumn[\index@prologue]%
    \parindent -30pt%
    \columnsep 15pt%
    \parskip 0pt plus 1pt%
    \leftskip 30pt%
    \rightskip 0pt plus 2cm%
    \small%
    \def\@idxitem{\par}%
    \let\item\@idxitem\ignorespaces}
  \def\endtheindex{\onecolumn}%
  \def\noindexing{\let\index=\@gobble}%
}


\def\tcb@doc@index@pgfsection{%
  \def\index@prologue{\section*{\kvtcb@text@index}\addcontentsline{toc}{section}{\kvtcb@text@index}%
    \par\noindent%
  }%
  \tcb@doc@index@pgf@%
}

\def\tcb@doc@index@pgfchapter{%
  \def\index@prologue{\ifdefined\phantomsection\phantomsection\fi\@makeschapterhead{\kvtcb@text@index}\addcontentsline{toc}{chapter}{\kvtcb@text@index}}%
  \tcb@doc@index@pgf@%
}


\let\tcb@doc@index@pgf=\tcb@doc@index@pgfsection%


\def\tcb@doc@index@doc{%
  \let\index@Com=\SpecialMainIndex%%
  \let\index@Env=\SpecialMainEnvIndex%
  \tcbset{index german settings}%
  \EnableCrossrefs%
  \PageIndex%
}

\def\tcb@doc@index@off{}%

\tcbset{%
  reset@documentation/.style={%
    index format=pgf,
    english language,
    documentation listing style=tcbdocumentation,
    index default settings,
    color option=Option,
    color definition=Definition,
    color hyperlink=Hyperlink,
    before example=\par\smallskip,
    after example=,},
  initialize@reset=reset@documentation,
}