Sorry if this has been asked before – I vaguely remember seeing something related to this, but can't find it anymore.
So I took a TeXample from here: Boxes with text and math. I edited it a tiny bit to make it shorter. Now, the problem is that although I specified the width of the box to be equal to the \textwidth, it seems to be a bit larger than the area from the left to the right margin, and it also shifted to the right (as is made clear from the showframe package. What it wrong here?
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes,decorations}
\usepackage{amsmath,amssymb}
\usepackage{showframe}
\begin{document}
\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}{\textwidth}
Some text and math blah blah blah
\begin{align}
\dot{n} &= u\cos\psi -v\sin\psi \\
\dot{e} &= u\sin\psi + v\cos\psi
\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}



tcolorboxpackage. – TeXnician Jun 16 '17 at 17:01