ベン図の 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 コードに基づいて、2 つの円に B と C という 2 つの内部名を定義し、それらを参照ポイントとして使用します。この参照ポイントでは、さまざまなスキルを使用してテキストを配置できます。たとえば、above, below, left, right= xx cm of reference points
もabove 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}
答え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
マクロを使用すると、テキスト (またはグラフィック) を既存の画像に重ねることができます。インセットはネストできます。インセットの位置は、基になる画像の左/中央/右および上/中央/下を基準とした図の寸法で指定します。この場合、画像の中心から中心までのオフセットを指定しました。
\parbox
この場合、インセットはテキスト モードですが、数式モード、 es モード、または実際には任意のモードで設定できます。
\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}