0

I would like to draw a circle with axes in the center of the page, just a little below some text. First I typed:

\begin{tikzpicture}
    \draw (-3,0) -- (3,0);
    \draw (0,-3) -- (0,3);
    \draw (0,0) circle (3cm);
\end{tikzpicture}

This put the circle on the left side of the page. If I change it to

\begin{tikzpicture}
    \draw (2,-1) -- (8,-1);
    \draw (5,-4) -- (5,2);
    \draw (5,-1) circle (3cm);
\end{tikzpicture}

nothing happens. Perhaps I don't understand the coordinate system in TikZ?

  • If you create a standalone file with Tikz and you only write, for example, \fill (0,0) circle (2pt); you'll get a black dot. If you change that to \fill (5,0) circle (2pt);, you'll get the same exact result. The dot is actually 5cm to the right, but without any other reference in the same picture, it'll look the same to you. If you add another dot at the origin, you'll notice the second dot being actually at that distance. – Alenanno Sep 8 '16 at 17:01
  • As Przemyslaw notes, the coordinates are not relative to the page, or text boundary, but only to other things in the tikzpicture, and bounding box (i.e. the outer edge of the diagram) is always adjusted so that it encloses all drawn elements, but no more. This box is placed in the document just like any other box, e.g. an image, or the letter X, so if you want to center it in the textblock, you can for example place it in a center environment. – Torbjørn T. Sep 8 '16 at 17:02
2

The coordinates are relative and the picture is enclosed in a minimal box containing it. If you want to move your coordinates, you can add additional ones. Please compare (not too nice) pictures. Frames are added to see the boxes containing figures.

\documentclass{article}

\usepackage{tikz}

\begin{document}

\framebox{
\begin{tikzpicture}
    \draw (-3,0) -- (3,0);
    \draw (0,-3) -- (0,3);
    \draw (0,0) circle (3cm);
\end{tikzpicture}
}

This put the circle on the left side of the page. If I change it to

\framebox{
\begin{tikzpicture}
    \draw(2,-1) -- (8,-1);
    \draw (5,-4) -- (5,2);
    \draw(5,-1) circle (3cm);
\end{tikzpicture}
}


\framebox{
\begin{tikzpicture}
\node (A) at (0,0) {A};
    \draw(2,-1) -- (8,-1);
    \draw (5,-4) -- (5,2);
    \draw(5,-1) circle (3cm);
\end{tikzpicture}
}
\end{document}

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.