\documentclass{minimal}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}
\noindent
\begin{tikzpicture}[trim left = (box.west)]
\node[draw = red] (box) {%
\begin{minipage}{\textwidth}
\lipsum[1]
\end{minipage}
};
\node[left = 1cm] at (box.west) {hello};
\end{tikzpicture}
\lipsum[2]
\end{document}
Is there a way to force the box to have the same width as the text above ?
Without using if possible
\begin{minipage}{0.94\textwidth}
Thanks
minipage
with a width oftextwidth
, your box is obviously larger than the text block below. Could you elaborate about what your problem is exactly?inner xsep
and theinner ysep
value. The red border adds by default anouter xsep
andouter ysep
to the size of the node (by default half the line width) so that the anchors of the node lie at the actual outside. So your actual TikZpicture is\textwidth + 2*/pgf/inner xsep + 2*/pgf/outer xsep
wide. (But remember the bounding box issue of your previous question which would have ignored any outer seps anyway.) So:\begin{minipage}{\dimexpr\textwidth-.6666ex-.4pt\relax}
would be a start. (Default inner sep is .3333ex and default linewidth is .4pt.)tcolorbox
package?