summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tcolorbox/tcolorbox.doc.xparse.tex
blob: f5ad60430ab2e0c3ecbc13853b8bf00b18ca9f7c (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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
% !TeX root = tcolorbox.tex
% include file of tcolorbox.tex (manual of the LaTeX package tcolorbox)
\clearpage
\section{Library \mylib{xparse}}\label{sec:xparse}%
\tcbset{external/prefix=external/xparse_}%
The library is loaded by a package option or inside the preamble by:
\begin{dispListing}
\tcbuselibrary{xparse}
\end{dispListing}
This also loads the package |xparse| \cite{latexproject:xparse}.

The purpose of this library is to give comfortable access to the
powerful document command production with |xparse| for |tcolorbox|.
See the |xparse| package documentation \cite{latexproject:xparse}
for details about the argument \meta{specification} used in this section.

%\subsection{Producing Document Commands With \texttt{xparse}}


\subsection{Option Keys}\label{subsec:xparse_options}

\begin{docTcbKey}{verbatim}{}{style, no value}
  Sets options for a \textit{verbatim} style \refCom{tcbox}.
  Since the indented boxes may contain only very few words, the
  dimensions are made smaller and \refKey{/tcb/nobeforeafter}
  and \refKey{/tcb/tcbox raise base} are set.
\begin{dispExample*}{sbs,lefthand ratio=0.6}
\DeclareTotalTCBox{\myverb}{ v }{verbatim,
  colframe=red!75!black,colupper=blue}{#1}

\myverb{\textbf} is a \myverb{\LaTeX} command.
\end{dispExample*}
\end{docTcbKey}


\begin{docTcbKey}{IfNoValueTF}{=\marg{argument}\marg{true options}\marg{false options}}{no default}
  Wraps the |\IfNoValueTF| command of |xparse| for option setting.
  If the \meta{argument} has no value, the \meta{true options} are set.
  Otherwise, the \meta{false options} are set.
\begin{dispExample}
\DeclareTColorBox{mybox}{ o }{colframe=red!75!black,
  IfNoValueTF={#1}{colback=red!5!white}{enhanced,interior style image=#1}}

\begin{mybox}
This is a tcolorbox.
\end{mybox}

\begin{mybox}[goldshade.png]
This is a tcolorbox.
\end{mybox}
\end{dispExample}
\end{docTcbKey}

\clearpage
\begin{docTcbKey}{IfValueTF}{=\marg{argument}\marg{true options}\marg{false options}}{no default}
  Wraps the |\IfValueTF| command of |xparse| for option setting.
  If the \meta{argument} has a value, the \meta{true options} are set.
  Otherwise, the \meta{false options} are set.
\begin{dispExample}
\DeclareTColorBox{mybox}{ o }{colframe=red!75!black,colback=red!5!white,
  IfValueTF={#1}{title={\flqq #1\frqq},fonttitle=\bfseries}{}}

\begin{mybox}
This is a tcolorbox.
\end{mybox}

\begin{mybox}[My title]
This is a tcolorbox.
\end{mybox}
\end{dispExample}
\end{docTcbKey}

\begin{docTcbKey}{IfBooleanTF}{=\marg{argument}\marg{true options}\marg{false options}}{no default}
  Wraps the |\IfBooleanTF| command of |xparse| for option setting.
  If the \meta{argument} is |\BooleanTue|, the \meta{true options} are set.
  If the \meta{argument} is |\BooleanFalse|, the \meta{false options} are set.

\begin{dispExample}
\DeclareTColorBox{mybox}{ s }{colframe=red!75!black,
  IfBooleanTF={#1}{colback=yellow!50!red}{colback=red!5!white}}

\begin{mybox}
This is a tcolorbox.
\end{mybox}

\begin{mybox}*
This is a tcolorbox.
\end{mybox}
\end{dispExample}
\end{docTcbKey}



\clearpage
\subsection{Producing \texttt{tcolorbox} Environments and Commands}\label{subsec:xparse_tcolorbox}

\begin{docCommand}{DeclareTColorBox}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Creates a new environment \meta{name} based on \refEnv{tcolorbox}.\\
  Basically, |\DeclareTColorBox| operates like |\DeclareDocumentEnvironment|. This means,
  the new environment \meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refEnv{tcolorbox}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new environment is always created, irrespective of an already existing
  environment with the same name.

\begin{dispExample}
% counter from previous example
\DeclareTColorBox[use counter from=pabox]{mybox}{ O{red} m d"" !O{} }
  {enhanced,colframe=#1!75!black,colback=#1!5!white,
   fonttitle=\bfseries,title={\thetcbcounter~#2},
   IfValueTF={#3}{watermark text={#3}}{},#4}

\begin{mybox}{My title}
This is a tcolorbox.
\end{mybox}

\begin{mybox}[blue]{My title}
This is a tcolorbox.
\end{mybox}

\begin{mybox}[green]{My title}"My Watermark"
This is a tcolorbox.
\end{mybox}

\begin{mybox}[yellow]{My title}[colbacktitle=yellow!50!white,coltitle=black]
This is a tcolorbox.
\end{mybox}

\begin{mybox}[purple]{My title}"All together"[coltitle=yellow]
This is a tcolorbox.
\end{mybox}
\end{dispExample}
\end{docCommand}

\clearpage
\begin{docCommand}{NewTColorBox}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTColorBox}, but based on |\NewDocumentEnvironment| instead of |\DeclareDocumentEnvironment|.
  An error is issued if \meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTColorBox}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTColorBox}, but based on |\RenewDocumentEnvironment| instead of |\DeclareDocumentEnvironment|.
  An existing environment is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTColorBox}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTColorBox}, but based on |\ProvideDocumentEnvironment| instead of |\DeclareDocumentEnvironment|.
  The environment \meta{name} is only created if it is not already defined.
\end{docCommand}


\clearpage

\begin{docCommand}{DeclareTotalTColorBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Creates a new command \texttt{\textbackslash}\meta{name} based on \refEnv{tcolorbox}.
  In contrast to \refCom{DeclareTColorBox}, also the \meta{content} of the |tcolorbox| is specified.\\
  Basically, |\DeclareTotalTColorBox| operates like |\DeclareDocumentCommand|. This means,
  the new command \texttt{\textbackslash}\meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refEnv{tcolorbox} which is filled with
  the specified \meta{content}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new command is always created, irrespective of an already existing
  command with the same name.

\begin{dispExample}
\DeclareTotalTColorBox{\diabox}{ O{} v  m }
  { bicolor,nobeforeafter,equal height group=diabox,width=5.7cm,
    fonttitle=\bfseries\ttfamily,adjusted title={#2},center title,
    colframe=blue!20!black,leftupper=0mm,rightupper=0mm,colback=black!75!white,#1}
  { \tikz\path[fill zoom image={#2}] (0,0) rectangle (\linewidth,4cm);%
    \tcblower#3}

\diabox{blueshade.png}{Created with |GIMP|.\\\url{http://www.gimp.org}}
\diabox{goldshade.png}{Created with |GIMP|.\\\url{http://www.gimp.org}}

\end{dispExample}
\end{docCommand}

\begin{docCommand}{NewTotalTColorBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTColorBox}, but based on |\NewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An error is issued if \texttt{\textbackslash}\meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTotalTColorBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTColorBox}, but based on |\RenewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An existing command is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTotalTColorBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTColorBox}, but based on |\ProvideDocumentCommand| instead of |\DeclareDocumentCommand|.
  The command \texttt{\textbackslash}\meta{name} is only created if it is not already defined.
\end{docCommand}


\clearpage
\subsection{Producing \texttt{tcbox} Commands}\label{subsec:xparse_tcbox}


\begin{docCommand}{DeclareTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Creates a new command \texttt{\textbackslash}\meta{name} based on \refCom{tcbox}.
  Basically, |\DeclareTCBox| operates like |\DeclareDocumentCommand|. This means,
  the new command \texttt{\textbackslash}\meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refCom{tcbox}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new command is always created, irrespective of an already existing
  command with the same name.

\begin{dispExample}
% counter from previous example
\DeclareTCBox[use counter from=pabox]{\mybox}{ s m s }
{ nobeforeafter,colback=red!5!white,colframe=red!75!black,
  title={#2 (Box \thetcbcounter)},fonttitle=\bfseries,
  IfBooleanTF={#1}{enhanced,drop shadow}{},
  IfBooleanTF={#3}{colbacktitle=red!50!white}{}  }

\mybox{Bird}{This is my first box.}
  \hfill
\mybox*{Tree}{This is my second box.}
  \par\bigskip
\mybox{Bike}*{This is my third box.}
  \hfill
\mybox*{City}*{This is my fourth box.}
\end{dispExample}
\end{docCommand}

\begin{docCommand}{NewTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBox}, but based on |\NewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An error is issued if \texttt{\textbackslash}\meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBox}, but based on |\RenewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An existing command is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBox}, but based on |\ProvideDocumentCommand| instead of |\DeclareDocumentCommand|.
  The command \texttt{\textbackslash}\meta{name} is only created if it is not already defined.
\end{docCommand}



\clearpage

\begin{docCommand}{DeclareTotalTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Creates a new command \texttt{\textbackslash}\meta{name} based on \refCom{tcbox}.
  In contrast to \refCom{DeclareTCBox}, also the \meta{content} of the |tcbox| is specified.\\
  Basically, |\DeclareTotalTCBox| operates like |\DeclareDocumentCommand|. This means,
  the new command \texttt{\textbackslash}\meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refCom{tcbox} which is filled with
  the specified \meta{content}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new command is always created, irrespective of an already existing
  command with the same name.

\begin{dispExample}
\DeclareTotalTCBox{\myverb}{ O{red} v !O{} }
{ fontupper=\ttfamily,nobeforeafter,tcbox raise base,arc=0pt,outer arc=0pt,
  top=0pt,bottom=0pt,left=0mm,right=0mm,
  leftrule=0pt,rightrule=0pt,toprule=0.3mm,bottomrule=0.3mm,boxsep=0.5mm,
  colback=#1!10!white,colframe=#1!50!black,#3}{#2}

To set a word \textbf{bold} in \myverb{\LaTeX}, use
\myverb[green]{\textbf{bold}}. Alternatively, write
\myverb[yellow]{{\bfseries bold}}.
In \myverb[blue]{\LaTeX}[enhanced,fuzzy halo], other font settings are
done in the same way, e.\,g. \myverb{\textit}, \myverb{\itshape}\\
or \myverb[brown]{\texttt}, \myverb[brown]{\ttfamily}.
\end{dispExample}

The next example uses |\lstinline| from the |listings| package to
typeset the verbatim content.

\begin{dispExample}
% \usepackage{listings} or \tcbuselibrary{listings}
\DeclareTotalTCBox{\commandbox}{ s v }
{verbatim,colupper=white,colback=black!75!white,colframe=black}
{\IfBooleanTF{#1}{\textcolor{red}{\ttfamily\bfseries > }}{}%
  \lstinline[language=command.com,keywordstyle=\color{blue!35!white}\bfseries]^#2^}

\commandbox*{cd "My Documents"} changes to directory \commandbox{My Documents}.

\commandbox*{dir /A} lists the directory content.

\commandbox*{copy example.txt d:\target} copies \commandbox{example.txt} to
  \commandbox{d:\target}.
\end{dispExample}
\end{docCommand}

\clearpage
\begin{docCommand}{NewTotalTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTCBox}, but based on |\NewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An error is issued if \texttt{\textbackslash}\meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTotalTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTCBox}, but based on |\RenewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An existing command is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTotalTCBox}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTCBox}, but based on |\ProvideDocumentCommand| instead of |\DeclareDocumentCommand|.
  The command \texttt{\textbackslash}\meta{name} is only created if it is not already defined.
\end{docCommand}


\begin{docCommand}{tcboxverb}{\oarg{options}\marg{verbatim box content}}
  Creates a colored box based on \refCom{tcbox} which is fitted to the width of the given
  \meta{verbatim box content}.
  The underlying \refCom{tcbox} is styled with
  \refKey{/tcb/verbatim} plus the given \meta{options}.
  The difference to \refCom{tcbox} is that the \meta{verbatim box content} is
  interpreted \textit{verbatim}. Therefore, |\tcboxverb| acts similar to |\verb|.

\begin{dispExample}
\tcboxverb{\LaTeX}, \tcboxverb[colback=blue!10!white,colupper=blue]{\LaTeX},
\tcboxverb[blank,fuzzy halo]{\LaTeX}, \tcboxverb[beamer]{\LaTeX},
\tcboxverb[enhanced,skin=enhancedmiddle jigsaw,colframe=red]{\LaTeX}.
\end{dispExample}
\end{docCommand}




\clearpage
\subsection{Producing \texttt{tcblisting} Environments}\label{subsec:xparse_listing}
\begin{marker}
Besides \mylib{xparse}, the following commands also need the \mylib{listings} library to be included.
\end{marker}

\begin{docCommand}{DeclareTCBListing}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Creates a new environment \meta{name} based on \refEnv{tcblisting}.\\
  Basically, |\DeclareTCBListing| operates like |\DeclareDocumentEnvironment|. This means,
  the new environment \meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refEnv{tcblisting}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new environment is always created, irrespective of an already existing
  environment with the same name.

\begin{dispExample*}{sbs,lefthand ratio=0.5}
\DeclareTCBListing{mybox}{ s O{} m }{%
  colback=red!5!white,
  colframe=red!75!black,
  fonttitle=\bfseries,
  IfBooleanTF={#1}
    {listing side text}
    {text side listing},
  title=#3,#2}

\begin{mybox}{Listing Box}
This is my
\LaTeX\ box.
\end{mybox}
\bigskip

\begin{mybox}*{Listing Box}
This is my
\LaTeX\ box.
\end{mybox}
\bigskip

\begin{mybox}[colback=yellow]
  {Listing Box}
This is my
\LaTeX\ box.
\end{mybox}
\end{dispExample*}
\end{docCommand}



\begin{docCommand}{NewTCBListing}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBListing}, but based on |\NewDocumentEnvironment| instead of |\DeclareDocumentEnvironment|.
  An error is issued if \meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTCBListing}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBListing}, but based on |\RenewDocumentEnvironment| instead of |\DeclareDocumentEnvironment|.
  An existing environment is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTCBListing}{\oarg{init options}\marg{name}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBListing}, but based on |\ProvideDocumentEnvironment| instead of |\DeclareDocumentEnvironment|.
  The environment \meta{name} is only created if it is not already defined.
\end{docCommand}

\clearpage


\begin{marker}
With date of 2018-05-12, the |xparse| \cite{latexproject:xparse} package
changed the argument collection process.
Now, spaces are ignored which leads to a serious change for listing environments
ending with an optional argument like \verb+O{}+.
The former behaviour of respecting spaces can be preserved by adding a \flqq\verb+!+\frqq.
Note that the following code uses \verb+!O{}+ now.
\begin{itemize}
\item For older |xparse| versions, the following code is correct when using \verb+O{}+.
\item For |xparse| of 2018-05-12, only the first two examples of
  the following code using \verb+O{}+ are really \flqq good\frqq\ -- all others do not work.
\item For |xparse| of 2018-05-12 and later, the following code is correct when using \verb+!O{}+.
\end{itemize}
\end{marker}





\begin{dispListing*}{title={Caveats of using an environment ending with an
  optional argument},fonttitle=\bfseries}
\DeclareTCBListing{mybox}{ !O{} }{listing only,#1}

\begin{mybox}[colframe=red]
\good
\end{mybox}

\begin{mybox}[colframe=red]\good\end{mybox}

\begin{mybox}
\good
\end{mybox}

\begin{mybox} \good\end{mybox}

\begin{mybox}\bad!\end{mybox}

\begin{mybox}
[\good]
\end{mybox}

\begin{mybox} [\good]\end{mybox}

\begin{mybox}[\bad!]\end{mybox}
\end{dispListing*}

\clearpage
\subsection{Producing \texttt{tcbinputlisting} Commands}\label{subsec:xparse_inputlisting}
\begin{marker}
The following commands need the \mylib{listings} library to be included.
\end{marker}


\begin{docCommand}{DeclareTCBInputListing}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Creates a new command \texttt{\textbackslash}\meta{name} based on \refCom{tcbinputlisting}.
  Basically, |\DeclareTCBInputListing| operates like |\DeclareDocumentCommand|. This means,
  the new command \texttt{\textbackslash}\meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refCom{tcbinputlisting}.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new command is always created, irrespective of an already existing
  command with the same name.

\begin{dispExample}
% counter from previous example
\DeclareTCBInputListing[use counter from=pabox]{\mylisting}{ O{} O{red} m }{%
  listing file={#3},title=Listing~\thetcbcounter,
  colback=#2!5!white,colframe=#2!50!black,colbacktitle=#2!75!black,
  fonttitle=\bfseries,listing only,#1}

\mylisting[before upper=\textit{This is the included file content:}]
  [blue]{\jobname.tcbtemp}
\end{dispExample}
  \end{docCommand}

\begin{docCommand}{NewTCBInputListing}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBInputListing}, but based on |\NewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An error is issued if \texttt{\textbackslash}\meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTCBInputListing}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBInputListing}, but based on |\RenewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An existing command is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTCBInputListing}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBInputListing}, but based on |\ProvideDocumentCommand| instead of |\DeclareDocumentCommand|.
  The command \texttt{\textbackslash}\meta{name} is only created if it is not already defined.
\end{docCommand}


\clearpage
\subsection{Producing \texttt{tboxfit} Commands}\label{subsec:xparse_tcboxfit}
\begin{marker}
The following commands need the \mylib{fitting} library to be included.
\end{marker}

\begin{docCommand}{DeclareTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Creates a new command \texttt{\textbackslash}\meta{name} based on \refCom{tcboxfit}.
  Basically, |\DeclareTCBoxFit| operates like |\DeclareDocumentCommand|. This means,
  the new command \texttt{\textbackslash}\meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refCom{tcboxfit}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new command is always created, irrespective of an already existing
  command with the same name.

\begin{dispExample*}{sbs,lefthand ratio=0.6}
% \usepackage{lipsum}

\DeclareTCBoxFit{\mybox}{ O{} m !o }
 {colback=red!5!white,
  colframe=red!75!black,
  width=#2,height=#2/3*2,
  IfValueTF={#3}{height=#3}{},
  #1}

\mybox[colback=yellow]{5cm}%
  {\lipsum[2]}

\mybox[colback=yellow]{5cm}[4cm]{\lipsum[2]}
\end{dispExample*}
\end{docCommand}

\begin{docCommand}{NewTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBoxFit}, but based on |\NewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An error is issued if \texttt{\textbackslash}\meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBoxFit}, but based on |\RenewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An existing command is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}}
  Operates like \refCom{DeclareTCBoxFit}, but based on |\ProvideDocumentCommand| instead of |\DeclareDocumentCommand|.
  The command \texttt{\textbackslash}\meta{name} is only created if it is not already defined.
\end{docCommand}

\clearpage

\begin{docCommand}{DeclareTotalTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Creates a new command \texttt{\textbackslash}\meta{name} based on \refCom{tcboxfit}.
  In contrast to \refCom{DeclareTCBoxFit}, also the \meta{content} of the |tcboxfit| is specified.\\
  Basically, |\DeclareTotalTCBoxFit| operates like |\DeclareDocumentCommand|. This means,
  the new command \texttt{\textbackslash}\meta{name} is constructed with the given argument \meta{specification}.
  The \meta{options} are given to the underlying \refCom{tcboxfit} which is filled with
  the specified \meta{content}.\\
  Note that \refKey{/tcb/savedelimiter} is set to the given \meta{name}
  automatically.\\
  The \meta{init options} allow setting up automatic numbering,
  see Section \ref{sec:initkeys} from page \pageref{sec:initkeys}.\\
  The new command is always created, irrespective of an already existing
  command with the same name.

\begin{dispExample}
% \usepackage{lipsum}

\DeclareTotalTCBoxFit{\multibox}{ O{} m O{10} m }
 {nobeforeafter,colback=red!5!white,colframe=red!75!black,width=#2,height=#2/3*2,
  valign=center,#1}
 { \foreach \n in {1,...,#3} { #4} }

\multibox{5cm}{I shall not repeat.}
\multibox[colframe=blue!75!white]{5cm}[20]{I shall not repeat.}\\
\multibox[colback=yellow,height=5cm]{14cm}[100]{I shall not repeat.}
\end{dispExample}
\end{docCommand}

\begin{docCommand}{NewTotalTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTCBoxFit}, but based on |\NewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An error is issued if \texttt{\textbackslash}\meta{name} has already been defined.
\end{docCommand}

\begin{docCommand}{RenewTotalTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTCBoxFit}, but based on |\RenewDocumentCommand| instead of |\DeclareDocumentCommand|.
  An existing command is redefined.
\end{docCommand}

\begin{docCommand}{ProvideTotalTCBoxFit}{\oarg{init options}\brackets{\texttt{\textbackslash}\meta{name}}\marg{specification}\marg{options}\marg{content}}
  Operates like \refCom{DeclareTotalTCBoxFit}, but based on |\ProvideDocumentCommand| instead of |\DeclareDocumentCommand|.
  The command \texttt{\textbackslash}\meta{name} is only created if it is not already defined.
\end{docCommand}