I've made boxed text into a manuscript using tikz
by following the example in texamples, it works like a charm as long as the box is short enough to fit into a page.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,snakes}
\usepackage{amsmath,amssymb}
\begin{document}
% Define box and box title style
\tikzstyle{mybox} = [draw=red, fill=blue!20, very thick,
rectangle, rounded corners, inner sep=10pt, inner ysep=20pt]
\tikzstyle{fancytitle} =[fill=red, text=white]
\begin{tikzpicture}
\node [mybox] (box){%
\begin{minipage}{0.50\textwidth}
To calculate the horizontal position the kinematic differential
equations are needed:
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\end{align}
For small angles the following approximation can be used:
\begin{align}
\dot{n} &= u -v\delta_\psi \\
\dot{e} &= u\delta_\psi + v
\end{align}
\end{minipage}
};
\node[fancytitle, right=10pt] at (box.north west) {A fancy title};
\node[fancytitle, rounded corners] at (box.east) {$\clubsuit$};
\end{tikzpicture}%
%
\end{document}
Questions
Is there a way to extend the code so that the box break (automatically) through pages?
I just found the mdframed
package,
How could I combine the two packages?
Best Answer
1st version: general box with
mdframed
.You don't need to
combine
both packages, just loadmdframed
withframemethod=TikZ
and look at the example 5 inmdframed-example-tikz.pdf
. I still don't completely understand how it works, but after some trial and error test I produced next code.The result is:
2nd version: exercise box with
mdframed
.As I've told, previous code was taken from an example at
mdframed
documentation. This example is supposed to be used for exercises and I didn't change original names. Now, if you want to type exercises with this format we can come back to the original code, clean it a little bit and obtain:3rd version: general and exercise box with
tcolorbox
.Just for completion, I'd like to add a solution made with
tcolorbox
package. With recent versions it's possible to makebreakable
framed boxes with it.This package provides several libraries to modify it's default behavior, we will need three of them:
breakable
: to allow boxes to automatically break between pages.skins
: to add some overlays over regular boxes.hooks
: to be able of using some special hooks in our code.Next code includes some comments to explain how to use it.