# tikzpicture extends over page margin and surrounding text

I tried to compile my MWE with standalone specification, but it did not work, I got errors. So I had to switch to article. Problem here is that the tikzpicture goes over the page margin to the left, and over the surrounding text on the other sides (up and right). Is there any way to control the placement of this picture on the page? I have this in a document that contains more than 20 tikzpictures and none of them behave like this one, and I cannot say I have done something different with this particular one... OK, on the top it can be controlled getting rid of \lipsum[1] and placing normal text with a spaced line end. But I can't place it properly to the right and the left.

%\documentclass{standalone}
\documentclass{article}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{lipsum}
\usepackage{mathtools}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{angles,arrows,calc,chains,intersections,through,backgrounds,patterns,positioning,quotes,decorations}
\usetikzlibrary{decorations.pathreplacing}
%lower the subscript by ex points
\def\dc{\rule{0pt}{1.0ex}}
\def\dd{\rule{0pt}{1.5ex}}
\def\df{\rule{0pt}{1.8ex}}
\def\ds{\rule{0pt}{2.0ex}}
\def\dss{\rule{0pt}{2.5ex}}
\def\dds{\rule{0pt}{3.0ex}}

\begin{document}

%\lipsum[1]
Text here to fill up the page.
Text here to fill up the page.
Text here to fill up the page.
Text here to fill up the page.
Text here to fill up the page.
Text here to fill up the page.
Text here to fill up the page.
\\[1.0cm]

\begin{wrapfigure}[20]{L}{0pt}
\begin{tikzpicture}[>=triangle 45, cap=round]

\coordinate (ORG) at (0.00, 0.00);
\draw[blue, line width=1.75pt, shorten >= -2.0cm, shorten <= -1.5cm, name path = d2] (1,0) -- +(45:9);
\draw[red, line width=1.75pt, shorten >= -2.0cm, shorten <= -1.5cm, name path = d1] (9,0) -- +(150:9);
\path [name intersections={of = d1 and d2}];
\coordinate (P)  at (intersection-1);
\filldraw [red] (P) circle(3pt);

\node[below, green] at ($(P)+(0.50,-2.50)$) {\LARGE\textbf{\textit{$d_{\dd{1}} \,\bigcap\, d_{\dd{2}}$}}};
\node[above, red] at ($(ORG)+(1.50,4.50)$) {\huge\textbf{\textit{$d_{\dd{2}}$}}};
\node[above, blue] at ($(ORG)+(1.50,1.00)$) {\huge\textbf{\textit{$d_{\dd{1}}$}}};
\end{tikzpicture}
\end{wrapfigure}

\lipsum[1]

\end{document}


I'd suggest you some changes:

• Get rid of the shorten keys; if need be, enlarge the lines using the appropriate starting and ending points.
• Scale down a little bit the image.
• Give some proper width to the tikzpicture in the wrapfigure environment (you had 0pt and I changed to 190pt).
• (Optional) Reduce the font size for the labels.

The code:

\documentclass{article}
\usepackage{wrapfig}
\usepackage{float}
\usepackage{lipsum}
\usepackage{mathtools}
\usepackage{color}
\usepackage[usenames,dvipsnames,svgnames,table,x11names]{xcolor}
\usepackage{tikz}
\usetikzlibrary{angles,arrows,calc,chains,intersections,through,backgrounds,patterns,positioning,quotes,decorations}
\usetikzlibrary{decorations.pathreplacing}
%lower the subscript by ex points
\def\dc{\rule{0pt}{1.0ex}}
\def\dd{\rule{0pt}{1.5ex}}
\def\df{\rule{0pt}{1.8ex}}
\def\ds{\rule{0pt}{2.0ex}}
\def\dss{\rule{0pt}{2.5ex}}
\def\dds{\rule{0pt}{3.0ex}}

\begin{document}

\lipsum[1]

\begin{wrapfigure}{L}{190pt}
\centering
\begin{tikzpicture}[baseline,>=triangle 45, cap=round,scale=0.8]
\coordinate (ORG) at (0.00, 0.00);
\draw[blue, line width=1.75pt, name path = d2] (1,0) -- +(45:9);
\draw[red, line width=1.75pt, name path = d1] (9,0) -- +(150:9);
\path [name intersections={of = d1 and d2}];
\coordinate (P)  at (intersection-1);
\filldraw [red] (P) circle(3pt);

\node[below, green] at ($(P)+(0.50,-2.50)$) {\LARGE\textbf{\textit{$d_{\dd{1}} \,\bigcap\, d_{\dd{2}}$}}};
\node[above, red] at ($(ORG)+(1.50,4.50)$) {\huge\textbf{\textit{$d_{\dd{2}}$}}};
\node[above, blue] at ($(ORG)+(1.50,1.00)$) {\huge\textbf{\textit{$d_{\dd{1}}$}}};
\end{tikzpicture}
\end{wrapfigure}

\lipsum[1]

\end{document}


The result:

I wouldn't use \textbf and \textit for math-mode.

• Yes, the shorten statements were the problem, thank you!! – Diegis Aug 6 '15 at 23:56