summaryrefslogtreecommitdiff
path: root/graphics/awesomebox/awesomebox.tex
blob: 7794b804592c626d33ee45517bfa4dead5965ea7 (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
\documentclass[a4paper,12pt]{article}

\usepackage{awesomebox}

\usepackage{xltxtra}
\defaultfontfeatures{Scale=MatchLowercase}
\setmonofont[Mapping=tex-text,Scale=0.9]{Inconsolata}
\setromanfont[Mapping=tex-text]{Linux Libertine O}
\setsansfont[Mapping=tex-text]{Linux Biolinum O}

\usepackage{polyglossia}
\setdefaultlanguage{english}

\usepackage{minted}

% Comment out the lines above and uncomment the following lines to test
% usage with pdflatex
%\usepackage[utf8]{inputenc}
%\usepackage[T1]{fontenc}
%\usepackage[english,frenchb]{babel}

\usepackage{geometry}
\geometry{
  xetex,
  vmargin=2cm,
  hmargin=3cm,
  includeheadfoot,
  nomarginpar
}
\linespread{1.2}

\newcommand{\cf}[1]{(\emph{cf.} section \ref{#1}, %
  <<\,\nameref{#1}\,>>, p. \pageref{#1})}

\usepackage{datetime}
\newcommand{\colophon}{
  ~\vfill
  \begin{center}
    \scriptsize Handcrafted with \faHeart{} from Nantes,
    France\\
    Awesome Box is released under the
    \hrefcolor{http://www.wtfpl.net/txt/copying/}{WTFPL}. A copy of this
    license is distributed in this package.\\
    \tiny version of the \today{} --- \currenttime
  \end{center}
}

\title{Awesome Boxes}
\author{Étienne Deparis}
\date{2019-07-27 v0.6}

% configuration de la transformation en PDF
\usepackage[pdfusetitle]{hyperref}
\hypersetup{
  colorlinks=false,
  pdfborder=0 0 0,
  breaklinks=true,
  bookmarksopen=true,
  pdfcreator=XeLaTeX,
  pdfproducer=XeLaTeX}

\newcommand\hrefcolor[2]{\textcolor{magenta}{\href{#1}{#2}}}

\begin{document}

\maketitle

\section{Introduction}

Awesome Boxes is all about drawing admonition blocks around text to
inform or alert your readers about something particular. The specific
aim of this package is to use
\hrefcolor{https://fontawesome.com/}{FontAwesome 5} icons to ease the
illustration of these boxes.

The idea of admonition blocks comes from the ones you can easily do with
\hrefcolor{http://asciidoctor.org/docs/user-manual/\#admonition}{AsciiDoc}.

\section{How to use it?}

Just download this package and call it at the beginning of your
document:

\begin{center}
\verb!\usepackage{awesomebox}!
\end{center}

\section{Provided boxes}
\subsection{Inline boxes}

The provided boxes follow the name convention of the
\hrefcolor{http://asciidoctor.org/docs/user-manual/\#admonition}{admonition
  blocks} from \hrefcolor{http://asciidoctor.org}{AsciiDoc}.

\begin{center}
\verb!\notebox{Lorem ipsum…}!
\end{center}

\notebox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
  aliquet libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\clearpage

\begin{center}
\verb!\tipbox{Lorem ipsum…}!
\end{center}

\tipbox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
  aliquet libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\begin{center}
\verb!\warningbox{Lorem ipsum…}!
\end{center}

\warningbox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
  aliquet libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\begin{center}
\verb!\cautionbox{Lorem ipsum…}!
\end{center}

\cautionbox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
  aliquet libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\begin{center}
\verb!\importantbox{Lorem ipsum…}!
\end{center}

\importantbox{Lorem ipsum dolor sit amet, consectetur adipiscing
  elit. Nam aliquet libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\subsection{Environments}
\label{sec:environments}

You can also insert admonition blocks with an environment syntax. The
same names can be used, but with a \emph{block} suffix.

\begin{verbatim}
\begin{noteblock}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
aliquet libero quis lectus elementum fermentum.
\end{noteblock}
\end{verbatim}

For the exactly same rendering:

\begin{noteblock}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet
  libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.
\end{noteblock}

\section{How to add new icons?}
\label{sec:new-icons}

This package use the
\hrefcolor{https://www.ctan.org/pkg/fontawesome5}{FontAwesome5 package}
under the hood. In order to use your own icons, just call the proper
\verb!\faXxx! command.

For example, if you want to add the \emph{rocket} icon
(\faRocket), you just have to  insert \verb!\faRocket!.

\section{How to create your own box?}
\label{sec:howtoown}
\subsection{Inline boxes}

To create your own box, with your own icon and colour, your own
vertical rule width and colour, your own horizontal rules at the top
and the bottom of your boxes, or a title, you can use our meta
command:

\begin{center}
\verb!\awesomebox[vrulecolor][hrule][title]{vrulewidth}{icon}{iconcolor}{content}!
\end{center}

Here are some examples of custom boxes:

\begin{center}
\verb!\awesomebox{5pt}{\faCertificate}{magenta}{Lorem ipsum…}!
\end{center}

\awesomebox{5pt}{\faCertificate}{magenta}{Lorem ipsum dolor sit amet,
  consectetur adipiscing elit. Nam aliquet libero quis lectus elementum
  fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\clearpage

\begin{center}
\verb!\awesomebox{0pt}{\faCogs}{black}{Lorem ipsum…}!
\end{center}

\awesomebox{0pt}{\faCogs}{black}{%
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet
  libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\begin{center}
\verb!\awesomebox[violet]{2pt}{\faRocket}{violet}{Lorem ipsum…}!
\end{center}

\awesomebox[violet]{2pt}{\faRocket}{violet}{Lorem ipsum dolor sit amet,
  consectetur adipiscing elit. Nam aliquet libero quis lectus elementum
  fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\vspace{2mm}
\begin{center}
\small\verb!\awesomebox[white][\abShortLine]{0pt}{\faGrinBeam[regular]}{black}{Lorem ipsum…}!
\end{center}

\awesomebox[white][\abShortLine]{0pt}{\faGrinBeam[regular]}{black}{%
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet
  libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\vspace{2mm}
\begin{center}
\small\verb!\awesomebox[white][\abLongLine][\textbf{Watch out}]{0pt}{\faBomb}{black}{Lorem…}!
\end{center}

\awesomebox[white][\abLongLine][\textbf{Watch out}]{0pt}{\faBomb}{black}{%
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet
  libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.}

\subsection{Environments}

To create your own box, with your own icon and colour, your own
vertical rule width and colour, your own horizontal rules at the top
and the bottom of your boxes, or a title, you can use our meta
command:

\begin{verbatim}
\begin{awesomeblock}[vrulecolor][hrule][title]{vrulewidth}{icon}{iconcolor}
  your text content
\end{awesomeblock}
\end{verbatim}

For example, we can rewrite the first previous example as:

\begin{verbatim}
\begin{awesomeblock}[magenta]{5pt}{\faCertificate}{magenta}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet
  libero quis lectus elementum fermentum.
\end{awesomeblock}
\end{verbatim}

Which will render this way:

\begin{awesomeblock}[magenta]{5pt}{\faCertificate}{magenta}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet
  libero quis lectus elementum fermentum.

  Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at
  dictum felis. Pellentesque tortor lacus, semper et neque vitae,
  egestas commodo nisl.
\end{awesomeblock}


\section{Other options}

Some internal options can be customized, in order to globally modify
your awesome boxes (either the default ones or your new ones).

\subsection{Left margin}

The left margin is the space left to display the icon before the
vertical rule. You can change it with the following command
(\verb!0.12\linewidth! is the default one):\\
\verb!\setlength{\aweboxleftmargin}{0.12\linewidth}!.

You must declare you new length \emph{after} the \verb!\begin{document}!
instruction, or your custom length will be overriden by the default
one.

\subsection{Content width}

The content width is the space used to insert the body of your
admonition block. You can change it with the following command
(\verb!0.88\linewidth! is the default one):\\
\verb!\setlength{\aweboxcontentwidth}{0.88\linewidth}!.

You must declare you new length \emph{after} the \verb!\begin{document}!
instruction, or your custom length will be overriden by the default
one.

\subsection{Vertical skip}

This space is used before and after the awesome box. You can change it
with (5mm is the default): \verb!\setlength{\aweboxvskip}{5mm}!.

You can put your new length either in the header or in the body of your
document.

\subsection{Sign raise}

This length is used to raise (or lower) the left icon. Its default value
is -5mm and you can change it with:
\verb!\setlength{\aweboxsignraise}{-5mm}!.

You can put your new length either in the header or in the body of your
document.

\subsection{Vertical rule width}

This width is used for the vertical rule of our four default boxes. Its
default value is 2pt and you can change it with:
\verb!\setlength{\aweboxrulewidth}{2pt}!.

You can put your new length either in the header or in the body of your
document.

\subsection{Vertical rule default color}

The vertical rule color is an optional argument passed to the commands
or environments. Its default value is the following (to match the one
defined by AsciiDoctor) and you can change it this way:

\verb!\definecolor{abvrulecolor}{RGB}{221,221,216}!

\section{With other environments}

Awesome boxes may be used in any other environments, like in a list.

\begin{verbatim}
\begin{itemize}
\item My first item
\item Lorem ipsum… \notebox{Fusce aliquet…}
\item Last and finally
\end{itemize}
\end{verbatim}

will give:

\begin{itemize}
\item My first item
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam
  aliquet libero quis lectus elementum fermentum. \notebox{Fusce aliquet
    augue sapien, non efficitur mi ornare sed. Morbi at dictum
    felis. Pellentesque tortor lacus, semper et neque vitae, egestas
    commodo nisl.}
\item Last and finally
\end{itemize}

It may contain other environments too, but in that case, you should
prefer the environment API (see Section \ref{sec:environments}):

\begin{verbatim}
\begin{importantblock}
  \begin{itemize}
  \item My first item
  \item My second item with \notebox{A note box!}
  \item Last and finally
  \end{itemize}
\end{importantblock}
\end{verbatim}

will give:

\begin{importantblock}
  \begin{itemize}
  \item My first item
  \item My second item with \notebox{A note box!}
  \item Last and finally
  \end{itemize}
\end{importantblock}

Or with a more complex example with minted environment:

\begin{verbatim}
\begin{noteblock}
  This could be written as:

  \begin{minted}{c++}
    std::cout << "hello world!" << std::endl;
  \end{minted}
\end{noteblock}
\end{verbatim}

\begin{noteblock}
  This could be written as:

  \begin{minted}{c++}
    std::cout << "hello world!" << std::endl;
  \end{minted}
\end{noteblock}

\section{Breaking changes}

\subsection{Version 0.6}

This version improved a lot block components rendering. Historically,
awesome box used fixed length to display icon and content. This leads to
admonition block to overflow or to be thinner than paragraphs around.

Please note that we change default block components width in purpose. It
used to be \verb!0.08\linewidth! for the margin and
\verb!0.92\linewidth! for the content. It is now \verb!0.12\linewidth!
for the margin and \verb!0.88\linewidth! for the content.

We now compute the default \verb!\aweboxleftmargin! and
\verb!\aweboxcontentwidth! value in a \verb!\AtBeginDocument!
command. Thus, to avoid your custom lengths to be overriden by the
default ones, you must declare them \emph{after} the
\verb!\begin{document}! instruction.

\subsection{Version 0.4}

This version introduced a way to customize the rule color. Thus, the
commands and environments arguments have been reorganized to be in a
more logical order.

Historically, the \verb!\awesomebox! command used the following syntax:

\begin{center}
\verb!\awesomebox{icon}{rulewidth}{iconcolor}{your text content}!
\end{center}

This syntax now leads to compiling errors, as you must now write it
as the following example shows you (and as explained in the section
\ref{sec:howtoown} "\nameref{sec:howtoown}"), to avoid an alternate
declaration of rule and icon options:

\begin{center}
\verb!\awesomebox[rulecolor]{rulewidth}{icon}{iconcolor}{your text content}!
\end{center}

If you only use the provided boxes and environments (the
\verb!\notebox!, \verb!\tipbox!, \texttt{\textbackslash warn\-ing\-box},
\verb!\cautionbox!, \verb!\importantbox! commands or the
\texttt{noteblock}, \texttt{tipblock}, \texttt{caution\-block},
\texttt{warningblock}, \texttt{importantblock} environments) you are not
affected by this change and your documents will work without any change.

\colophon

\end{document}