Debian Codegraph @

texmf-dist/doc/latex/tcolorbox/tcolorbox-example.tex

raw
1 %% The LaTeX package tcolorbox - version 6.9.0 (2025/11/28)
2 %% tcolorbox-example.tex: an example for tcolorbox
3 %%
4 %% -------------------------------------------------------------------------------------------
5 %% Copyright (c) 2006-2025 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
6 %% -------------------------------------------------------------------------------------------
7 %%
8 %% This work may be distributed and/or modified under the
9 %% conditions of the LaTeX Project Public License, either version 1.3
10 %% of this license or (at your option) any later version.
11 %% The latest version of this license is in
12 %% http://www.latex-project.org/lppl.txt
13 %% and version 1.3 or later is part of all distributions of LaTeX
14 %% version 2005/12/01 or later.
15 %%
16 %% This work has the LPPL maintenance status `author-maintained'.
17 %%
18 %% This work consists of all files listed in README
19 %%
20 % arara: pdflatex: { }
21 % arara: pdflatex: { synctex: yes }
22 %
23 \documentclass{article}
24 \usepackage{lipsum,lmodern}
25 \usepackage[most]{tcolorbox}
26
27 \begin{document}
28
29 %----------------------------------------------------------
30 \section{Colored boxes}
31
32 \begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
33 My box.
34 \end{tcolorbox}
35
36 \begin{tcolorbox}[colback=blue!5!white,colframe=blue!75!black,title=My title]
37 My box with my title.
38 \end{tcolorbox}
39
40 \begin{tcolorbox}[colback=green!5!white,colframe=green!75!black]
41 Upper part of my box.
42 \tcblower
43 Lower part of my box.
44 \end{tcolorbox}
45
46 \begin{tcolorbox}[colback=yellow!5!white,colframe=yellow!50!black,
47 colbacktitle=yellow!75!black,title=My title]
48 I can do this also with a title.
49 \tcblower
50 Lower part of my box.
51 \end{tcolorbox}
52
53 \begin{tcolorbox}[colback=yellow!10!white,colframe=red!75!black,lowerbox=invisible,
54 savelowerto=\jobname_ex.tex]
55 Now, we play hide and seek. Where is the lower part?
56 \tcblower
57 I'm invisible until you find me.
58 \end{tcolorbox}
59
60 \begin{tcolorbox}[colback=yellow!10!white,colframe=red!75!black,title=Here I am]
61 \input{\jobname_ex.tex}
62 \end{tcolorbox}
63
64
65 \begin{tcolorbox}[enhanced,sharp corners=uphill,
66 colback=blue!50!white,colframe=blue!25!black,coltext=yellow,
67 fontupper=\Large\bfseries,arc=6mm,boxrule=2mm,boxsep=5mm,
68 borderline={0.3mm}{0.3mm}{white}]
69 Funny settings.
70 \end{tcolorbox}
71
72
73 \begin{tcolorbox}[enhanced,frame style image=blueshade.png,
74 opacityback=0.75,opacitybacktitle=0.25,
75 colback=blue!5!white,colframe=blue!75!black,
76 title=My title]
77 This box is filled with an external image.\par
78 Title and interior are made partly transparent to show the image.
79 \end{tcolorbox}
80
81
82 \begin{tcolorbox}[enhanced,attach boxed title to top center={yshift=-3mm,yshifttext=-1mm},
83 colback=blue!5!white,colframe=blue!75!black,colbacktitle=red!80!black,
84 title=My title,fonttitle=\bfseries,
85 boxed title style={size=small,colframe=red!50!black} ]
86 This box uses a \textit{boxed title}. The box of the title can
87 be formatted independently from the main box.
88 \end{tcolorbox}
89
90
91 \clearpage
92 %----------------------------------------------------------
93 \section{\LaTeX-Examples}
94
95 \begin{tcblisting}{colback=red!5!white,colframe=red!75!black}
96 This is a \LaTeX\ example:
97 \begin{equation}
98 \sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.
99 \end{equation}
100 \end{tcblisting}
101
102
103 \begin{tcblisting}{colback=red!5!white,colframe=red!75!black,listing side text,
104 title=Side by side,fonttitle=\bfseries}
105 This is a \LaTeX\ example:
106 \begin{equation}
107 \sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.
108 \end{equation}
109 \end{tcblisting}
110
111
112 %----------------------------------------------------------
113 \section{Theorems}
114
115 \newtcbtheorem[auto counter,number within=section]{theo}%
116 {Theorem}{fonttitle=\bfseries\upshape, fontupper=\slshape,
117 arc=0mm, colback=blue!5!white,colframe=blue!75!black}{theorem}
118
119 \begin{theo}{Summation of Numbers}{summation}
120 For all natural number $n$ it holds:
121 \begin{equation}
122 \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
123 \end{equation}
124 \end{theo}
125
126 We have given Theorem \ref{theorem:summation} on page \pageref{theorem:summation}.
127
128 \newtcbtheorem[use counter from=theo]{antheo}%
129 {Theorem}{theorem style=change,oversize,enlarge top by=1mm,enlarge bottom by=1mm,
130 enhanced jigsaw,interior hidden,fuzzy halo=1mm with green,
131 fonttitle=\bfseries\upshape,fontupper=\slshape,
132 colframe=green!75!black,coltitle=green!50!blue!75!black}{antheorem}
133
134 \begin{antheo}{Summation of Numbers}{summation}
135 For all natural number $n$ it holds:
136 \begin{equation}
137 \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
138 \end{equation}
139 \end{antheo}
140
141 %----------------------------------------------------------
142 \section{Watermarks}
143
144 \begin{tcolorbox}[enhanced,watermark graphics=Basilica_5.png,
145 watermark opacity=0.3,watermark zoom=0.9,
146 colback=green!5!white,colframe=green!75!black,
147 fonttitle=\bfseries, title=Box with a watermark picture]
148 Here, you see my nice box with a picture as a watermark.
149 This picture is automatically resized to fit the dimensions
150 of my box. Instead of a picture, some text could be used or
151 arbitrary graphical code. See the documentation for more options.
152 \end{tcolorbox}
153
154 %----------------------------------------------------------
155 \section{Boxes in boxes}
156 \begin{tcolorbox}[colback=yellow!10!white,colframe=yellow!50!black,
157 every box/.style={fonttitle=\bfseries},title=Box]
158 \begin{tcolorbox}[enhanced,colback=red!10!white,colframe=red!50!black,
159 colbacktitle=red!85!black,
160 title=Box inside box,drop fuzzy shadow]
161 \begin{tcolorbox}[beamer,colframe=blue!50!black,title=Box inside box inside box]
162 And now for something completely different: Boxes!\par\medskip
163 \newtcbox{\mybox}[1][]{nobeforeafter,tcbox raise base,colframe=green!50!black,colback=green!10!white,
164 sharp corners,top=1pt,bottom=1pt,before upper=\strut,#1}
165 \mybox[rounded corners=west]{This} \mybox{is} \mybox{another} \mybox[rounded corners=east]{box.}
166 \end{tcolorbox}
167 \end{tcolorbox}
168 \end{tcolorbox}
169
170
171
172 %----------------------------------------------------------
173 \section{Breakable Boxes}
174 \begin{tcolorbox}[enhanced jigsaw,breakable,pad at break*=1mm,
175 colback=blue!5!white,colframe=blue!75!black,title=Breakable box,
176 watermark color=white,watermark text=\Roman{tcbbreakpart}]
177 \lipsum[1-12]
178 \end{tcolorbox}
179
180 %----------------------------------------------------------
181 \clearpage
182 \section{Fit Boxes}
183
184 \begin{tcolorbox}[enhanced,fit to height=10cm,
185 colback=green!25!black!10!white,colframe=green!75!black,title=Fit box (10cm),
186 drop fuzzy shadow,watermark color=white,watermark text=Fit]
187 \lipsum[1-4]
188 \end{tcolorbox}
189
190 \begin{tcolorbox}[enhanced,fit to height=5cm,
191 colback=green!25!black!10!white,colframe=green!75!black,title=Fit box (5cm),
192 drop fuzzy shadow,watermark color=white,watermark text=Fit]
193 \lipsum[1-4]
194 \end{tcolorbox}
195
196 %----------------------------------------------------------
197 \begin{tcolorbox}[tile,size=fbox,boxsep=2mm,boxrule=0pt,
198 colback=blue!20!black,colbacktitle=yellow!40!black,
199 phantom={\thispagestyle{empty}},
200 title=\section{Rasters of Boxes},spread=-1cm]
201 \begin{tcbitemize}[raster columns=3,raster rows=4,raster equal skip=2mm,
202 raster height=\tcbtextheight,
203 title={Box~\thetcbrasternum},fonttitle=\bfseries,
204 enhanced,colframe=blue!50,colback=blue!5]
205 \tcbitem A
206 \tcbitem[flip title={interior hidden}] B
207 \tcbitem[colbacktitle=blue!40!black] C
208 \tcbitem[colbacktitle=blue!40!black,flip title] D
209 \tcbitem[beamer] E
210 \tcbitem[tile,colbacktitle=red!40!black] F
211 \tcbitem[tile,colbacktitle=red!40!black,flip title={sharp corners}] G
212 \tcbitem[blankest]
213 \begin{tcbitemize}[raster columns=2,raster rows=2,raster height=\tcbtextheight,
214 tile,halign=center,valign=center,fontupper=\bfseries\Huge,before upper=\strut,
215 colback=green!20]
216 \tcbitem a
217 \tcbitem b
218 \tcbitem c
219 \tcbitem d
220 \end{tcbitemize}
221 \tcbitem[widget] I
222 \tcbitem[frame style image=goldshade,opacityback=0.5,colback=white] J
223 \tcbitem[frame style image=blueshade,opacityback=0.5,colback=white,
224 center title,flip title={frame hidden,opacityback=0.25,colback=black}] K
225 \tcbitem[octogon arc,arc is angular,halign=center,valign=center,
226 detach title,watermark text={\tcbtitletext}] L
227 \end{tcbitemize}
228 \end{tcolorbox}
229
230
231
232 \end{document}
233