Debian Codegraph @

texmf-dist/doc/latex/stex/stex-docheader.tex

raw
1 \RequirePackage{paralist}
2 \ifcsname stexdocpath\endcsname\else\def\stexdocpath{.}\fi
3 \documentclass[full]{l3doc}
4
5 \usepackage[hyperref=auto,style=alphabetic]{biblatex}
6 \usepackage[lang={en,de}]{stex}
7 \usepackage[show]{ed}
8 \usepackage{rustex}
9 \usepackage{stex-highlighting,stexthm}
10
11
12 \srefsetin[sTeX/Documentation]{documentation}{the \stex Documentation}
13
14 \makeatletter
15 \providecommand{\HTML}{\textsc{html}\xspace}%
16 \providecommand{\XML}{\textsc{xml}\xspace}%
17 \providecommand{\PDF}{\textsc{pdf}\xspace}%
18 \providecommand\openmath{\textsc{OpenMath}\xspace}
19 \providecommand\OMDoc{\textsc{OMDoc}\xspace}
20 \DeclareRobustCommand\LaTeXML{L\kern-.36em%
21 {\sbox\z@ T%
22 \vbox to\ht\z@{\hbox{\check@mathfonts
23 \fontsize\sf@size\z@
24 \math@fontsfalse\selectfont
25 A}%
26 \vss}%
27 }%
28 \kern-.15em%
29 T\kern-.1667em\lower.4ex\hbox{E}\kern-0.05em\relax
30 {\scshape xml}\xspace}%
31 \def\mmt{\textsc{Mmt}\xspace}
32 \def\immt{\textsc{iMmt}\xspace}
33 \makeatother
34
35
36 \newif\ifhadtitle\hadtitlefalse
37
38 \def\stexversion{4.0.0}
39 \def\changedate{\today}
40 \def\stextoptitle#1#2{\title{#1\thanks{Version {\stexversion} (last revised {\changedate})} }\def\thispkg{#2}}
41
42 \author{Michael Kohlhase, Dennis Müller\\
43 FAU Erlangen-Nürnberg\\
44 \url{http://kwarc.info/}
45 }
46
47 \def\docmodule#1{
48 \begin{document}
49 \stexmaketitle
50 \setsectionlevel{#1}
51 \stexdocumentation
52 \steximplementation
53 \stexfooter
54 \end{document}
55 }
56
57
58 \ExplSyntaxOn
59 \def\stexmaketitle{
60 \ifhadtitle\else
61 \hadtitletrue
62 \maketitle
63 \tableofcontents
64 \int_gincr:N \l_stex_current_section_level_int
65
66 \seq_map_inline:Nn \c_stex_mathhub_files {
67 \__stex_mathhub_find_manifest:nn {##1}{ sTeX / Documentation }
68 \str_if_empty:NF \l__stex_mathhub_manifest_str \seq_map_break:
69 }
70 % \str_if_empty:NF \l__stex_mathhub_manifest_str {
71 % \usemodule[sTeX/Documentation]{macros?AllMacros}
72 % }
73 \fi
74 }
75
76 \def\stexdomanual{
77 \DisableDocumentation
78 \DisableImplementation
79 \EnableManual
80 \begin{sfragment}{Manual}
81 \DocInput{\jobname.dtx}
82 \end{sfragment}
83 }
84
85 \def\stexdocumentation{
86 \DisableManual
87 \DisableImplementation
88 \EnableDocumentation
89 \begin{sfragment}{Documentation}
90 \DocInput{\jobname.dtx}
91 \end{sfragment}
92 }
93
94 \def\steximplementation{
95 \DisableManual
96 \DisableDocumentation
97 \EnableImplementation
98 \begin{sfragment}{Implementation}
99 \DocInput{\jobname.dtx}
100 \end{sfragment}
101 }
102
103 \def\stexfooter{
104 \clearpage
105 \PrintIndex
106 \printbibliography
107 }
108
109 \ExplSyntaxOff
110
111 \usepackage{lststex,mdframed}
112 \usepackage[most]{tcolorbox}
113
114 \lstset{literate=%
115 {Ö}{{\"O}}1
116 {Ä}{{\"A}}1
117 {Ü}{{\"U}}1
118 {ß}{{\ss}}1
119 {ü}{{\"u}}1
120 {ä}{{\"a}}1
121 {ö}{{\"o}}1
122 {~}{{\textasciitilde}}1
123 }
124
125
126 \newenvironment{framed}[1][]{
127 \ifstexhtml\par\vbox\bgroup
128 \csname exp_args:Nne\endcsname\begin{stex_annotate_env}{%
129 style:border=solid 1px black,%
130 style:width=var(--this-width),%
131 style:min-width=var(--this-width),%
132 style:--this-width=calc(var(--current-width) - 6px),%
133 style:padding=3px,%
134 style:margin-top=5px,%
135 style:margin-bottom=5px%
136 }
137 \csname stex_annotate_invisible:n\endcsname{ }%
138 \begin{stex_annotate_env}{%
139 style:--current-width=var(--this-width);%
140 }\csname stex_annotate_invisible:n\endcsname{ }
141 \else\begin{mdframed}[#1]\fi
142 }{%
143 \ifstexhtml
144 \end{stex_annotate_env}\end{stex_annotate_env}\egroup\par
145 \else\end{mdframed}\fi
146 }
147 \newcommand{\scaled}[2][0.9\hsize]{\begin{center}\resizebox{#1}{!}{\begin{minipage}{\textwidth} #2 \end{minipage}}\end{center}}
148
149 \makeatletter
150 \ExplSyntaxOn
151
152 \def\doc_exbox:nnn#1#2#3{
153 \begin{sexample}[#3]
154 Input:
155 \begin{framed}[linewidth=1pt,backgroundcolor=white]\small
156 #1
157 \end{framed}
158 Output:
159 \begin{framed}[linewidth=1pt,backgroundcolor=white]\small
160 #2
161 \end{framed}
162 \end{sexample}
163 }
164
165
166 \NewDocumentCommand\stexexamplefile{O{} m O{} O{}}{
167 \doc_exbox:nnn{
168 \hfill File~\str_if_empty:nTF{#1}{
169 \prop_if_exist:NT \l_stex_current_archive_prop {
170 [\texttt{\prop_item:Nn \l_stex_current_archive_prop {id}}]
171 }
172 }{[#1]}\texttt{\tl_to_str:n{#2}}
173 \_lststex_parse_args:n{#3}
174 \stex_in_archive:nn{#1}{
175 \exp_args:Nno \use:nn{\lstinputlisting[} \l_lststex_return_tl ]{\stex_source_path:n{#2}}
176 }
177 }{
178 \inputref[#1]{#2}
179 }{#4}
180 }
181
182 \newwrite\testoutfile
183 \NewDocumentCommand\stexexample{O{} O{}}{
184 \begingroup
185 \catcode`\\=12\relax
186 \catcode`\#=12\relax
187 \catcode`\&=12\relax
188 \catcode`\$=12\relax
189 \catcode`\^=12\relax
190 \catcode`\_=12\relax
191 \catcode`\ =12\relax
192 \catcode`^^J=12\relax
193 \endlinechar=`^^J
194 \newlinechar=-1
195 %^^A \everyeof{\noexpand}
196 \example_a:nnn{#1}{#2}
197 }
198 \long\def\example_a:nnn #1 #2 #3 {
199 \endgroup
200 \immediate\openout\testoutfile=\jobname.exmpl
201 \immediate\write\testoutfile{
202 \c_backslash_str begin{stexcode}[#1]
203 \detokenize{^^J}#3
204 \c_backslash_str end{stexcode}
205 }
206 \immediate\closeout\testoutfile
207 \doc_exbox:nnn{
208 \catcode`\#=12\relax
209 \csname @ @ input\endcsname{\jobname.exmpl}
210 }{
211 \immediate\openout\testoutfile=\jobname.exmpl
212 \immediate\write\testoutfile{#3}
213 \immediate\closeout\testoutfile
214 \csname @ @ input\endcsname \jobname.exmpl\relax
215 }{#2}
216 \peek_charcode_remove:NT ^^J
217 }
218
219 \ExplSyntaxOff
220 \makeatother
221
222 \makeatletter
223 \newcount\example@counter\example@counter=0
224 \newtcolorbox{exampleborderbox}[1][]{
225 empty,
226 title={Example \the\example@counter #1},
227 attach boxed title to top left,
228 minipage boxed title,
229 boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}},
230 coltitle=blue,fonttitle=\bfseries,
231 parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm,
232 before upper=\csname @totalleftmargin\endcsname0pt,
233 overlay unbroken={\draw[blue,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); },
234 overlay first={\draw[blue,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); },
235 overlay middle={\draw[blue,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); },
236 overlay last={\draw[blue,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); },
237 outer arc=4pt%
238 }
239
240 \ExplSyntaxOn
241 \stexstyleexample{
242 \global\advance\example@counter by 1
243 \tl_if_empty:NTF\thistitle{
244 \begin{exampleborderbox}
245 }{
246 \begin{exampleborderbox}[ (\thistitle)]
247 }
248 }{
249 \end{exampleborderbox}
250 }
251 \ExplSyntaxOff\makeatother
252
253 \stexcssexample[counter=example]{
254 border-left:3px solid blue;
255 padding-left:3px;
256 margin-left: -3px;
257 width:calc(var(--rustex-curr-width) + 3px);
258 }{
259 font-weight: bold;
260 font-size:inherit;
261 color:blue;
262 display:block;
263 &::before {
264 content: "Example " counter(ftml-example) " ";
265 }
266 &::after {
267 content: ".";
268 }
269 }
270
271
272 \usetikzlibrary{calc}
273
274 \def\textwarning{\includegraphics[width=1.2em]{stex-dangerous-bend}\xspace}
275 \newtcolorbox{dangerbox}{
276 breakable,
277 enhanced,
278 left=0pt,
279 right=0pt,
280 top=8pt,
281 bottom=8pt,
282 colback=white,
283 colframe=red,
284 width=\textwidth,
285 enlarge left by=0mm,
286 boxsep=5pt,
287 fontupper=\small,
288 arc=4pt,
289 outer arc=4pt,
290 leftupper=1.5cm,
291 overlay={
292 \node[anchor=west] at ([xshift=10pt]$(frame.north west)!0.5!(frame.south west)$)
293 {\includegraphics[width=1cm,height=1cm]{stex-dangerous-bend}};}
294 }
295
296 \protected\def\TODO#1{\textcolor{red}{TODO}\footnote{\textcolor{red}{TODO: #1}}}
297
298 \definecolor{darkgreen}{rgb}{0.0, 0.5, 0.0}
299
300 \usepackage[solutions]{problem}
301 \usepackage{hwexam}
302 \newtcolorbox{problemborderbox}[1][]{
303 empty,
304 title={Exercise #1},
305 attach boxed title to top left,
306 minipage boxed title,
307 boxed title style={empty,size=minimal,toprule=0pt,top=1pt,left=3mm,overlay={}},
308 coltitle=darkgreen,fonttitle=\bfseries,
309 parbox=false,boxsep=0pt,left=3mm,right=0mm,top=2pt,breakable,pad at break=0mm,
310 before upper=\csname @totalleftmargin\endcsname0pt,
311 overlay unbroken={\draw[darkgreen,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); },
312 overlay first={\draw[darkgreen,line width=2pt] ([xshift=-0pt]title.north west) -- ([xshift=-0pt]frame.south west); },
313 overlay middle={\draw[darkgreen,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); },
314 overlay last={\draw[darkgreen,line width=2pt] ([xshift=-0pt]frame.north west) -- ([xshift=-0pt]frame.south west); },
315 outer arc=4pt%
316 }
317
318 \ExplSyntaxOn
319 \stexstyleproblem{
320 \tl_if_empty:NTF\thistitle{
321 \begin{problemborderbox}
322 }{
323 \begin{problemborderbox}[ (\thistitle)]
324 }
325 }{
326 \end{problemborderbox}
327 }
328 \ExplSyntaxOff
329
330 \stexcssproblem{
331 border-left:3px darkgreen solid;
332 padding-left:3px;
333 margin-left: -3px;
334 calc(var(--rustex-curr-width) + 3px);
335 }{
336 font-weight: bold;
337 font-size:inherit;
338 color:darkgreen;
339 display:block;
340 &::before {
341 content: "Exercise";
342 }
343 }
344
345 \newtcolorbox{experimental}{
346 breakable,
347 enhanced,
348 left=0pt,
349 right=0pt,
350 top=8pt,
351 bottom=8pt,
352 colback=white,
353 colframe=gray,
354 width=\textwidth,
355 enlarge left by=0mm,
356 boxsep=5pt,
357 fontupper=\small,
358 arc=4pt,
359 outer arc=4pt,
360 leftupper=1.5cm,
361 overlay={
362 \node[anchor=west] at ([xshift=10pt]$(frame.north west)!0.5!(frame.south west)$)
363 {\includegraphics[height=1cm]{stex-experimental}};}
364 }
365
366
367 \usetikzlibrary{decorations.pathmorphing,shapes,arrows,calc}
368 % Taken from pgflibrarytikzmmt.code.tex
369 \newcommand{\mmtarrowtip}{angle 45}
370 \newcommand{\mmtarrowtipmonoright}{right hook}
371
372 \tikzstyle{include}=[\mmtarrowtipmonoright-\mmtarrowtip,thick]
373 \tikzstyle{morph}=[-\mmtarrowtip,thick]
374 \tikzstyle{preview}=[decorate, decoration={coil,aspect=0,amplitude=1pt,
375 segment length=6pt,
376 pre=lineto,pre length=3pt,
377 post=lineto,post length=5pt}, thick]
378 \tikzstyle{view}=[preview,-\mmtarrowtip]
379
380
381 % TIKZ RULES
382 \def\mmtlogo{
383 \begin{tikzpicture}
384
385 % White Background (Margins are eyeballed)
386 % This is necessary because we paste white over arrows later.
387 % If somebody want's to do the full song and dance with
388 % interrupted arrows to get transparent background, be my guest.
389
390 \fill[white!] (-0.01,0.15) rectangle (1.11,-0.95);
391
392 % Arrows
393 \draw [blue, include] (0,0) -- (1.1,0);
394 \draw [green, morph] (0,-0.4) -- (1.1,-0.4);
395 \draw [red, view] (-0,-0.8) -- (1.1,-0.8);
396
397 % Cutout for letters
398 \fill[white] (0.33,0.1) rectangle (0.66,-0.9);
399
400 % Letters
401 \node at (0.18,0) (nodeM1) {\large M};
402 \node at (0.18,-0.4) (nodeM2) {\large M};
403 \node at (0.21,-0.8) (nodeT) {\large T};
404
405 \end{tikzpicture}
406 }
407
408 \newtcolorbox{mmtbox}{
409 breakable,
410 enhanced,
411 left=0pt,
412 right=0pt,
413 top=8pt,
414 bottom=8pt,
415 colback=white,
416 colframe=green,
417 width=\textwidth,
418 enlarge left by=0mm,
419 boxsep=5pt,
420 fontupper=\small,
421 arc=4pt,
422 outer arc=4pt,
423 leftupper=1.5cm,
424 overlay={
425 \node[anchor=west] at ([xshift=10pt]$(frame.north west)!0.5!(frame.south west)$)
426 {\mmtlogo};}
427 }
428
429 \newtcolorbox{defibox}{
430 breakable,
431 enhanced,
432 left=0pt,
433 right=0pt,
434 top=8pt,
435 bottom=8pt,
436 colback=white,
437 colframe=orange,
438 width=\textwidth,
439 enlarge left by=0mm,
440 boxsep=5pt,
441 fontupper=\small,
442 leftupper=1.5cm,
443 arc=4pt,
444 outer arc=4pt,
445 overlay={\node[anchor=west] at ([xshift=10pt]$(frame.north west)!0.5!(frame.south west)$)
446 {\textcolor{orange}{\Large\sTeX}};}
447 }
448
449 \stexstyleparagraph[defibox]{
450 \begin{defibox}
451 }{
452 \end{defibox}
453 }
454 \stexcssparagraph[defibox]{
455 border:3px solid orange;
456 padding:3px;
457 margin-left: -6px;
458 width: calc(var(--rustex-curr-width) + 6px);
459 }{
460 font-weight: bold;
461 font-size:inherit;
462 color:orange;
463 display:block;
464 &::before {
465 font-size:larger;
466 content: "sTeX ";
467 }
468 &::after {
469 content: "";
470 }
471 }
472
473 \AtBeginDocument{\catcode`_=8}
474
475 \ExplSyntaxOn
476
477 \bool_new:N \g_stexdoc_typeset_manual_bool
478 \NewDocumentCommand \EnableManual {}{
479 \bool_gset_true:N \g_stexdoc_typeset_manual_bool
480 \renewenvironment{sfunction}{\manualsfunction}{\endmanualsfunction}
481 }
482
483 \NewDocumentCommand \DisableManual {}{
484 \bool_gset_false:N \g_stexdoc_typeset_manual_bool
485 \renewenvironment{sfunction}{\realsfunction}{\endrealsfunction}
486 }
487
488 \NewDocumentEnvironment {stexmanual} {} {
489 \bool_if:NTF \g_stexdoc_typeset_manual_bool
490 {\bool_set_false:N \l__codedoc_in_implementation_bool}
491 {\comment}
492 }{
493 \bool_if:NF \g_stexdoc_typeset_manual_bool {\endcomment}
494 }
495
496
497 \stex_sms_allow_escape:N \stexmacro
498 \protected\def\stexmacro#1{
499 \stex_if_in_module:T{
500 \stex_execute_in_module:e{\tl_set:cn{l_stex_stexmacro_\tl_to_str:n{#1}_path}{\exp_args:Ne\stex_new_symbol_uri:n{\tl_to_str:n{#1}}}}
501 \exp_args:NNe\symdecl*{\tl_to_str:n{#1}}[type=\sn{TeX?macro}]
502 \exp_args:Ne\notation{\tl_to_str:n{#1}}{\comp{\texttt{\textbackslash\detokenize{#1}}}}
503 }
504 }
505
506 \ProvideDocumentEnvironment {manualsfunction}{m O{} +v}{
507 \seq_set_split:Nnn \_stexdoc_sfunction_seq , {#1}
508 \seq_map_inline:Nn \_stexdoc_sfunction_seq {
509 \stex_pseudogroup_with:nn{\stex_smsmode_do:}{\def\stex_smsmode_do:{}\stexmacro{##1}}
510 }
511 \cs_set_eq:NN \dcs \_stexdoc_dcs:
512 \ifstexhtml
513 \def\box_move_up:nn##1##2{\tex_raise:D\__box_dim_eval:n{0pt}##2}
514 \renewenvironment{syntax}{\noindent}{\par}
515 \fi
516 \begin{sparagraph}[style=symdoc,for={#1}]
517 \__codedoc_function:nnw{#2}{#3}
518 }{
519 \stex_if_smsmode:F{\__codedoc_function_end:}
520 \end{sparagraph}
521 }
522
523 \NewDocumentEnvironment{ realsfunction }{ O{} +v m }{
524 \protected\def \StartImpl {\_start_impl_fun:nn{#1}{#2}}
525 \bool_if:NTF \g__codedoc_typeset_documentation_bool {
526 \__codedoc_function:nnw{#1}{#2}
527 \tl_if_empty:nF{#3}{ \begin{syntax} #3 \end{syntax} }
528 }{
529 \bool_if:NTF \g_stexdoc_typeset_manual_bool {
530 \__codedoc_function:nnw{#1}{#2}
531 \tl_if_empty:nF{#3}{ \begin{syntax} #3 \end{syntax} }
532 }
533 {
534 \exp_after:wN \StartImpl \_skip_doc:
535 }
536 }
537 }{
538 \bool_if:NT \g_stexdoc_in_comment_bool {
539 \bool_gset_false:N \g_stexdoc_in_comment_bool
540 \endcomment
541 }
542 \bool_if:NTF \g__codedoc_typeset_implementation_bool {
543 \__codedoc_macro_end:
544 }
545 }
546 \newenvironment{sfunction}{\realsfunction}{\endrealsfunction}
547 \stex_sms_allow_env:n{sfunction}
548
549 \NewDocumentEnvironment{ svariable }{ O{} +v }{
550 \protected\def \StartImpl {\_start_impl_fun:nn{var, #1}{#2}}
551 \bool_if:NTF \g__codedoc_typeset_documentation_bool {
552 \bool_set_false:N \l__codedoc_in_implementation_bool
553 \__codedoc_function:nnw{#1}{#2}
554 }{
555 \exp_after:wN \StartImpl \_skip_doc:
556 }
557 }{
558 \bool_if:NTF \g__codedoc_typeset_implementation_bool {
559 \__codedoc_macro_end:
560 }{
561 \endcomment
562 }
563 }
564
565 \NewDocumentEnvironment{ senvironment }{ +v }{
566 \protected\def \StartImpl {\_start_env_fun:n{#1}}
567 \bool_if:NTF \g__codedoc_typeset_documentation_bool {
568 \bool_set_false:N \l__codedoc_in_implementation_bool
569 \vskip10pt
570 \DescribeEnv{#1}
571 }{
572 \exp_after:wN \StartImpl \_skip_doc:
573 }
574 }{
575 \bool_if:NTF \g__codedoc_typeset_implementation_bool {
576 \endenvironment
577 }{
578 \endcomment
579 }
580 }
581
582 \cs_new:Npn \_skip_doc: #1 \StartImpl {}
583
584 \cs_new_protected:Nn \_start_impl_fun:nn {
585 \bool_if:NT \g__codedoc_typeset_documentation_bool {
586 \__codedoc_function_end:
587 }
588 \bool_if:NTF \g__codedoc_typeset_implementation_bool {
589 \__codedoc_macro:nnw{#1}{#2}
590 }{
591 \bool_gset_true:N \g_stexdoc_in_comment_bool
592 \comment
593 }
594 }
595
596 \cs_new_protected:Nn \_start_env_fun:n {
597 \bool_if:NT \g__codedoc_typeset_documentation_bool {
598 \par
599 }
600 \bool_if:NTF \g__codedoc_typeset_implementation_bool {
601 \environment{#1}
602 }{
603 \bool_gset_true:N \g_stexdoc_in_comment_bool
604 \comment
605 }
606 }
607
608 \bool_new:N \g_stexdoc_in_comment_bool
609
610 \ExplSyntaxOff