使用 tikzpictures 绘制两个三角形

使用 tikzpictures 绘制两个三角形

我想使用 tikzpicture 包绘制以下两个三角形。

有人可以告诉我怎么做吗?

非常感谢 在此处输入图片描述

答案1

\documentclass[border=3mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric,patterns.meta}
\begin{document}
   \begin{tikzpicture}[fillSt/.style={shape=regular polygon,regular polygon sides=3,draw,thin,pattern={Dots[radius=0.1pt,distance=0.5pt,angle=45]}}]
% triangle left
\node[fillSt](tr-1){};
\draw[thick] (tr-1.corner 2) -- (tr-1.corner 3) ;
%triangle right
\node[fillSt](tr-2) at (1,0){};
\draw[thick,line join=bevel] (tr-2.corner 2) -- (tr-2.corner 1) -- (tr-2.corner 3) ;
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

这个怎么样?

\documentclass{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]
%uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300

%Flowchart: Extract [id:dp6901203222093623] 
\draw  [fill={rgb, 255:red, 155; green, 155; blue, 155 }  ,fill opacity=0.52 ] (135,109) -- (170,170) -- (100,170) -- cycle ;
%Shape: Rectangle [id:dp3827041707489245] 
\draw   (100,169) -- (170,169) -- (170,170) -- (100,170) -- cycle ;
%Shape: Rectangle [id:dp4124155250260684] 
\draw   (238.32,110.4) -- (273.12,171.14) -- (272.25,171.63) -- (237.45,110.9) -- cycle ;
%Flowchart: Extract [id:dp2714396375563397] 
\draw  [fill={rgb, 255:red, 155; green, 155; blue, 155 }  ,fill opacity=0.52 ] (238.32,110.4) -- (273.32,171.4) -- (203.32,171.4) -- cycle ;
%Shape: Rectangle [id:dp9059060773721866] 
\draw   (239.83,111.67) -- (204.18,171.91) -- (203.32,171.4) -- (238.97,111.16) -- cycle ;

\end{tikzpicture}
\end{document}

在此处输入图片描述

答案3

像这样吗?

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{graphicx}
\usetikzlibrary{patterns}
\usepackage{lipsum}

\begin{document}
\lipsum[2][1-3]
\begin{figure}[h!]
\centering
  \tikzset{
pattern size/.store in=\mcSize, 
pattern size = 5pt,
pattern thickness/.store in=\mcThickness, 
pattern thickness = 0.3pt,
pattern radius/.store in=\mcRadius, 
pattern radius = 1pt}
\makeatletter
\pgfutil@ifundefined{pgf@pattern@name@_088n0fwyr}{
\makeatletter
\pgfdeclarepatternformonly[\mcRadius,\mcThickness,\mcSize]{_088n0fwyr}
{\pgfpoint{-0.5*\mcSize}{-0.5*\mcSize}}
{\pgfpoint{0.5*\mcSize}{0.5*\mcSize}}
{\pgfpoint{\mcSize}{\mcSize}}
{
\pgfsetcolor{\tikz@pattern@color}
\pgfsetlinewidth{\mcThickness}
\pgfpathcircle\pgfpointorigin{\mcRadius}
\pgfusepath{stroke}
}}
\makeatother

% Pattern Info
 
\tikzset{
pattern size/.store in=\mcSize, 
pattern size = 5pt,
pattern thickness/.store in=\mcThickness, 
pattern thickness = 0.3pt,
pattern radius/.store in=\mcRadius, 
pattern radius = 1pt}
\makeatletter
\pgfutil@ifundefined{pgf@pattern@name@_w4to3i4nq}{
\makeatletter
\pgfdeclarepatternformonly[\mcRadius,\mcThickness,\mcSize]{_w4to3i4nq}
{\pgfpoint{-0.5*\mcSize}{-0.5*\mcSize}}
{\pgfpoint{0.5*\mcSize}{0.5*\mcSize}}
{\pgfpoint{\mcSize}{\mcSize}}
{
\pgfsetcolor{\tikz@pattern@color}
\pgfsetlinewidth{\mcThickness}
\pgfpathcircle\pgfpointorigin{\mcRadius}
\pgfusepath{stroke}
}}
\makeatother
\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]
%uncomment if require: \path (0,300); %set diagram left start at 0, and has height of 300
%Shape: Triangle [id:dp5325583356831882] 
\draw  [pattern=_088n0fwyr,pattern size=3.9000000000000004pt,pattern thickness=0.75pt,pattern radius=0.75pt, pattern color={rgb, 255:red, 0; green, 0; blue, 0}] (151.5,107) -- (203,189) -- (100,189) -- cycle ;
%Straight Lines [id:da975328210899923] 
\draw [line width=2.25]    (100,189) -- (202,189) ;
%Shape: Triangle [id:dp7838665647025242] 
\draw  [pattern=_w4to3i4nq,pattern size=3.9000000000000004pt,pattern thickness=0.75pt,pattern radius=0.75pt, pattern color={rgb, 255:red, 0; green, 0; blue, 0}] (298.5,108) -- (350,190) -- (247,190) -- cycle ;
%Straight Lines [id:da39505002416627244] 
\draw [line width=2.25]    (247,190) -- (298.5,108) -- (350,190) ;
\end{tikzpicture}
  \caption{Two triangles with patterns.}
  \label{fig:triangle1}
\end{figure}
\lipsum[3][1-2]

\end{document}

相关内容