如何绘制一个内部有实线的等边三角形?

如何绘制一个内部有实线的等边三角形?

我知道如何绘制这样的三角形:

\begin{tikzpicture}
%Triangle 2
\node at (2,-1) {triangle 2};
\draw (0,0)--(2,0) node[sloped,pos=0.5]{};
\draw (2,0)--(2,2) node[sloped,pos=0.5]{\arrowR};
\draw (0,0)--(2,2) node[sloped,pos=0.5]{\arrowR};
\end{tikzpicture}

但是,我想画的图形是这样的:

在此处输入图片描述

一个等边三角形,里面有一条实线,有人可以帮我画吗?

答案1

首先,没有人可以帮助您,因为您没有提供如何防御的\arrowL方法。\arrowR

我也不知道你对给出的代码有什么不理解这里

您可以使用相应的 tikz 语法简单地将其延长一条线来实现这个三角形\draw

编辑:正如 Rmano 所言,第一个版本嵌套了 tikz 环境。因此,最好使用带装饰的第二个版本。

\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}

\newcommand{\arrowL}{
    \tikz \draw[latex-] (0,0) -- (0.1,0);
}
\newcommand{\arrowR}{
    \tikz \draw[-latex] (0,0) -- (0.1,0);
}

\begin{document}
    \begin{tikzpicture}
        \draw (0,0)--(8,0) node[sloped,pos=0.5]{\arrowL};
        \draw (4,4)--(8,0) node[sloped,pos=0.5]{\arrowL};
        \draw (0,0)--(4,4) node[sloped,pos=0.5]{\arrowL};
        \draw (4,4)--(4,0) node[sloped,pos=0.5]{};  

    \end{tikzpicture}
\end{document}

...并带有标签:

\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}

\newcommand{\arrowL}{
    \tikz \draw[latex-] (0,0) -- (0.1,0);
}
\newcommand{\arrowR}{
    \tikz \draw[-latex] (0,0) -- (0.1,0);
}

\begin{document}
    \begin{tikzpicture}
        \draw (0,0)--(8,0) node[sloped,pos=0.5]{\arrowL};
        \draw (4,4)--(8,0) node[sloped,pos=0.5]{\arrowL};
        \draw (0,0)--(4,4) node[sloped,pos=0.5]{\arrowL};
        \draw (4,4)--(4,0) node[sloped,pos=0.5]{};  

% nodes
 \node[left] at (0,0) {$v$};
 \node[right] at (8,0) {$v$};
 \node[above] at (4,4) {$v$};
 \node[below] at (4,0) {$b$};
 \node[above] at (2,2) {$a$};
 \node[above] at (6,2) {$a$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

使用装饰的版本:

\documentclass[border=0.5cm]{standalone}
\usepackage{tikz}
\usetikzlibrary{ decorations.markings}

\tikzset{
    arrow/.style={postaction={decorate},
        decoration={markings,mark=at position .5 with {\arrowreversed{latex}}}},
    arrow2/.style={postaction={decorate},
        decoration={markings,mark=at position .5 with {\arrow{latex}}}},
}


\begin{document}
    \begin{tikzpicture}
        ] 
        
        \draw[arrow] (0,0)--(8,0);      
        \draw[arrow] (4,4)--(8,0);
        \draw[arrow] (0,0)--(4,4);
        \draw (4,4)--(4,0);  
    
    % nodes
    \node[left] at (0,0) {$v$};
    \node[right] at (8,0) {$v$};
    \node[above] at (4,4) {$v$};
    \node[below] at (4,0) {$b$};
    \node[above] at (2,2) {$a$};
    \node[above] at (6,2) {$a$};
    \end{tikzpicture}
\end{document}

在此处输入图片描述

答案2

对于等边三角形,使用此代码:

\documentclass[border=0.5cm]{standalone}

\usepackage{tikz}


