4

I know how to draw a triangle like so:

\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}

But, here is the figure I wanna draw:

enter image description here

An equilateral triangle with a solid line inside it, could anyone help me in this drawing please?

3 Answers 3

4

First nobody can help you since you did not provide how \arrowL and \arrowR are defiend.

I also do not know what you do not understand with the code given here.

You can achieve this triangle by simple extend it by one more line using the corresponding tikz syntax \draw.

EDIT: As mentioned by Rmano this first version is nesting tikz enviroments. So it is better to use the second version with decorations.

\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}

...and with labels:

\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}

enter image description here

a version using decorations:

\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}

enter image description here

4
  • I am in document class
    – Brain
    Commented Jan 25, 2022 at 6:05
  • Hmmm... It works in this case, but you are nesting tikz environments, which is highly dangerous. See for example tex.stackexchange.com/questions/629435/… --- as soon as you add options, the internal arrow can do strange things. I suggest using decorations here.
    – Rmano
    Commented Jan 25, 2022 at 7:24
  • 1
    @Rmano Thanks, I did not realizd that I am actually nesting tikz. I added a version with decorations.
    – Roland
    Commented Jan 25, 2022 at 7:44
  • The version the OP gives look better but maybe just because the lines are thicker and the arrows bigger?
    – Simd
    Commented Jan 25, 2022 at 16:29
3

For an equilateral triangle, with this code:

\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}

you have the output:

enter image description here

If you want only the equilateral triangle, with this code:

\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}

you have this output:

enter image description here

3

Here a solution with tkz-euclide. You can choose between the following triangles: enter image description here equilateral half or two one pythagore or pythagoras or egyptian school
golden or sublime euclid or euclide gold cheops two angles isosceles right

\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}

enter image description here

I take the same code but to inverse the triangle I wrote B,A instead of A,Bidem for the arrow.

\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}
2
  • I want the tip of the triangle on the right to be its base, I want to preserve the direction of the arrows, I think the triangle you inverted is not the one I am giving above.... am I correct?
    – Brain
    Commented Jan 25, 2022 at 7:57
  • No the second triangle is to show you that you can draw some triangles defined in tkz-euclide. Now you can do anything. I add some codes to show you how modify ... Commented Jan 25, 2022 at 8:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .