我想画出从椭圆表面发出的箭头。这是我得到的(箭头没有接触表面):
\documentclass[border={2pt 2pt 2pt 2pt}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows,positioning}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{fadings,shadings}
\begin{document}
\begin{tikzpicture}[fill=red!20]
\draw (0,0) ellipse (2cm and 1cm);
\foreach \i in {0,45,...,315}
{
\begin{scope}[rotate=\i]
\draw[-latex,thick] (2.1,0) -- (3,0);
\end{scope}
}
\end{tikzpicture}
\结束{文档}
答案1
我通过自定义椭圆节点来解决这个问题:
\documentclass[border={2pt 2pt 2pt 2pt}]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\tikzset{
myellipse/.style args={#1 and #2}{
shape=ellipse,
minimum width=#1,
minimum height=#2,
}
}
\begin{document}
\begin{tikzpicture}
\node[myellipse=2cm and 1cm, draw] (a) at (0,0) {};
\foreach \i in {0, 45, ..., 315} {
\draw[->] (a.\i) -- +(\i:.5cm);
}
\end{tikzpicture}
\end{document}