1

I made a Tikz image that i would like to use as a icon of sorts in my document but as i have tried to displace it to the upper left corner of the document I inicially find that aparently the bounding box of the image is to big for it to move to the left, and then after some experiments with clipping the tikzimage I find that whenever I try to displace the image to begin to the left of where text usually begins, the image becomes cropped at the beginning and is only draw after the line that marks where text usually begins in the page.

That is somewhat strange for in the beginning my image was too much to the left and actually got draw to the rightmost point in the page, so if it where some type of limiting box in the page wouldn't it also crop the image at the right side too ?

is there a way to overcome tis problem ?

As pointed, I should give more specific information, so there it is the code i am using:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{hobby}

\begin{document}
\begin{tikzpicture}[y=28pt, x=28pt,scale =0.5,yscale=-1.1, xscale=1.2]
\draw[help lines,step=8pt] (-6,-1) grid (18,11);
 \clip (-6,-1) rectangle (30,12);
 \path[fill=black ,xshift = -12cm, rotate=-12] (1.93,2.85) to [curve  
 through ={(4.09,2.77)..
 (3.16,0.15)..(0.45,1.68)..(2.37,6.57)..(8.41,7.82)..(12.30,8.08)}]
 (13.36,8.6) .. controls (14.45,8) and (15.50,7.8) .. (19.08,7.96) to
 [curve  through ={(23.36,8.97)..(25.39,10.67)}] (25.22,12.77) 
 .. controls (24.22,9.9) and (21.65,10.45)..(21.09,12.27) to [curve
 through ={(23.46,15.72)..(27.28,12.86)..(25.40,8.13)..(21.72,6.40)..
 (16.44,5.93)..(15.3,5.79)}] (14.49,5.31) .. controls (14.18,5.5) and 
 (14,5.67)..(13.3,5.82) to [curve  through ={(12.4,5.92)..(8.55,5.89)..
 (5.9,5.75)..(2.01,4.06)}] (1.93,2.85) ;


\end{tikzpicture}


\end{document}

And here is a image of what i mean:

enter image description here

  • a tikzpicture has no external spacing it is just a box and so is positioned exactly like a letter and it can be placed on the page in the same way,. With no example provided in your question it is hard to guess what you did, or what went wrong. – David Carlisle Feb 8 at 17:23
  • 1
    \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[remember picture,overlay] \node [below left] at (current page.north west) [draw, fill=cyan, text width=24mm, align=center, font=\tiny] { This is an absolutely positioned text in the upper left corner. }; \end{tikzpicture} \end{document} ? for details see TikZ & PGF manual, page 254 (v3.1.1) – Zarko Feb 8 at 17:28
  • @Zarko To me this example appears as in the rightmost position not in the leftmost. – Felipe Dilho Feb 8 at 17:34
  • 1
    It might be good if you informed @Zarko that this is a continuation of the this post. And I agree with Zarko. The reason why there seems to be a left offset is that the bounding box is not as tight as it could be, and you have no \noindent. – user121799 Feb 8 at 17:40
  • @Zarko I also do not know what the OP really wants. It could be that they want overlay. – user121799 Feb 8 at 17:47
1

Shift the picture with xshift and yshift to the corner:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{hobby}

\begin{document}

\begin{tikzpicture}[remember picture, overlay,y=28pt, x=28pt,scale =0.5,yscale=-1.1, xscale=1.2,xshift=-2.7cm,yshift=-7.8cm]
\draw[help lines,step=8pt] (-6,-1) grid (18,11);
 \clip (-6,-1) rectangle (30,12);
 \path[fill=black ,xshift = -12cm, rotate=-12] (1.93,2.85) to [curve  
 through ={(4.09,2.77)..
 (3.16,0.15)..(0.45,1.68)..(2.37,6.57)..(8.41,7.82)..(12.30,8.08)}]
 (13.36,8.6) .. controls (14.45,8) and (15.50,7.8) .. (19.08,7.96) to
 [curve  through ={(23.36,8.97)..(25.39,10.67)}] (25.22,12.77) 
 .. controls (24.22,9.9) and (21.65,10.45)..(21.09,12.27) to [curve
 through ={(23.46,15.72)..(27.28,12.86)..(25.40,8.13)..(21.72,6.40)..
 (16.44,5.93)..(15.3,5.79)}] (14.49,5.31) .. controls (14.18,5.5) and 
 (14,5.67)..(13.3,5.82) to [curve  through ={(12.4,5.92)..(8.55,5.89)..
 (5.9,5.75)..(2.01,4.06)}] (1.93,2.85) ;
