77

As I know, I can draw a circle using:

\draw (1,0) circle (2)

I try this kind of method to draw a \draw ellipse, failed. Would you tell me how to draw a ellipse? What's wrong with the code below?

The code is:

\documentclass{minimal}

\usepackage{tikz}
\usepackage{verbatim}
\begin{document}

% Define the rings. Store them in macros to make things
% more flexible.
 \def\boundellipse {(0,0) ellipse (10,5)}

\begin{tikzpicture}
    % Then we draw the rings
\draw \boundellipse;

\end{tikzpicture}

\end{document} 

5 Answers 5

7

PSTricks' ellipse syntax might be closer to your requirement. Here it is \psellipse(<centerX, centerY>)(<semi-major-length, semi-minor-length>).

enter image description here

\documentclass[pstricks,border=12pt]{standalone}

\begin{document}
\begin{pspicture}[showgrid=true](8,6)
    \psellipse[linecolor=red](4,3)(4,3)
    \pscircle[linecolor=blue](4,3){2}
\end{pspicture}
\end{document}
0
186

enter image description here

\documentclass[border=3pt]{standalone}
\usepackage{tikz}

\begin{document}
\tikz \draw (0,0) ellipse (2cm and 1cm);


or

\begin{tikzpicture}
    \draw (0,0) ellipse (2cm and 1cm);
\end{tikzpicture}
\end{document}

EDIT:

\documentclass[border=3pt]{standalone}
\usepackage{tikz}
\def\myellipse{(0,0) ellipse (2cm and 1cm)}


\begin{document}
\tikz \draw \myellipse ;


or

\begin{tikzpicture}
    \draw \myellipse;
\end{tikzpicture}
\end{document}
2
  • Yes, it did work. Thanks, however if I draw a circle like this way: \def\boundellipse {(0,0) circle(2)} then draw , it can work, why can not ellipse?
    – sweetyBaby
    Jul 28, 2012 at 12:40
  • Is there any way to assign a name to an ellipse drawn this way? I need to store the ellipse in a "variable" (name) and use the name to later align other elements... May 25, 2023 at 6:15
31

The pgfmanual gives \draw (a,b) circle [x radius=1cm, y radius=2cm];

With a macro

\newcommand{\boundellipse}[3]% center, x rad, y rad
{(#1) ellipse [x radius=#2,y radius=#3]
}
1
  • 4
    +1. A pgfmanual extract: "ellipse has exactly the same effect as circle. The older syntax for this command is ellipse ( x radius and y radius ). As for the circle command, this syntax is not as good as the standard syntax." Jul 28, 2012 at 20:46
21

The notion is xdim and ydim, you are using xdim, ydim:

\documentclass{minimal}
\usepackage{tikz}

\begin{document}

\newcommand{\boundellipse}[3]% center, xdim, ydim
{(#1) ellipse (#2 and #3)
}

\begin{tikzpicture}
\draw \boundellipse{0,0}{10}{5};
\draw \boundellipse{4,1}{-2}{4};
\draw \boundellipse{-2,4}{1}{3};

\end{tikzpicture}

\end{document}

enter image description here

5
\documentclass{minimal}
    \usepackage{tikz}
        \begin{document} 
    \begin{tikzpicture}[yscale=2]
     \draw (1,0) circle (2);
     \end{tikzpicture}
    \end{document}

enter image description here

5
  • 1
    by far the simplest and best answer.
    – abcd
    Aug 24, 2017 at 0:37
  • 3
    Why use scale if there's an ellipse function? Nov 26, 2017 at 14:14
  • why not?................
    – Leox
    Nov 26, 2017 at 18:28
  • 8
    @Leox Because this is a bad way of drawing an ellipse that would scale everything else in the drawing. Sep 19, 2021 at 16:31
  • Throw it inside a scope and it will only scale the ellipse. Still wouldn't do it this way, but wouldn't be hard to resolve the issue hperkristiansen points out.
    – kholli
    Feb 7 at 22:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .