![把圆圈放在球体旁边](https://linux22.com/image/446678/%E6%8A%8A%E5%9C%86%E5%9C%88%E6%94%BE%E5%9C%A8%E7%90%83%E4%BD%93%E6%97%81%E8%BE%B9.png)
我试图将圆圈与球体并排放置,这是我的尝试
\documentclass{article}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\begin{figure}[h]
\centering
\begin{minipage}
\centering
\begin{tikzpicture}
\draw[fill=none](0,0) circle (1.0) node [black,yshift=-1.5cm] {2-bola};
\draw[fill=black](0,0) circle (1 pt) node [above] {\tiny a};
\draw[](0,0) -- (1,0) node [midway,above] {$\scriptstyle r$};
\draw (-1,0) arc (180:360:1cm and 0.5cm);
\draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
\draw (0,1) arc (90:270:0.5cm and 1cm);
\draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
\draw (0,0) circle (1cm);
\shade[ball color=blue!10!white,opacity=0.20] (0,0) circle (1cm);
\end{tikzpicture}
\end{minipage}
\hfill
\begin{minipage}
\centering
\begin{tikzpicture}
\draw[fill=none](0,0) circle (1.0) node [black,yshift=-1.5cm] {2-bola};
\draw[fill=black](0,0) circle (1 pt) node [above] {\tiny a};
\draw[](0,0) -- (1,0) node [midway,above] {$\scriptstyle r$};
\end{tikzpicture}
\end{minipage}
\end{figure}
\end{document}
错误是什么?
答案1
删除minipage
图片之间的 s 和空行后,我得到以下结果:
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\begin{figure}[ht]
\centering
\begin{tikzpicture}
\draw[fill=none](0,0) circle (1.0) node [black,yshift=-1.5cm] {2-bola};
\draw[fill=black](0,0) circle (1 pt) node [above] {\tiny a};
\draw[](0,0) -- (1,0) node [midway,above] {$\scriptstyle r$};
\draw (-1,0) arc (180:360:1cm and 0.5cm);
\draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
\draw (0,1) arc (90:270:0.5cm and 1cm);
\draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
\draw (0,0) circle (1cm);
\shade[ball color=blue!10!white,opacity=0.20] (0,0) circle (1cm);
\end{tikzpicture}
\hfil
\begin{tikzpicture}
\draw[fill=none](0,0) circle (1.0) node [black,yshift=-1.5cm] {2-bola};
\draw[fill=black](0,0) circle (1 pt) node [above] {\tiny a};
\draw[](0,0) -- (1,0) node [midway,above] {$\scriptstyle r$};
\end{tikzpicture}
\end{figure}
\end{document}
附录: 但是,您也可以按照以下方式绘制图像:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning,
quotes,
shadings}
\tikzset{
node distance = 2mm and 12mm,
C/.style = {circle, draw, minimum size=#1, inner sep=0pt},
dot/.style = {circle, fill, inner sep=1.2pt, node contents={}},
every edge quotes/.style = {auto, font=\footnotesize, text=black},
S/.style = {ball color=blue!30,opacity=0.20},
}
\begin{document}
\begin{center}
\begin{tikzpicture}
\def\R{1cm}
\shade[S] (0,0) circle[radius=\R];
\node (n1) [C=2*\R, label=below:2-bola] {};
\node (n2) [dot, label=$a$] {};
\draw (n1.west) arc (180:360:1cm and 0.5cm)
(n1.north) arc (90:270:0.5cm and 1cm);
\draw[dashed]
(n1.west) arc (180:0:1cm and 0.5cm)
(n1.north) arc (90:-90:0.5cm and 1cm);
\draw (n2) to [pos=0.6,"$r$"] (n1.east);
\begin{scope}[xshift=44mm]
\shade[S] (0,0) circle[radius=\R];
\node (n1) [C=2*\R, label=below:2-bola] {};
\node (n2) [dot, label=$a$] {};
\draw (n2) to [pos=0.6,"$r$"] (n1.east);
\end{scope}
\end{tikzpicture}
\end{center}
\end{document}
结果与以前非常相似:
答案2
\documentclass{article}
\usepackage{tikz}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{caption}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[fill=none](0,0) circle (1.0) node [black,yshift=-1.5cm] {2-bola};
\draw[fill=black](0,0) circle (1 pt) node [above] {\tiny a};
\draw[](0,0) -- (1,0) node [midway,above] {$\scriptstyle r$};
\draw (-1,0) arc (180:360:1cm and 0.5cm);
\draw[dashed] (-1,0) arc (180:0:1cm and 0.5cm);
\draw (0,1) arc (90:270:0.5cm and 1cm);
\draw[dashed] (0,1) arc (90:-90:0.5cm and 1cm);
\draw (0,0) circle (1cm);
\shade[ball color=blue!10!white,opacity=0.20] (0,0) circle (1cm);
\end{tikzpicture}
\hspace{1cm}
\begin{tikzpicture}
\draw[fill=none](0,0) circle (1.0) node [black,yshift=-1.5cm] {2-bola};
\draw[fill=black](0,0) circle (1 pt) node [above] {\tiny a};
\draw[](0,0) -- (1,0) node [midway,above] {$\scriptstyle r$};
\end{tikzpicture}
\end{center}
\end{document}