\end{tikzpicture}


\end{document}
  • Thank you that was exctly what i was looking for, i Just made some small alterations and I got exactly what i was looking for and I didn't NEED to re-scale ANITHING, May God bless you ! – Felipe Dilho Feb 8 at 18:23
5

let me convert my comment to answer:

  • for image positioning use tikzpicture options remember picture,overlay,
  • for determining image size use (only) scale=..., transform shape
  • for grid use node style, which contain:

    path picture={
    \draw[#1,step=#2] (\ppbb.south west) grid (\ppbb.north east);                                  
                  }
    

    where option #1 and #2 determine grid's lines thickness and color, and step size respectively, \ppbb is abbreviation for path picture bounding box

  • redraw image by use of the relative coordinates. by this is enabled positioning drawn image without any tweak with xshift, yshift:

    \documentclass{article}
    \usepackage{tikz}
    \usetikzlibrary{hobby,positioning}
    \newcommand\coo[1]{coordinate (#1)}             % <---
    \newcommand\ppbb{path picture bounding box}     % <---
    
    \begin{document}
    \begin{tikzpicture}[remember picture,overlay,
                        scale=0.2, transform shape, % <--- determine size
    box/.style args = {#1/#2}{draw,#1,
                            minimum width=300mm, minimum height=200mm,
                            anchor=north west, inner sep=0,
                            path picture={
                            \draw[#1,step=#2] (\ppbb.south west) grid (\ppbb.north east);
                                        }
                                },
    box/.default = {ultra thin, gray}/10 mm
                            ]
    \node (s) [box] at (current page.north west) {};
    \path (s.west)  % the starting coordinate forf drawing the image
        -| ++ ( 3.2,-4.8) \coo{a1} -| ++ ( 2.1,-0.1) \coo{a2} |- ++ (-0.9,-2.6) \coo{a3}
        -| ++ (-2.7, 1.5) \coo{a4} |- ++ ( 1.9, 4.9) \coo{a5} |- ++ ( 6.0, 1.2)\coo{a6}
        -| ++ ( 3.9, 0.3) \coo{a7} |- ++ ( 1.1, 0.5) \coo{a8}
    %
        |- ++ ( 1.1,-0.5) \coo{a9}  -| ++ ( 1.5,-0.2) \coo{a10} -| ++ ( 3.2, 0.1) \coo{a11}
        -| ++ ( 4.2, 1.0) \coo{a12} -| ++ ( 2.0, 1.5) \coo{a13} -| ++ (-0.2, 2.3) \coo{a14}
    %
        -| ++ (-0.8,-1.4) \coo{a15} -- ++ (-2.8, 0.0) \coo{a16} -- ++ ( 0.0, 3.0) \coo{a17}
        |- ++ ( 1.9, 1.4) \coo{a18} -| ++ ( 3.8,-2.9) \coo{a19} |- ++ (-1.9,-4.7) \coo{a20}
        |- ++ (-3.7,-1.7) \coo{a21} |- ++ (-5.2,-0.5) \coo{a22} |- ++ (-1.2,-0.2) \coo{a23}
        |- ++ (-0.8,-0.4) \coo{a24}
    %
        |- ++ (-1.1, 0.5) \coo{a25} |- ++ (-1.2, 0.1) \coo{a26} -- ++ (-3.3,-0.0) \coo{a27}
        |- ++ (-5.4,-0.6) \coo{a28} |- ++ (-1.5,-1.2) \coo{a29};
    \fill[red]
        (a1)  to [curve through={(a2) ..(a3) ..(a4) ..(a5) ..(a6)..(a7)}] (a8) --
        (a8)  to [curve through={(a9) ..(a10)..(a11)..(a12)..(a13)}] (a14) --
        (a14) to [curve through={(a15)..(a16)..(a17)..(a18)..(a19)..
                                 (a20)..(a21)..(a22)..(a23)}] (a24) --
        (a24) to [curve through={(a25)..(a26)..(a27)..(a28)..(a29)}] cycle ;
    \end{tikzpicture}
    \end{document}
    

with scale=0.2 and step=10mm

enter image description here

with scale=0.1 and step=10mm

enter image description here

with scale=0.1 and step=15mm

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.