Skip to content

Instantly share code, notes, and snippets.

@twhyntie
Last active April 20, 2023 16:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twhyntie/30ef65b696869f86bf740697ecba7c1c to your computer and use it in GitHub Desktop.
Save twhyntie/30ef65b696869f86bf740697ecba7c1c to your computer and use it in GitHub Desktop.
A demonstration of the LaTeX tcolorbox package for writing documentation.
%
% A demonstration of the tcolorbox package.
%
% Run with:
% $ pdflatex tcolorboxdemo.tex
%
\documentclass{article}
\usepackage{xcolor}
\definecolor{grey}{RGB}{0.5,0.5,0.5}
\usepackage{tcolorbox}
% Warning tcolorbox
% #1: tcolorbox options
% #2: Box title
\newtcolorbox{warningbox}[2][]
{
colframe = red!25,
colback = red!10,
coltitle = red!20!black,
title = #2,
#1,
}
% Hint tcolorbox
% #1: tcolorbox options
% #2: Box title
\newtcolorbox{hintbox}[2][]
{
colframe = green!25,
colback = green!10,
coltitle = green!20!black,
title = #2,
#1,
}
% Info (information) tcolorbox
% #1: tcolorbox options
% #2: Box title
\newtcolorbox{infobox}[2][]
{
colframe = grey!25,
colback = grey!10,
coltitle = grey!20!black,
title = #2,
#1,
}
\begin{document}
\begin{hintbox}{Hint}
This is a hint. Hint boxes are used for pointing out things that might
be useful while carrying out the task being described (particularly
where we have received user feedback on a given step!).
\end{hintbox}
\begin{warningbox}{Warning!}
This is a warning. These are used to flag up potential pitfalls or
issues you may need to be aware of to avoid making mistakes or doing
Something Bad.
\end{warningbox}
\begin{infobox}{Point of information}
This is a point of information. These boxes will generally present
things that may not directly relate to the topic being discussed but are
nonetheless interesting.
\end{infobox}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment