据我所知,我可以使用以下方法绘制一个圆圈:
\draw (1,0) circle (2)
我尝试用这种方法画\draw
椭圆,失败了。你能告诉我如何画椭圆吗?下面的代码有什么问题?
代码如下:
\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}
答案1
PSTricks 的椭圆语法可能更接近您的要求。这里就是\psellipse(<centerX, centerY>)(<semi-major-length, semi-minor-length>)
。
\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}
答案2
\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}
编辑:
\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}
答案3
pgfmanual 给出了\draw (a,b) circle [x radius=1cm, y radius=2cm];
使用宏
\newcommand{\boundellipse}[3]% center, x rad, y rad
{(#1) ellipse [x radius=#2,y radius=#3]
}