# TikZ: using the ellipse command with a start and end angle instead of an arc

Consider the code below:

\documentclass[convert = false]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\begin{document}
\begin{tikzpicture}
\draw[-latex] (0, 0) ellipse [x radius = 3cm, y radius = 2cm, start angle = 30,
end angle = 150];
\end{tikzpicture}
\end{document}


This code produces no compiling errors but it doesn't acknowledge the start and angle or the arrow option. I could use the command arc, but then to have the arc centered at the origin, I would need to define the arc starting coordinate as

\coordinate (P) at ($(0, 0) + (30:3cm and 2cm)$);


And then draw the arc:

\documentclass[convert = false]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\draw[-latex] (0, 0) ellipse [x radius = 3cm, y radius = 2cm,
start angle = 30, end angle = 150];

\coordinate (P) at ($(0, 0) + (30:3cm and 2cm)$);

\draw[thick, red, -latex] ($(0, 0) + (30:3cm and 2cm)$(P) arc
(30:150:3cm and 2cm);
\end{tikzpicture}
\end{document}


This isn't terribly difficult but is there a way to use the ellipse command to achieve the desired result?

• The ellipse command always draws a full ellipse, so unless you're willing to clip it, that's not the way to go. You don't need all that \coordinate and calc stuff for the arc, though: Just use \draw[thick, red, -latex] (30:3cm and 2cm) arc (30:150:3cm and 2cm);. The definition of your coordinate (($(0, 0) + (30:3cm and 2cm)$)) doesn't really make sense: It's perfectly equivalent to just saying (30:3cm and 2cm) (you're simply adding 0 to the coordinates). – Jake Jul 8 '13 at 19:54
• @Jake I don’t think the problem here is the use of calc but that to draw an arc around a coordinate you need to evaluate/input start angle and radii twice. – Qrrbrbirlbel Jul 8 '13 at 22:26
• @Qrrbrbirlbel: Possibly. I wasn't sure from the question (hence the comment), but I am sure that the ($(0, 0) + (30:3cm and 2cm)$) syntax is unnecessary. – Jake Jul 8 '13 at 22:28
• – Qrrbrbirlbel Nov 10 '13 at 3:09

You can define a new style that automates setting the start coordinate and drawing the arc:

\tikzset{
partial ellipse/.style args={#1:#2:#3}{
insert path={+ (#1:#3) arc (#1:#2:#3)}
}
}


Then you can simply say

\draw[thick, red, -latex] (0,0) [partial ellipse=30:150:3cm and 2cm];


to draw the arc:

Apart from defining a custom to path or an insert path solution, one could re-define the way TikZ draws its arc. For that, I add two keys:

• move to start,
• line to start.

This implementation does only affect the superior [ ] syntax, though (but that could be changed with a small fix to \tikz@do@arc).

The advantage of settings this up as a key is that it can be applied to a scope or to a path and can be used inside other styles.

## Code

\documentclass[tikz]{standalone}
\makeatletter
\def\tikz@arc@opt[#1]{% over-write!
{%
\tikzset{every arc/.try,#1}%
\pgfkeysgetvalue{/tikz/start angle}\tikz@s
\pgfkeysgetvalue{/tikz/end angle}\tikz@e
\pgfkeysgetvalue{/tikz/delta angle}\tikz@d
\ifx\tikz@s\pgfutil@empty%
\pgfmathsetmacro\tikz@s{\tikz@e-\tikz@d}
\else
\ifx\tikz@e\pgfutil@empty%
\pgfmathsetmacro\tikz@e{\tikz@s+\tikz@d}
\fi%
\fi
\tikz@arc@moveto
\xdef\pgf@marshal{\noexpand%
\tikz@do@arc{\tikz@s}{\tikz@e}
}%
\pgf@marshal%
\tikz@arcfinal%
}
\let\tikz@arc@moveto\relax
\def\tikz@arc@movetolineto#1{%
\tikzset{%
move to start/.code=\tikz@arc@movetolineto\pgfpathmoveto,%
line to start/.code=\tikz@arc@movetolineto\pgfpathlineto}
\makeatother
\begin{document}
\coordinate (C) at (rand,rand);
\draw[ultra thick] (C) ellipse [];
\draw[green]   ([shift=(30:1 and .6)] C) arc [start angle=30,   end angle=150];
\draw[red]     (C) -- ++ (180:1 and .6)  arc [start angle=180, delta angle=70] -- cycle;
\draw[blue!50] (C)    ++ (270:1 and .6)  arc [start angle=270, delta angle=80] -- cycle;
\end{tikzpicture}


• @Jake Come to think of it, the **s were not such a good idea. I think using keys is a better approach and suits the system of TikZ better. – Qrrbrbirlbel Jul 9 '13 at 2:19