3

I'm trying a very simple use of tikzpicture for drawing an ellipse. My problem is that when I change the coordinates -- say from (0,0) to (10,0) -- nothing happens, i.e., position of the ellipse does not change. Any ideas why?

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
\begin{tikzpicture}
\draw (0,0) ellipse (2cm and .5cm);
\end{tikzpicture}
\end{frame}
\end{document}
  • 1
    Welcome to TeX.SE! The posisioning in tikzpicture is relative. You have to give one point as base (lets say in a \path command) so that the next point will be moved relative to your start point. See my example. – koleygr Oct 13 '17 at 19:47
  • Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. – user36296 Jan 4 '18 at 9:24
6

According to my comment: "the posisioning in tikzpicture is relative. You have to give one point as base (lets say in a \path command) so that the next point will be moved relative to your start point."

Test code:

\documentclass{beamer}
\usepackage{tikz}

\begin{document}
\begin{frame}
\begin{center}
\fbox{
\begin{tikzpicture}
\node at (0,0) {};
\draw (0,0) ellipse (2cm and .5cm);
\end{tikzpicture}}
\end{center}

\begin{center}
\fbox{
\begin{tikzpicture}
\node at (0,0){};
\draw (5,3) ellipse (2cm and .5cm);
\end{tikzpicture}}
\end{center}

\end{frame}
\end{document}

In the first image the minimum x= -2 and maximum =2 from the ellipse. In the second the ellipse starts from x=(5-2)=3 and ends to x=(5+2)=7, but xminimum=0 from the \node command, so the ellipse will be moved 3 cm right. Also ymin=0 (from the node) but ellipse is between y=(3-0.5)=2.5 amd y=(3+0.5)=3.5cm...

Hope that explained what you need.

Output:

enter image description here

So, a good practice is to use empty nodes in xmin, xmax, ymin and ymax and then everything will be as expected. (a rectangle path like \path (x1,y1) rectangle (x2,y2); would be a shorter and better option if you are familiar with that.)

  • You are welcome @Asaf. If your question is answered, please accept the answer you prefer by clicking the tick on its left. – koleygr Oct 13 '17 at 21:18
2

enter image description here

\documentclass{beamer}
\usepackage[utf8]{inputenc}
    \usepackage{tikz}

    \begin{document}

    \begin{tikzpicture}
    \draw[black,thin,xshift=0cm,yshift=0cm] (0,0) grid (4,4);
    \draw (1,1) ellipse (2cm and 1cm);
    \end{tikzpicture}

    \end{document}

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.