# Remove indentation from a colored box made with tikz

I have a document which looks like this:

Code is like this:

\documentclass[10pt]{memoir}
\usepackage{lipsum}
\usepackage{tikz}

\usetikzlibrary{shapes,backgrounds,patterns}
\tikzstyle{box} = [align=center, text width=12.4cm, draw=blue, fill=blue, rectangle, rounded corners,
inner sep=5pt, inner ysep=5pt]

\begin{document}
\lipsum
~\\
\begin{tikzpicture}
\node[box](box){\color{white}\textbf{white text on blue background}};
\node[shape=circle,fill=white,inner sep=2mm] at (box.west) {};
\node[text=blue,right=-3pt] at (box.west) {\textbf{1}};
\end{tikzpicture}
~\\
\lipsum
\end{document}

I'd like the tikzpicture not to be indented and to be vertically aligned with the text. I tried with \noindent before \begin{tikzpicture} but it doesn't seem to work ...

Any suggestion?

-

If you add draw to your circle node, you will see that your box IS aligned with the text. If you do not want the left of the circle to be counted against the bounding box, use overlay:

\node[shape=circle,fill=white,inner sep=2mm, overlay] at (box.west) {};

Even better solution is to join the two last nodes:

\lipsum
~\\
\begin{tikzpicture}
\node[box](box){\color{white}\textbf{white text on blue background}};
\node[shape=circle,fill=white,
text=blue,right=-3pt] at (box.west) {\textbf{1}};
\end{tikzpicture}
~\\
\lipsum
-
wow, I completely forgot the circle! Thank you very much! :) –  dcmst Jan 16 '13 at 20:09

The white circle contributes to the bounding box of the tikzpicture. That can be turned off by optionoverlay. Then it remains theinner sepof the text inside the circle. The example below compensates by using\hspace*` (star form at the beginning of a line). Also it reduces the width of the box for better fitting into the line width.

\documentclass[10pt]{memoir}
\usepackage{lipsum}
\usepackage{tikz}

\usetikzlibrary{shapes,backgrounds,patterns}
\tikzstyle{box} = [align=center, text width=\the\dimexpr\linewidth-10pt\relax,
draw=blue, fill=blue,
rectangle, rounded corners,
inner sep=5pt, inner ysep=5pt]

\begin{document}
\lipsum
~\\
\hspace*{-.3333em}%
\begin{tikzpicture}
\node[box](box){\color{white}\textbf{white text on blue background}};
\node[overlay,shape=circle,fill=white,inner sep=2mm] at (box.west) {};
\node[text=blue,right=-3pt] at (box.west) {\textbf{1}};
\end{tikzpicture}
~\\
\lipsum
\end{document}

-
thank you for all the suggestions! –  dcmst Jan 16 '13 at 20:42

Well, it is actually vertically aligned. For example, if we color the circle green, like this:

\begin{tikzpicture}
\node[box] (box){\color{white}\textbf{white text on blue background}};
\node[shape=circle,fill=green,inner sep=2mm] at (box.west) {};
\node[text=blue,right=-3pt] at (box.west) {\textbf{1}};
\draw [brown] (current bounding box.south west) rectangle
(current bounding box.north east);
\end{tikzpicture}

We get

So I guess what you want is to place some of the circle outside of the bounding box, like this:

\begin{tikzpicture}
\node[box] (box){\color{white}\textbf{white text on blue background}};
\node[shape=circle,fill=white,inner sep=2mm] at (box.west) (circle) {};
\node[text=blue,right=-3pt] at (box.west) {\textbf{1}};
\pgfresetboundingbox
\useasboundingbox (circle.north) rectangle (box.south east);
\end{tikzpicture}

From which you get

-