-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.tex
243 lines (194 loc) · 5.89 KB
/
demo.tex
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
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{minted}
\usepackage[align]{flatbox}
\usemintedstyle{colorful}
\newminted{latex}{linenos}
\newcommand{\dashskip}{%
\begin{center}
\rule{3em}{.1pt}
\end{center}}
\BeforeBeginEnvironment{latexcode}{\medskip\textit{\underline{\LaTeX{} code:}}}
\title{Demo of \texttt{flatbox}}
\author{Léo Valais}
\date\today
\begin{document}
\maketitle
Dependencies:
\begin{itemize}
\item xcolor
\item tcolorbox
\item ifthen
\item applecolors (optional)
\end{itemize}
\section{Presentation}
The package \texttt{flabox} provides three kind of \texttt{tcolorbox}es:
\begin{itemize}
\item \texttt{flatbox}: boxes without background
\item \texttt{ffbox}: boxes with filled background
\item \texttt{groupbox}: another kind of minimalistic box
\end{itemize}
\begin{flatbox}{Title}
I'm a \texttt{flatbox}.
\end{flatbox}
\begin{ffbox}{Title}
I'm a \texttt{ffbox}.
\end{ffbox}
\begin{groupbox}{Title}
I'm a \texttt{groupbox}.
\end{groupbox}
\begin{latexcode}
\begin{flatbox}{Title}
I'm a \texttt{flatbox}.
\end{flatbox}
\begin{ffbox}{Title}
I'm a \texttt{ffbox}.
\end{ffbox}
\begin{groupbox}{Title}
I'm a \texttt{groupbox}.
\end{groupbox}
\end{latexcode}
These boxes can have an empty title:
\begin{flatbox}{}
I'm a \texttt{flatbox} without title.
\end{flatbox}
\begin{ffbox}{}
I'm a \texttt{ffbox} without title.
\end{ffbox}
\begin{groupbox}{}
I'm a \texttt{groupbox}.
\end{groupbox}
\begin{latexcode}
\begin{flatbox}{}
I'm a \texttt{flatbox} without title.
\end{flatbox}
\begin{ffbox}{}
I'm a \texttt{ffbox} without title.
\end{ffbox}
\begin{groupbox}{}
I'm a \texttt{groupbox}.
\end{groupbox}
\end{latexcode}
\subsection{Colors}
Since these boxes are intentionally simplistic, the main point one wants to
customize is the colors. To define \texttt{flatbox}-compatible colors, use \texttt{$\backslash$setflatboxcolor}.
\begin{latexcode}
\setflatboxcolor[fg]{hippie}{red} % same as \setflatboxcolor{hippie}{red}
\setflatboxcolor[bg]{hippie}{green}
\end{latexcode}
For \texttt{flatbox}es, the background color is useless and it is not even
necessary to define it.
Then, to use this color combination, pass the name of the combination as an
optional parameter to the boxes:
\begin{latexcode}
\begin{flatbox}[hippie]{Hippie flatbox}
I'm a hippie box.
\end{flatbox}
\begin{ffbox}[hippie]{Hippie flatbox}
I'm a hippie box.
\end{ffbox}
\end{latexcode}
\setflatboxcolor[fg]{hippie}{red} % same as \setflatboxcolor{hippie}{red}
\setflatboxcolor[bg]{hippie}{green}
\begin{flatbox}[hippie]{Hippie flatbox}
I'm a hippie box.
\end{flatbox}
\begin{ffbox}[hippie]{Hippie flatbox}
I'm a hippie box.
\end{ffbox}
\medskip
Alternatively, you can manually define the colors using the \texttt{xcolor}
package facilities:
\begin{latexcode}
\colorlet{flatboxhippie.fg}{red}
\definecolor{flatboxhippie.bg}{RGB}{0,255,0}
\end{latexcode}
\bigskip
The \texttt{flatbox} package defines some default colors for the environments
\texttt{flatbox}, \texttt{exampleflatbox}, \texttt{alertflatbox},
\texttt{noteflatbox}, \texttt{theoremflatbox},
\texttt{ffbox}, \texttt{exampleffbox}, \texttt{alertffbox},
\texttt{noteffbox} and \texttt{theoremffbox} which are shown in section \ref{sec:show}.
\dashskip
You can also override default colors, which names are:
\begin{itemize}
\renewcommand{\line}[1]{\item \texttt{flatbox#1.fg} and \texttt{flatbox#1.bg}}
\line{}
\line{example}
\line{alert}
\line{theorem}
\line{note}
\end{itemize}
\dashskip
If the package \texttt{applecolors} is imported \textcolor{red}{\textbf{before}}
\texttt{flatbox}, the iOS colors are used as default colors instead.
\subsection{Error boxes}
This package also defines the command \texttt{$\backslash$errbox} and the
environment \texttt{errorbox} that uses the colors \texttt{flatboxerror.fg} and
\texttt{flatboxerror.bg}. They're sometimes useful to the writter for debugging
purposes or to leave temporary notes but clearly not meant to be kept in the final
document.
I'm a sentance\errbox{oh crap!} with some mistackes\errbox{not again!}.
\begin{errorbox}
Fix spelling (aspell?).
\end{errorbox}
\begin{latexcode}
I'm a sentance\errbox{oh crap!} with some mistackes\errbox{not again!}.
\begin{errorbox}
Fix spelling (aspell?).
\end{errorbox}
\end{latexcode}
\subsection{Package options}
The package \texttt{flatbox} accepts two options:
\begin{itemize}
\item \texttt{rounded}: gives \texttt{ffbox}es rounded corners
\item \texttt{align}: if you wish to use both \texttt{flatbox}es and
\texttt{ffbox}es in the same document, you might want to have their left magin
aligned. This option does that (\texttt{flatbox}es have more indentation otherwise).
This option is used in this document.
\end{itemize}
\newpage
\section{Demo}
\label{sec:show}
Each box just has one (required) parameter: the title (can be empty).
\begin{latexcode}
\begin{style of flatbox}{optional title}
\end{latexcode}
\newcommand{\demo}[2][I'm a demo box.\\Also I like to span over\\multiple\\lines.]{%
\subsection{\texttt{#2flatbox} and \texttt{#2ffbox}}
\begin{minipage}[c]{.5\linewidth}
\begin{#2flatbox}{Demo of \texttt{#2flatbox}}
#1
\end{#2flatbox}
\end{minipage}
\begin{minipage}[c]{.5\linewidth}
\begin{#2ffbox}{Demo of \texttt{#2ffbox}}
#1
\end{#2ffbox}
\end{minipage}
\begin{minipage}[c]{.5\linewidth}
\begin{#2flatbox}{} #1 \end{#2flatbox}
\end{minipage}
\begin{minipage}[c]{.5\linewidth}
\begin{#2ffbox}{} #1 \end{#2ffbox}
\end{minipage}
\begin{minipage}[c]{.5\linewidth}
\begin{#2groupbox}{Demo of \texttt{#2groupbox}}
#1
\end{#2groupbox}
\end{minipage}
\begin{minipage}[c]{.5\linewidth}
\begin{#2groupbox}{} #1 \end{#2groupbox}
\end{minipage}
}
\demo{}
\demo{example}
\demo{alert}
\demo[Stirling's approximation\\\[
\forall n \in \mathbb{N}, n! \sim \sqrt{2 \cdot \pi \cdot n} \cdot \left(\frac{n}{e}\right)^n
\]]{theorem}
\demo{note}
\end{document}