如何在 LaTeX 中创建此图表?

如何在 LaTeX 中创建此图表?

我想知道如何在 LaTeX 中创建这个完整图形(K4),并根据所显示的内容将边缘涂成蓝色或红色。

任何帮助都将不胜感激。谢谢!

在此处输入图片描述

答案1

使用 Mathcha 的快速解决方案:-)。

\documentclass[12pt]{article}
\usepackage{tikz}
\begin{document}

\tikzset{every picture/.style={line width=0.75pt}} %set default line width to 0.75pt        

\begin{tikzpicture}[x=0.75pt,y=0.75pt,yscale=-1,xscale=1]
\draw [color={rgb, 255:red, 74; green, 144; blue, 226 }  ,draw opacity=1, line width=1mm]   (187,229) -- (364,229) ;
\draw [color={rgb, 255:red, 74; green, 144; blue, 226 }  ,draw opacity=1, line width=1mm]   (364,52) -- (187,229) ;
\draw [color={rgb, 255:red, 74; green, 144; blue, 226 }  ,draw opacity=1, line width=1mm]   (187,52) -- (364,52) ;
\draw [color={rgb, 255:red, 208; green, 2; blue, 27 }  ,draw opacity=1, line width=1mm]   (364,52) -- (364,229) ;
\draw [color={rgb, 255:red, 208; green, 2; blue, 27 }  ,draw opacity=1, line width=1mm  ]   (187,52) -- (364,229) ;
\draw [color={rgb, 255:red, 208; green, 2; blue, 27 }  ,draw opacity=1, line width=1mm  ]   (187,52) -- (187,229) ;
%Shape: Circle [id:dp03642722858449887] 
\draw  [color={rgb, 255:red, 184; green, 233; blue, 134 }  ,draw opacity=1 ][fill={rgb, 255:red, 184; green, 233; blue, 134 }  ,fill opacity=1 ] (173.5,52) .. controls (173.5,44.54) and (179.54,38.5) .. (187,38.5) .. controls (194.46,38.5) and (200.5,44.54) .. (200.5,52) .. controls (200.5,59.46) and (194.46,65.5) .. (187,65.5) .. controls (179.54,65.5) and (173.5,59.46) .. (173.5,52) -- cycle ;
%Shape: Circle [id:dp5110077705683167] 
\draw  [color={rgb, 255:red, 184; green, 233; blue, 134 }  ,draw opacity=1 ][fill={rgb, 255:red, 184; green, 233; blue, 134 }  ,fill opacity=1 ] (350.5,52) .. controls (350.5,44.54) and (356.54,38.5) .. (364,38.5) .. controls (371.46,38.5) and (377.5,44.54) .. (377.5,52) .. controls (377.5,59.46) and (371.46,65.5) .. (364,65.5) .. controls (356.54,65.5) and (350.5,59.46) .. (350.5,52) -- cycle ;
%Shape: Circle [id:dp42972232221333573] 
\draw  [color={rgb, 255:red, 184; green, 233; blue, 134 }  ,draw opacity=1 ][fill={rgb, 255:red, 184; green, 233; blue, 134 }  ,fill opacity=1 ] (350.5,229) .. controls (350.5,221.54) and (356.54,215.5) .. (364,215.5) .. controls (371.46,215.5) and (377.5,221.54) .. (377.5,229) .. controls (377.5,236.46) and (371.46,242.5) .. (364,242.5) .. controls (356.54,242.5) and (350.5,236.46) .. (350.5,229) -- cycle ;
%Shape: Circle [id:dp7505367984521332] 
\draw  [color={rgb, 255:red, 184; green, 233; blue, 134 }  ,draw opacity=1 ][fill={rgb, 255:red, 184; green, 233; blue, 134 }  ,fill opacity=1 ] (173.5,229) .. controls (173.5,221.54) and (179.54,215.5) .. (187,215.5) .. controls (194.46,215.5) and (200.5,221.54) .. (200.5,229) .. controls (200.5,236.46) and (194.46,242.5) .. (187,242.5) .. controls (179.54,242.5) and (173.5,236.46) .. (173.5,229) -- cycle ;
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

一个简单的解决方案pstricks

\documentclass[svgnames]{article}
 \usepackage{pst-node}

\begin{document}

 \[ \psset{arrows=-, linewidth=0.6pt, nodesep=0pt, dotsize=4.5pt, rowsep=1.2cm, colsep = 1.5cm, shortput =tablr}
 \begin{psmatrix}[emnode=dot, linecolor=MediumSeaGreen]
  & & \\%
  & & 
  %%%
\psset{linecolor=DeepSkyBlue}
 \ncline{1,1}{1,2} \ncline{2,1}{2,2} \ncline{2,1}{1,2}
\psset{linecolor=Coral}
\ncline{1,1}{2,1}\ncline{1,2}{2,2}\ncline{1,1}{2,2}
 \end{psmatrix}
 \]

\end{document} 

在此处输入图片描述

相关内容