summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tcolorbox/tcolorbox-example.tex
blob: f1f61989b8ce241260392baceae0e84fa5bf3c20 (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
%% The LaTeX package tcolorbox - version 4.30 (2020/04/28)
%% tcolorbox-example.tex: an example for tcolorbox
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2006-2020 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
%%
% arara: pdflatex: {  }
% arara: pdflatex: { synctex: yes }
%
\documentclass{article}
\usepackage{tikz,lipsum,lmodern}
\usepackage[most]{tcolorbox}

\begin{document}

%----------------------------------------------------------
\section{Colored boxes}

\begin{tcolorbox}[colback=red!5!white,colframe=red!75!black]
  My box.
\end{tcolorbox}

\begin{tcolorbox}[colback=blue!5!white,colframe=blue!75!black,title=My title]
  My box with my title.
\end{tcolorbox}

\begin{tcolorbox}[colback=green!5!white,colframe=green!75!black]
  Upper part of my box.
  \tcblower
  Lower part of my box.
\end{tcolorbox}

\begin{tcolorbox}[colback=yellow!5!white,colframe=yellow!50!black,
  colbacktitle=yellow!75!black,title=My title]
  I can do this also with a title.
  \tcblower
  Lower part of my box.
\end{tcolorbox}

\begin{tcolorbox}[colback=yellow!10!white,colframe=red!75!black,lowerbox=invisible,
  savelowerto=\jobname_ex.tex]
  Now, we play hide and seek. Where is the lower part?
  \tcblower
  I'm invisible until you find me.
\end{tcolorbox}

\begin{tcolorbox}[colback=yellow!10!white,colframe=red!75!black,title=Here I am]
  \input{\jobname_ex.tex}
\end{tcolorbox}


\begin{tcolorbox}[enhanced,sharp corners=uphill,
    colback=blue!50!white,colframe=blue!25!black,coltext=yellow,
    fontupper=\Large\bfseries,arc=6mm,boxrule=2mm,boxsep=5mm,
    borderline={0.3mm}{0.3mm}{white}]
  Funny settings.
\end{tcolorbox}


\begin{tcolorbox}[enhanced,frame style image=blueshade.png,
  opacityback=0.75,opacitybacktitle=0.25,
  colback=blue!5!white,colframe=blue!75!black,
  title=My title]
  This box is filled with an external image.\par
  Title and interior are made partly transparent to show the image.
\end{tcolorbox}


\begin{tcolorbox}[enhanced,attach boxed title to top center={yshift=-3mm,yshifttext=-1mm},
  colback=blue!5!white,colframe=blue!75!black,colbacktitle=red!80!black,
  title=My title,fonttitle=\bfseries,
  boxed title style={size=small,colframe=red!50!black} ]
  This box uses a \textit{boxed title}. The box of the title can
  be formatted independently from the main box.
\end{tcolorbox}


\clearpage
%----------------------------------------------------------
\section{\LaTeX-Examples}

\begin{tcblisting}{colback=red!5!white,colframe=red!75!black}
This is a \LaTeX\ example:
\begin{equation}
\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.
\end{equation}
\end{tcblisting}


\begin{tcblisting}{colback=red!5!white,colframe=red!75!black,listing side text,
  title=Side by side,fonttitle=\bfseries}
This is a \LaTeX\ example:
\begin{equation}
\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.
\end{equation}
\end{tcblisting}


%----------------------------------------------------------
\section{Theorems}

\newtcbtheorem[auto counter,number within=section]{theo}%
  {Theorem}{fonttitle=\bfseries\upshape, fontupper=\slshape,
     arc=0mm, colback=blue!5!white,colframe=blue!75!black}{theorem}

\begin{theo}{Summation of Numbers}{summation}
  For all natural number $n$ it holds:
  \begin{equation}
  \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
  \end{equation}
\end{theo}

We have given Theorem \ref{theorem:summation} on page \pageref{theorem:summation}.

\newtcbtheorem[use counter from=theo]{antheo}%
  {Theorem}{theorem style=change,oversize,enlarge top by=1mm,enlarge bottom by=1mm,
    enhanced jigsaw,interior hidden,fuzzy halo=1mm with green,
     fonttitle=\bfseries\upshape,fontupper=\slshape,
     colframe=green!75!black,coltitle=green!50!blue!75!black}{antheorem}

\begin{antheo}{Summation of Numbers}{summation}
  For all natural number $n$ it holds:
  \begin{equation}
  \tcbhighmath{\sum\limits_{i=1}^n i = \frac{n(n+1)}{2}.}
  \end{equation}
\end{antheo}

%----------------------------------------------------------
\section{Watermarks}

\begin{tcolorbox}[enhanced,watermark graphics=Basilica_5.png,
  watermark opacity=0.3,watermark zoom=0.9,
  colback=green!5!white,colframe=green!75!black,
  fonttitle=\bfseries, title=Box with a watermark picture]
  Here, you see my nice box with a picture as a watermark.
  This picture is automatically resized to fit the dimensions
  of my box. Instead of a picure, some text could be used or
  arbitrary graphical code. See the documentation for more options.
\end{tcolorbox}

%----------------------------------------------------------
\section{Boxes in boxes}
\begin{tcolorbox}[colback=yellow!10!white,colframe=yellow!50!black,
  every box/.style={fonttitle=\bfseries},title=Box]
  \begin{tcolorbox}[enhanced,colback=red!10!white,colframe=red!50!black,
    colbacktitle=red!85!black,
    title=Box inside box,drop fuzzy shadow]
    \begin{tcolorbox}[beamer,colframe=blue!50!black,title=Box inside box inside box]
      And now for something completely different: Boxes!\par\medskip
      \newtcbox{\mybox}[1][]{nobeforeafter,tcbox raise base,colframe=green!50!black,colback=green!10!white,
        sharp corners,top=1pt,bottom=1pt,before upper=\strut,#1}
      \mybox[rounded corners=west]{This} \mybox{is} \mybox{another} \mybox[rounded corners=east]{box.}
    \end{tcolorbox}
  \end{tcolorbox}
\end{tcolorbox}



%----------------------------------------------------------
\section{Breakable Boxes}
\begin{tcolorbox}[enhanced jigsaw,breakable,pad at break*=1mm,
  colback=blue!5!white,colframe=blue!75!black,title=Breakable box,
  watermark color=white,watermark text=\Roman{tcbbreakpart}]
  \lipsum[1-12]
\end{tcolorbox}

%----------------------------------------------------------
\clearpage
\section{Fit Boxes}

\begin{tcolorbox}[enhanced,fit to height=10cm,
  colback=green!25!black!10!white,colframe=green!75!black,title=Fit box (10cm),
  drop fuzzy shadow,watermark color=white,watermark text=Fit]
  \lipsum[1-4]
\end{tcolorbox}

\begin{tcolorbox}[enhanced,fit to height=5cm,
  colback=green!25!black!10!white,colframe=green!75!black,title=Fit box (5cm),
  drop fuzzy shadow,watermark color=white,watermark text=Fit]
  \lipsum[1-4]
\end{tcolorbox}

%----------------------------------------------------------
\begin{tcolorbox}[tile,size=fbox,boxsep=2mm,boxrule=0pt,
    colback=blue!20!black,colbacktitle=yellow!40!black,
    phantom={\thispagestyle{empty}},
    title=\section{Rasters of Boxes},spread=-1cm]
  \begin{tcbitemize}[raster columns=3,raster rows=4,raster equal skip=2mm,
      raster height=\tcbtextheight,
      title={Box~\thetcbrasternum},fonttitle=\bfseries,
      enhanced,colframe=blue!50,colback=blue!5]
    \tcbitem A
    \tcbitem[flip title={interior hidden}] B
    \tcbitem[colbacktitle=blue!40!black] C
    \tcbitem[colbacktitle=blue!40!black,flip title] D
    \tcbitem[beamer] E
    \tcbitem[tile,colbacktitle=red!40!black] F
    \tcbitem[tile,colbacktitle=red!40!black,flip title={sharp corners}] G
    \tcbitem[blankest]
      \begin{tcbitemize}[raster columns=2,raster rows=2,raster height=\tcbtextheight,
          tile,halign=center,valign=center,fontupper=\bfseries\Huge,before upper=\strut,
          colback=green!20]
        \tcbitem a
        \tcbitem b
        \tcbitem c
        \tcbitem d
      \end{tcbitemize}
    \tcbitem[widget] I
    \tcbitem[frame style image=goldshade,opacityback=0.5,colback=white] J
    \tcbitem[frame style image=blueshade,opacityback=0.5,colback=white,
      center title,flip title={frame hidden,opacityback=0.25,colback=black}] K
    \tcbitem[octogon arc,arc is angular,halign=center,valign=center,
      detach title,watermark text={\tcbtitletext}] L
  \end{tcbitemize}
\end{tcolorbox}



\end{document}