| 1 |
\documentclass[a4paper,12pt]{article} |
| 2 |
|
| 3 |
\usepackage{awesomebox} |
| 4 |
|
| 5 |
\usepackage{xltxtra} |
| 6 |
\defaultfontfeatures{Scale=MatchLowercase} |
| 7 |
\setmonofont[Mapping=tex-text,Scale=0.9]{Inconsolata} |
| 8 |
\setromanfont[Mapping=tex-text]{Linux Libertine O} |
| 9 |
\setsansfont[Mapping=tex-text]{Linux Biolinum O} |
| 10 |
|
| 11 |
\usepackage{polyglossia} |
| 12 |
\setdefaultlanguage{english} |
| 13 |
|
| 14 |
\usepackage{minted} |
| 15 |
|
| 16 |
% Comment out the lines above and uncomment the following lines to test |
| 17 |
% usage with pdflatex |
| 18 |
%\usepackage[utf8]{inputenc} |
| 19 |
%\usepackage[T1]{fontenc} |
| 20 |
%\usepackage[english,frenchb]{babel} |
| 21 |
|
| 22 |
\usepackage{geometry} |
| 23 |
\geometry{ |
| 24 |
xetex, |
| 25 |
vmargin=2cm, |
| 26 |
hmargin=3cm, |
| 27 |
includeheadfoot, |
| 28 |
nomarginpar |
| 29 |
} |
| 30 |
\linespread{1.2} |
| 31 |
|
| 32 |
\newcommand{\cf}[1]{(\emph{cf.} section \ref{#1}, % |
| 33 |
<<\,\nameref{#1}\,>>, p. \pageref{#1})} |
| 34 |
|
| 35 |
\usepackage{datetime} |
| 36 |
\newcommand{\colophon}{ |
| 37 |
~\vfill |
| 38 |
\begin{center} |
| 39 |
\scriptsize Handcrafted with \faHeart{} from Nantes, |
| 40 |
France\\ |
| 41 |
Awesome Box is released under the |
| 42 |
\hrefcolor{http://www.wtfpl.net/txt/copying/}{WTFPL}. A copy of this |
| 43 |
license is distributed in this package.\\ |
| 44 |
\tiny version of the \today{} --- \currenttime |
| 45 |
\end{center} |
| 46 |
} |
| 47 |
|
| 48 |
\title{Awesome Boxes} |
| 49 |
\author{Étienne Deparis} |
| 50 |
\date{2019-07-27 v0.6} |
| 51 |
|
| 52 |
% configuration de la transformation en PDF |
| 53 |
\usepackage[pdfusetitle]{hyperref} |
| 54 |
\hypersetup{ |
| 55 |
colorlinks=false, |
| 56 |
pdfborder=0 0 0, |
| 57 |
breaklinks=true, |
| 58 |
bookmarksopen=true, |
| 59 |
pdfcreator=XeLaTeX, |
| 60 |
pdfproducer=XeLaTeX} |
| 61 |
|
| 62 |
\newcommand\hrefcolor[2]{\textcolor{magenta}{\href{#1}{#2}}} |
| 63 |
|
| 64 |
\begin{document} |
| 65 |
|
| 66 |
\maketitle |
| 67 |
|
| 68 |
\section{Introduction} |
| 69 |
|
| 70 |
Awesome Boxes is all about drawing admonition blocks around text to |
| 71 |
inform or alert your readers about something particular. The specific |
| 72 |
aim of this package is to use |
| 73 |
\hrefcolor{https://fontawesome.com/}{FontAwesome 5} icons to ease the |
| 74 |
illustration of these boxes. |
| 75 |
|
| 76 |
The idea of admonition blocks comes from the ones you can easily do with |
| 77 |
\hrefcolor{http://asciidoctor.org/docs/user-manual/\#admonition}{AsciiDoc}. |
| 78 |
|
| 79 |
\section{How to use it?} |
| 80 |
|
| 81 |
Just download this package and call it at the beginning of your |
| 82 |
document: |
| 83 |
|
| 84 |
\begin{center} |
| 85 |
\verb!\usepackage{awesomebox}! |
| 86 |
\end{center} |
| 87 |
|
| 88 |
\section{Provided boxes} |
| 89 |
\subsection{Inline boxes} |
| 90 |
|
| 91 |
The provided boxes follow the name convention of the |
| 92 |
\hrefcolor{http://asciidoctor.org/docs/user-manual/\#admonition}{admonition |
| 93 |
blocks} from \hrefcolor{http://asciidoctor.org}{AsciiDoc}. |
| 94 |
|
| 95 |
\begin{center} |
| 96 |
\verb!\notebox{Lorem ipsum…}! |
| 97 |
\end{center} |
| 98 |
|
| 99 |
\notebox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam |
| 100 |
aliquet libero quis lectus elementum fermentum. |
| 101 |
|
| 102 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 103 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 104 |
egestas commodo nisl.} |
| 105 |
|
| 106 |
\clearpage |
| 107 |
|
| 108 |
\begin{center} |
| 109 |
\verb!\tipbox{Lorem ipsum…}! |
| 110 |
\end{center} |
| 111 |
|
| 112 |
\tipbox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam |
| 113 |
aliquet libero quis lectus elementum fermentum. |
| 114 |
|
| 115 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 116 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 117 |
egestas commodo nisl.} |
| 118 |
|
| 119 |
\begin{center} |
| 120 |
\verb!\warningbox{Lorem ipsum…}! |
| 121 |
\end{center} |
| 122 |
|
| 123 |
\warningbox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam |
| 124 |
aliquet libero quis lectus elementum fermentum. |
| 125 |
|
| 126 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 127 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 128 |
egestas commodo nisl.} |
| 129 |
|
| 130 |
\begin{center} |
| 131 |
\verb!\cautionbox{Lorem ipsum…}! |
| 132 |
\end{center} |
| 133 |
|
| 134 |
\cautionbox{Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam |
| 135 |
aliquet libero quis lectus elementum fermentum. |
| 136 |
|
| 137 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 138 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 139 |
egestas commodo nisl.} |
| 140 |
|
| 141 |
\begin{center} |
| 142 |
\verb!\importantbox{Lorem ipsum…}! |
| 143 |
\end{center} |
| 144 |
|
| 145 |
\importantbox{Lorem ipsum dolor sit amet, consectetur adipiscing |
| 146 |
elit. Nam aliquet libero quis lectus elementum fermentum. |
| 147 |
|
| 148 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 149 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 150 |
egestas commodo nisl.} |
| 151 |
|
| 152 |
\subsection{Environments} |
| 153 |
\label{sec:environments} |
| 154 |
|
| 155 |
You can also insert admonition blocks with an environment syntax. The |
| 156 |
same names can be used, but with a \emph{block} suffix. |
| 157 |
|
| 158 |
\begin{verbatim} |
| 159 |
\begin{noteblock} |
| 160 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam |
| 161 |
aliquet libero quis lectus elementum fermentum. |
| 162 |
\end{noteblock} |
| 163 |
\end{verbatim} |
| 164 |
|
| 165 |
For the exactly same rendering: |
| 166 |
|
| 167 |
\begin{noteblock} |
| 168 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet |
| 169 |
libero quis lectus elementum fermentum. |
| 170 |
|
| 171 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 172 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 173 |
egestas commodo nisl. |
| 174 |
\end{noteblock} |
| 175 |
|
| 176 |
\section{How to add new icons?} |
| 177 |
\label{sec:new-icons} |
| 178 |
|
| 179 |
This package use the |
| 180 |
\hrefcolor{https://www.ctan.org/pkg/fontawesome5}{FontAwesome5 package} |
| 181 |
under the hood. In order to use your own icons, just call the proper |
| 182 |
\verb!\faXxx! command. |
| 183 |
|
| 184 |
For example, if you want to add the \emph{rocket} icon |
| 185 |
(\faRocket), you just have to insert \verb!\faRocket!. |
| 186 |
|
| 187 |
\section{How to create your own box?} |
| 188 |
\label{sec:howtoown} |
| 189 |
\subsection{Inline boxes} |
| 190 |
|
| 191 |
To create your own box, with your own icon and colour, your own |
| 192 |
vertical rule width and colour, your own horizontal rules at the top |
| 193 |
and the bottom of your boxes, or a title, you can use our meta |
| 194 |
command: |
| 195 |
|
| 196 |
\begin{center} |
| 197 |
\verb!\awesomebox[vrulecolor][hrule][title]{vrulewidth}{icon}{iconcolor}{content}! |
| 198 |
\end{center} |
| 199 |
|
| 200 |
Here are some examples of custom boxes: |
| 201 |
|
| 202 |
\begin{center} |
| 203 |
\verb!\awesomebox{5pt}{\faCertificate}{magenta}{Lorem ipsum…}! |
| 204 |
\end{center} |
| 205 |
|
| 206 |
\awesomebox{5pt}{\faCertificate}{magenta}{Lorem ipsum dolor sit amet, |
| 207 |
consectetur adipiscing elit. Nam aliquet libero quis lectus elementum |
| 208 |
fermentum. |
| 209 |
|
| 210 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 211 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 212 |
egestas commodo nisl.} |
| 213 |
|
| 214 |
\clearpage |
| 215 |
|
| 216 |
\begin{center} |
| 217 |
\verb!\awesomebox{0pt}{\faCogs}{black}{Lorem ipsum…}! |
| 218 |
\end{center} |
| 219 |
|
| 220 |
\awesomebox{0pt}{\faCogs}{black}{% |
| 221 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet |
| 222 |
libero quis lectus elementum fermentum. |
| 223 |
|
| 224 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 225 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 226 |
egestas commodo nisl.} |
| 227 |
|
| 228 |
\begin{center} |
| 229 |
\verb!\awesomebox[violet]{2pt}{\faRocket}{violet}{Lorem ipsum…}! |
| 230 |
\end{center} |
| 231 |
|
| 232 |
\awesomebox[violet]{2pt}{\faRocket}{violet}{Lorem ipsum dolor sit amet, |
| 233 |
consectetur adipiscing elit. Nam aliquet libero quis lectus elementum |
| 234 |
fermentum. |
| 235 |
|
| 236 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 237 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 238 |
egestas commodo nisl.} |
| 239 |
|
| 240 |
\vspace{2mm} |
| 241 |
\begin{center} |
| 242 |
\small\verb!\awesomebox[white][\abShortLine]{0pt}{\faGrinBeam[regular]}{black}{Lorem ipsum…}! |
| 243 |
\end{center} |
| 244 |
|
| 245 |
\awesomebox[white][\abShortLine]{0pt}{\faGrinBeam[regular]}{black}{% |
| 246 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet |
| 247 |
libero quis lectus elementum fermentum. |
| 248 |
|
| 249 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 250 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 251 |
egestas commodo nisl.} |
| 252 |
|
| 253 |
\vspace{2mm} |
| 254 |
\begin{center} |
| 255 |
\small\verb!\awesomebox[white][\abLongLine][\textbf{Watch out}]{0pt}{\faBomb}{black}{Lorem…}! |
| 256 |
\end{center} |
| 257 |
|
| 258 |
\awesomebox[white][\abLongLine][\textbf{Watch out}]{0pt}{\faBomb}{black}{% |
| 259 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet |
| 260 |
libero quis lectus elementum fermentum. |
| 261 |
|
| 262 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 263 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 264 |
egestas commodo nisl.} |
| 265 |
|
| 266 |
\subsection{Environments} |
| 267 |
|
| 268 |
To create your own box, with your own icon and colour, your own |
| 269 |
vertical rule width and colour, your own horizontal rules at the top |
| 270 |
and the bottom of your boxes, or a title, you can use our meta |
| 271 |
command: |
| 272 |
|
| 273 |
\begin{verbatim} |
| 274 |
\begin{awesomeblock}[vrulecolor][hrule][title]{vrulewidth}{icon}{iconcolor} |
| 275 |
your text content |
| 276 |
\end{awesomeblock} |
| 277 |
\end{verbatim} |
| 278 |
|
| 279 |
For example, we can rewrite the first previous example as: |
| 280 |
|
| 281 |
\begin{verbatim} |
| 282 |
\begin{awesomeblock}[magenta]{5pt}{\faCertificate}{magenta} |
| 283 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet |
| 284 |
libero quis lectus elementum fermentum. |
| 285 |
\end{awesomeblock} |
| 286 |
\end{verbatim} |
| 287 |
|
| 288 |
Which will render this way: |
| 289 |
|
| 290 |
\begin{awesomeblock}[magenta]{5pt}{\faCertificate}{magenta} |
| 291 |
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam aliquet |
| 292 |
libero quis lectus elementum fermentum. |
| 293 |
|
| 294 |
Fusce aliquet augue sapien, non efficitur mi ornare sed. Morbi at |
| 295 |
dictum felis. Pellentesque tortor lacus, semper et neque vitae, |
| 296 |
egestas commodo nisl. |
| 297 |
\end{awesomeblock} |
| 298 |
|
| 299 |
|
| 300 |
\section{Other options} |
| 301 |
|
| 302 |
Some internal options can be customized, in order to globally modify |
| 303 |
your awesome boxes (either the default ones or your new ones). |
| 304 |
|
| 305 |
\subsection{Left margin} |
| 306 |
|
| 307 |
The left margin is the space left to display the icon before the |
| 308 |
vertical rule. You can change it with the following command |
| 309 |
(\verb!0.12\linewidth! is the default one):\\ |
| 310 |
\verb!\setlength{\aweboxleftmargin}{0.12\linewidth}!. |
| 311 |
|
| 312 |
You must declare you new length \emph{after} the \verb!\begin{document}! |
| 313 |
instruction, or your custom length will be overriden by the default |
| 314 |
one. |
| 315 |
|
| 316 |
\subsection{Content width} |
| 317 |
|
| 318 |
The content width is the space used to insert the body of your |
| 319 |
admonition block. You can change it with the following command |
| 320 |
(\verb!0.88\linewidth! is the default one):\\ |
| 321 |
\verb!\setlength{\aweboxcontentwidth}{0.88\linewidth}!. |
| 322 |
|
| 323 |
You must declare you new length \emph{after} the \verb!\begin{document}! |
| 324 |
instruction, or your custom length will be overriden by the default |
| 325 |
one. |
| 326 |
|
| 327 |
\subsection{Vertical skip} |
| 328 |
|
| 329 |
This space is used before and after the awesome box. You can change it |
| 330 |
with (5mm is the default): \verb!\setlength{\aweboxvskip}{5mm}!. |
| 331 |
|
| 332 |
You can put your new length either in the header or in the body of your |
| 333 |
document. |
| 334 |
|
| 335 |
\subsection{Sign raise} |
| 336 |
|
| 337 |
This length is used to raise (or lower) the left icon. Its default value |
| 338 |
is -5mm and you can change it with: |
| 339 |
\verb!\setlength{\aweboxsignraise}{-5mm}!. |
| 340 |
|
| 341 |
You can put your new length either in the header or in the body of your |
| 342 |
document. |
| 343 |
|
| 344 |
\subsection{Vertical rule width} |
| 345 |
|
| 346 |
This width is used for the vertical rule of our four default boxes. Its |
| 347 |
default value is 2pt and you can change it with: |
| 348 |
\verb!\setlength{\aweboxrulewidth}{2pt}!. |
| 349 |
|
| 350 |
You can put your new length either in the header or in the body of your |
| 351 |
document. |
| 352 |
|
| 353 |
\subsection{Vertical rule default color} |
| 354 |
|
| 355 |
The vertical rule color is an optional argument passed to the commands |
| 356 |
or environments. Its default value is the following (to match the one |
| 357 |
defined by AsciiDoctor) and you can change it this way: |
| 358 |
|
| 359 |
\verb!\definecolor{abvrulecolor}{RGB}{221,221,216}! |
| 360 |
|
| 361 |
\section{With other environments} |
| 362 |
|
| 363 |
Awesome boxes may be used in any other environments, like in a list. |
| 364 |
|
| 365 |
\begin{verbatim} |
| 366 |
\begin{itemize} |
| 367 |
\item My first item |
| 368 |
\item Lorem ipsum… \notebox{Fusce aliquet…} |
| 369 |
\item Last and finally |
| 370 |
\end{itemize} |
| 371 |
\end{verbatim} |
| 372 |
|
| 373 |
will give: |
| 374 |
|
| 375 |
\begin{itemize} |
| 376 |
\item My first item |
| 377 |
\item Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam |
| 378 |
aliquet libero quis lectus elementum fermentum. \notebox{Fusce aliquet |
| 379 |
augue sapien, non efficitur mi ornare sed. Morbi at dictum |
| 380 |
felis. Pellentesque tortor lacus, semper et neque vitae, egestas |
| 381 |
commodo nisl.} |
| 382 |
\item Last and finally |
| 383 |
\end{itemize} |
| 384 |
|
| 385 |
It may contain other environments too, but in that case, you should |
| 386 |
prefer the environment API (see Section \ref{sec:environments}): |
| 387 |
|
| 388 |
\begin{verbatim} |
| 389 |
\begin{importantblock} |
| 390 |
\begin{itemize} |
| 391 |
\item My first item |
| 392 |
\item My second item with \notebox{A note box!} |
| 393 |
\item Last and finally |
| 394 |
\end{itemize} |
| 395 |
\end{importantblock} |
| 396 |
\end{verbatim} |
| 397 |
|
| 398 |
will give: |
| 399 |
|
| 400 |
\begin{importantblock} |
| 401 |
\begin{itemize} |
| 402 |
\item My first item |
| 403 |
\item My second item with \notebox{A note box!} |
| 404 |
\item Last and finally |
| 405 |
\end{itemize} |
| 406 |
\end{importantblock} |
| 407 |
|
| 408 |
Or with a more complex example with minted environment: |
| 409 |
|
| 410 |
\begin{verbatim} |
| 411 |
\begin{noteblock} |
| 412 |
This could be written as: |
| 413 |
|
| 414 |
\begin{minted}{c++} |
| 415 |
std::cout << "hello world!" << std::endl; |
| 416 |
\end{minted} |
| 417 |
\end{noteblock} |
| 418 |
\end{verbatim} |
| 419 |
|
| 420 |
\begin{noteblock} |
| 421 |
This could be written as: |
| 422 |
|
| 423 |
\begin{minted}{c++} |
| 424 |
std::cout << "hello world!" << std::endl; |
| 425 |
\end{minted} |
| 426 |
\end{noteblock} |
| 427 |
|
| 428 |
\section{Breaking changes} |
| 429 |
|
| 430 |
\subsection{Version 0.6} |
| 431 |
|
| 432 |
This version improved a lot block components rendering. Historically, |
| 433 |
awesome box used fixed length to display icon and content. This leads to |
| 434 |
admonition block to overflow or to be thinner than paragraphs around. |
| 435 |
|
| 436 |
Please note that we change default block components width in purpose. It |
| 437 |
used to be \verb!0.08\linewidth! for the margin and |
| 438 |
\verb!0.92\linewidth! for the content. It is now \verb!0.12\linewidth! |
| 439 |
for the margin and \verb!0.88\linewidth! for the content. |
| 440 |
|
| 441 |
We now compute the default \verb!\aweboxleftmargin! and |
| 442 |
\verb!\aweboxcontentwidth! value in a \verb!\AtBeginDocument! |
| 443 |
command. Thus, to avoid your custom lengths to be overriden by the |
| 444 |
default ones, you must declare them \emph{after} the |
| 445 |
\verb!\begin{document}! instruction. |
| 446 |
|
| 447 |
\subsection{Version 0.4} |
| 448 |
|
| 449 |
This version introduced a way to customize the rule color. Thus, the |
| 450 |
commands and environments arguments have been reorganized to be in a |
| 451 |
more logical order. |
| 452 |
|
| 453 |
Historically, the \verb!\awesomebox! command used the following syntax: |
| 454 |
|
| 455 |
\begin{center} |
| 456 |
\verb!\awesomebox{icon}{rulewidth}{iconcolor}{your text content}! |
| 457 |
\end{center} |
| 458 |
|
| 459 |
This syntax now leads to compiling errors, as you must now write it |
| 460 |
as the following example shows you (and as explained in the section |
| 461 |
\ref{sec:howtoown} "\nameref{sec:howtoown}"), to avoid an alternate |
| 462 |
declaration of rule and icon options: |
| 463 |
|
| 464 |
\begin{center} |
| 465 |
\verb!\awesomebox[rulecolor]{rulewidth}{icon}{iconcolor}{your text content}! |
| 466 |
\end{center} |
| 467 |
|
| 468 |
If you only use the provided boxes and environments (the |
| 469 |
\verb!\notebox!, \verb!\tipbox!, \texttt{\textbackslash warn\-ing\-box}, |
| 470 |
\verb!\cautionbox!, \verb!\importantbox! commands or the |
| 471 |
\texttt{noteblock}, \texttt{tipblock}, \texttt{caution\-block}, |
| 472 |
\texttt{warningblock}, \texttt{importantblock} environments) you are not |
| 473 |
affected by this change and your documents will work without any change. |
| 474 |
|
| 475 |
\colophon |
| 476 |
|
| 477 |
\end{document} |