\begin{document} 
    \begin{tikzpicture}
        %   Triangle 1
        
        %\draw (0,0)--(2,0)--(60:2)--(0,0)--cycle;
        \draw (2,0)--(0,0) node[midway,below] () {$b$};
        \draw (2,0)--(1,1.732) node[midway,right] () {$a'$};
        \draw (1,1.732)--(0,0) node[midway,left] () {$a'$};
        \draw[-latex] (2,0)--(1,0);
        \draw[-latex] (2,0)--(1.5,0.866);
        \draw[-latex] (1,1.732)--(.5,0.866);
        \draw (1,1.732)--(1,0);
        \node[below] at (0,0) () {$v$};
        \node[below] at (2,0) () {$v$};
        \node[above] at (1,1.732) () {$v$};
    \end{tikzpicture}

\end{document}

你有输出:

在此处输入图片描述

如果您只想要等边三角形,请使用以下代码:

\documentclass[border=0.5cm]{standalone}

\usepackage{tikz}


\begin{document} 
    \begin{tikzpicture}
        \draw (0,0)--(2,0)--(60:2)--(0,0)--cycle;
        \draw (1,1.732)--(1,0);
    \end{tikzpicture}
\end{document}

你有这个输出:

在此处输入图片描述

答案3

这里有一个解决方案tkz-euclide。您可以在以下三角形中进行选择: 在此处输入图片描述 等边 一半或二 一 毕达哥拉斯或毕达哥拉斯或埃及学派
金色或崇高 欧几里得或欧几里得金 基奥普斯 两个角 等腰 直角

\documentclass{standalone}
\usepackage{tkz-euclide}

\tkzSetUpLine[line width=.4pt,color=teal]
\tikzset{arrow/.style={
         decoration={markings,
         mark= at position .5 with {\arrow[scale=2]{>}}}}}  
\begin{document}

\begin{tikzpicture}[scale=1.5,]
\tkzDefPoint(0,0){A}
\tkzDefPoint(4,0){B}
\tkzDefTriangle[equilateral](A,B) \tkzGetPoint{C}
\tkzDefMidPoint(A,B)    \tkzGetPoint{M}
\tkzDrawPolygon(A,B,C)
\tkzDrawSegments[arrow,postaction={decorate}](A,B B,C C,A)
\tkzDrawSegment(C,M)
\tkzLabelPoints(A,B,C)
\end{tikzpicture}

\begin{tikzpicture}[scale=1.5,]
\tkzDefPoint(0,0){A}
\tkzDefPoint(4,0){B}
\tkzDefTriangle[egyptian](A,B) \tkzGetPoint{C}
\tkzDrawPolygon(A,B,C)
\tkzDrawSegments[arrow,postaction={decorate}](A,B B,C C,A)
\end{tikzpicture}    
\end{document}

在此处输入图片描述

我采用相同的代码,但要反转我写的三角形,B,A而不是A,B箭头的那个。

\documentclass{standalone}
\usepackage{tkz-euclide}

\tkzSetUpLine[line width=.4pt,color=teal]
\tikzset{arrow/.style={
         decoration={markings,
         mark= at position .5 with {\arrow[scale=2]{>}}}}}  
\begin{document}

\begin{tikzpicture}[scale=1.5,]
\tkzDefPoint(0,0){A}
\tkzDefPoint(4,0){B}
\tkzDefTriangle[equilateral](A,B) \tkzGetPoint{C}
\tkzDefMidPoint(A,B)    \tkzGetPoint{M}
\tkzDrawPolygon(A,B,C)
\tkzDrawSegments[arrow,postaction={decorate}](B,A B,C C,A)
\tkzDrawSegment(C,M)
\tkzLabelPoints(A,B,C)
\end{tikzpicture}

\begin{tikzpicture}[scale=1.5,]
\tkzDefPoint(0,0){A}
\tkzDefPoint(4,0){B}
\tkzDefTriangle[equilateral](B,A) \tkzGetPoint{C}
\tkzDefMidPoint(A,B)    \tkzGetPoint{M}
\tkzDrawPolygon(A,B,C)
\tkzDrawSegments[arrow,postaction={decorate}](A,B B,C C,A)
\tkzDrawSegment(C,M)
\tkzLabelPoints(A,B,C)
\end{tikzpicture}

\end{document}

相关内容