LaTeX: information boxes

A way to have basic information boxes, with automatic numbering for cross referencing is to use mdframed. Apparently this works well when the box needs to split across multiple pages. Useful for review papers, books and theses.

%% Preamble
\documentclass{article}
\usepackage{lipsum}
\usepackage[framemethod=TikZ]{mdframed}

%% Setting box counter
\newcounter{infobox}[section]
\renewcommand{\theinfobox}{\thesection.\arabic{infobox}}

%% Infobox style
\newenvironment{infobox}[1][]{%
    \refstepcounter{infobox}
    \begin{mdframed}[%
        frametitle={Box \theinfobox\ #1},
        skipabove=\baselineskip plus 2pt minus 1pt,
        skipbelow=\baselineskip plus 2pt minus 1pt,
        frametitleaboveskip= 7pt,
        frametitlebelowskip= 7pt,
        linewidth=0pt,
        linecolor=black,
        frametitlerule=false,
        frametitlebackgroundcolor=blue!10,
        backgroundcolor=blue!10,
        roundcorner=7pt,
    ]%
}{%
    \end{mdframed}
}

%% Document
\begin{document}

\section{Blah}
\lipsum[1]

\begin{infobox}[Major theories explaining blah]
\lipsum[3]
\label{info:theories}
\end{infobox}

Box \ref{info:theories} indicates theories explaining blah are
\lipsum[3]

\end{document}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s