我为其编写的代码是 -
\documentclass{article}
\usepackage{amsmath}
\usepackage{pstricks}
\usepackage{auto-pst-pdf}
\usepackage{pst-node,pst-plot}
\begin{document}
\begin{pspicture}(-6,-6)(6,6)
\pscircle(-3,-3){6}
\pscircle(5,-3){6}
\put(-6,-3){$\text{multiples\ of\ 2}$}
\put(5.5,-3){$\text{multiples\ of\ 3}$}
\put(-1,-3){$\text{multiples of 6}$}
\end{pspicture}
\end{document}
我得到的输出是-
你看出问题了吗?
首先,我似乎无法像那样将单词multiples
和of 2
堆叠在一起。而且,我究竟如何为这个特定区域着色。我知道如何为整个圆圈着色,即在画圆圈时将其放在[fillstyle=solid,fillcolor=lightgray]
后面。\pscircle
答案1
我只能在设置unit
为 0.5cm 后重现您的输出。无论如何,此代码生成的图像接近您想要的图像。
\documentclass{article}
\usepackage{pstricks}
\usepackage{amsmath}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}(-6,-6)(6,6)
\pscircle(-3,-3){6}
\pscircle(5,-3){6}
\rput[c](-4,-3){\begin{tabular}{c}multiples\\ of 2
\end{tabular}}
\rput[c](6,-3){\begin{tabular}{c}
multiples\\ of 3
\end{tabular}
}
\pscustom[fillstyle=solid, fillcolor=lightgray, linestyle=solid]{
\psarc(-3,-3){6}{-48}{48}
\psarc(5,-3){6}{132}{228}
}
\rput[c](1,-3){\begin{tabular}{c}
multiples\\ of 6
\end{tabular}}
\end{pspicture}
\end{document}
我还建议使用pstricks
命令\rput
而不是\put
。
答案2
使用剪辑:
\documentclass{article}
\usepackage{pstricks}
\begin{document}
\begin{pspicture}(-6,-3)(6,3)
\rput(-2.5,0){\shortstack{multiples\\of 2}}
\rput(2.5,0){\shortstack{multiples\\ of 3}}
\psclip{\pscircle(-2,0){3}}
\pscircle[fillstyle=solid, fillcolor=lightgray](2,0){3}
\endpsclip
\pscircle(2,0){3}
\rput(0,0){\shortstack{multiples\\ of 6}}
\end{pspicture}
\end{document}
如果你愿意\pscustom
,那么使用
\documentclass{article}
\usepackage{pst-eucl}
\begin{document}
\begin{pspicture}[showgrid](-6,-3)(6,3)
\pstGeonode[PointName=none,PointSymbol=none](-2,0){A}(2,0){B}
\pstInterCC[RadiusA=\pstDistVal{3},RadiusB=\pstDistVal{3}]{A}{}{B}{}{I1}{I2}
\pscustom[fillstyle=solid,fillcolor=red!30]{%
\pstArcOAB{A}{I2}{I1}
\pstArcOAB{B}{I1}{I2}
}
\pscircle(A){3}\pscircle(B){3}
\end{pspicture}
\end{document}
答案3
您可以使用 pst-eucl。
\documentclass[svgnames,dvipsnames]{article}
\usepackage{pstricks,pstricks-add,pst-eucl}
\usepackage{amsmath}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}[showgrid](-9,-6)(11,6)
\pnode(-3,0){A}
\pnode(5,0){B}
\midAB(A)(B){M}
\def\radA{6}
\def\radB{6}
\pscircle(A){\radA}
\pscircle(B){\radB}
\rput[r](A){\shortstack{multiples\\ of 2}}
\rput[l](B){\shortstack{multiples\\ of 3}}
\pstInterCC[DistCoef=1, RadiusA=\pstDistVal{\radA},DistCoef=1,
RadiusB=\pstDistVal{\radB}]{A}{}{B}{}{E}{F}%
\pscustom[fillstyle=solid, fillcolor=lightgray, linestyle=solid]{
\pstArcOAB{A}{F}{E}
\pstArcOAB{B}{E}{F}
}
\rput[c](M){\shortstack{multiples\\ of 6}}
\end{pspicture}
\end{document}
如果需要计算角度,可以在后记中完成:
\documentclass[pstricks,border=5mm,x11names,svgnames,dvipsnames]{standalone}
\usepackage{pstricks-add,pst-eucl}
\usepackage{amsmath}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{unit=0.5cm}
\begin{pspicture}[showgrid,saveNodeCoors,NodeCoorPrefix=n](-9,-6)(11,6)
\pnodes(-3,0){A}(5,0){B}
\midAB(A)(B){M}
\def\radA{6}
\def\radB{6}
\pscircle(A){\radA}
\pscircle(B){\radB}
\rput[r](A){\shortstack{multiples\\ of 2}}
\rput[l](B){\shortstack{multiples\\ of 3}}
\pstInterCC[RadiusA=\pstDistVal{\radA},RadiusB=\pstDistVal{\radB}]{A}{}{B}{}{E}{F}%
\pnode(F){Fq}\pnode(E){Eq}
\pscustom[fillstyle=solid,fillcolor=lightgray,linestyle=solid]{
\psarc(A){\radA}{! nFqy nAy sub nFqx nAx sub atan}{! nEqy nAy sub nEqx nAx sub atan}
\psarc(B){\radB}{! nEqy nBy sub nEqx nBx sub atan}{! nFqy nBy sub nFqx nBx sub atan}
}
\rput[c](M){\shortstack{multiples\\ of 6}}
\end{pspicture}
\end{document}
答案4
使用新的oefill
(奇偶规则)选项。
\documentclass[pstricks]{standalone}
\begin{document}
\begin{pspicture}(-5,-3)(5,3)
\pscustom[fillstyle=oefill,fillcolor=lightgray]{\pscircle(-2,0){3}\pscircle(2,0){3}}
\foreach \x/\y/\t in {-3/0/2,0/0/6,3/0/3}{\rput(\x,\y){\shortstack{multiples\\ of \t}}}
\end{pspicture}
\end{document}
警告
添加红框是为了显示oefill
选项中有一个小错误。你能看到左侧有一个额外的空白吗?还请注意,将oefill
奇怪的“2 的倍数”和“3 的倍数”区域设置为不透明。