如何在圓圈中加入數字?

如何在圓圈中加入數字?

我想在維恩程序的 3 個地方添加一些數字。但我不知道該怎麼做。

\documentclass{letter}
\usepackage[english]{babel}
\usepackage{tikz}
\def\secondcircle{(210:1.75cm) circle (2.5cm)}
\def\thirdcircle{(330:1.75cm) circle (2.5cm)}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip \secondcircle;
\fill[cyan] \thirdcircle;
\end{scope}
\draw \secondcircle node [text=black,below left] {$B$};
\draw \thirdcircle node [text=black,below right] {$C$};
\end{tikzpicture}
\end{document}

在此輸入影像描述

答案1

根據您的 tikz 程式碼,此嘗試為兩個圓圈定義了兩個名為 B 和 C 的內部名稱,並將它們用作參考點,您可以在其中使用許多技巧來放置文字。舉些例子,above, below, left, right= xx cm of reference pointsabove right/left, below right/left= xx cm of reference也隨時為您服務。你需要\tikzlibrary{positioning}

在此輸入影像描述

代碼:

\documentclass{letter}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{positioning}
\def\secondcircle{(210:1.75cm) circle (2.5cm)}
\def\thirdcircle{(330:1.75cm) circle (2.5cm)}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip \secondcircle;
\fill[cyan] \thirdcircle;
\end{scope}
\draw \secondcircle node(B) [text=black,below left] {$B$};
\draw \thirdcircle node (C)[text=black,below right] {$C$};
\node[left= 1cm of B]{1};
\node[right= 1cm of C]{4};
\node[right= 1.2 cm of B]{23};
\end{tikzpicture}
\end{document}

答案2

這是使用 PSTricks 的一種方法:

\documentclass{article}

\usepackage{pstricks}

\newcommand*\circB{\pscircle(2,2){2}}
\newcommand*\circC{\pscircle(4,2){2}}

\begin{document}

\begin{pspicture}(6,4)
\begin{psclip}{\circB}
 \psset{fillstyle = solid, fillcolor = blue!60}
 \circC
\end{psclip}
\circB
\circC
\rput(1.1,2){$B$}
\rput(4.9,2){$C$}
\rput(3,2){$1,2,3,4$}
\end{pspicture}

\bigskip

\begin{pspicture}(6,4)
\begin{psclip}{}
 \psset{fillstyle = solid, fillcolor = blue!60}
 \circB
 \psset{fillcolor = white}
 \circC
\end{psclip}
\circB
\circC
\rput(1.1,2){$B$}
\rput(4.9,2){$C$}
\rput(3,2){$1,2,3,4$}
\end{pspicture}

\end{document}

輸出2

答案3

您可以使用calc庫來計算相對節點位置,例如這裡

\documentclass{letter}
\usepackage[english]{babel}
\usepackage{tikz}
\usetikzlibrary{calc}
\def\secondcircle{(210:1.75cm) circle (2.5cm)}
\def\thirdcircle{(330:1.75cm) circle (2.5cm)}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip \secondcircle;
\fill[cyan] \thirdcircle;
\end{scope}
\draw \secondcircle node [text=black,below left] (B) {$B$};
\draw \thirdcircle node [text=black,below right] (C) {$C$};
\node at ($(B)!-0.25!(C)$) {1};
\node at ($(B)!0.5!(C)$) {2,3};
\node at ($(B)!1.25!(C)+(0,.5cm)$) {4};
\end{tikzpicture}
\end{document}

在此輸入影像描述

答案4

stackinset巨集允許文字(或圖形)覆蓋現有影像。插圖可以嵌套。插圖的位置在圖形尺寸中指定,相對於底層影像的左/中/右和上/中/下。在本例中,我指定了相對於影像中心的偏移量。

在本例中,插圖是文字模式,但它們可以設定為數學模式、\parboxes 或任何其他模式。

\documentclass{letter}
\usepackage[english]{babel}
\usepackage{stackengine}
\usepackage{tikz}
\def\secondcircle{(210:1.75cm) circle (2.5cm)}
\def\thirdcircle{(330:1.75cm) circle (2.5cm)}
\begin{document}
\stackinset{c}{-2.2cm}{c}{-.25cm}{1}{%
\stackinset{c}{}{c}{}{234}{%
\stackinset{c}{2cm}{c}{0.5cm}{5}{%
\begin{tikzpicture}
\begin{scope}
\clip \secondcircle;
\fill[cyan] \thirdcircle;
\end{scope}
\draw \secondcircle node [text=black,below left] {$B$};
\draw \thirdcircle node [text=black,below right] {$C$};
\end{tikzpicture}%
}}}
\end{document}

在此輸入影像描述

相關內容