我本应得到第一张图片,但我得到的却是第二张图片。我尝试过改变填充,但即使是最小的改变也会造成很大的变化。
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw (-2,-1.5) rectangle (3.5,1.5) node[below left]{$U$};
\fill[gray] (0,0) circle (1cm);
\fill[gray] (1,0) circle (1cm);
\draw (0,0) circle (1cm) node {$A$};
\draw (1.5,0) circle (1cm) node {$B$};
\end{tikzpicture}
\end{center}
\end{document}
答案1
像这样?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw (-2,-1.5) rectangle (3.5,1.5) node[below left]{$U$};
\fill[gray] (0,0) circle (1cm);
\fill[gray] (1,0) circle (1cm);
\draw (0,0) circle (1cm) node[xshift=-5mm] {$A$};
\draw (1,0) circle (1cm) node[xshift=5mm] {$B$};
\end{tikzpicture}
\end{center}
\end{document}
您可能还想使用以下替代方法:
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw (-2,-1.5) rectangle (3.5,1.5) node[below left]{$U$};
\fill[gray] (0,0) circle (1cm);
\fill[gray] (1.5,0) circle (1cm);
\draw (0,0) circle (1cm) node {$A$};
\draw (1.5,0) circle (1cm) node {$B$};
\end{tikzpicture}
\end{center}
\end{document}