0

I have the following code for an octahedron. I need to remove the below part of that and write A, B, C, D, E for each vertex. I do not know how to do that. Your help will be appreciated.

\[
\begin{tikzpicture}[z={(-.3cm,-.2cm)}, % direction z gets projected to; can also change x,y
                                       % use cm to specify non-transformed coordinates
                    line join=round, line cap=round, % makes the corners look nicer
                    every node/.style = {inner sep=1pt, font=\scriptsize}
                   ]
  \draw ( 0,2,0) node[above] {} --
        (-2,0,0) node [left] {} --
        (0,-2,0) node[below] {} --
        ( 2,0,0) node[right] {} --
        ( 0,2,0) --
        ( 0,0,2) node[below left] {} --
        (0,-2,0) (2,0,0) -- (0,0,2) -- (-2,0,0);
  \draw[dashed] (0,2,0) -- (0,0,-2) -- (0,-2,0) (2,0,0) -- (0,0,-2) -- (-2,0,0);
\end{tikzpicture}
\]

In fact, we have a tetrahedron that its base is a triangle, but I need the base as a rectangle, a tetragonal pyramid with letters on each vertex.

1
  • 1
    What would happen, if you'd replace those { } by {someText}? // Kindly apply this checklist to turn your code into something useable here: tex.meta.stackexchange.com/questions/228/… . // Why do you put the tikypicture environment into math-mode? // Are you familiar with the tutorials in tikz.dev ?
    – MS-SPO
    Jan 7 at 9:26

1 Answer 1

1

Something like this?

\documentclass[border=10pt]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[
    z={(-.3cm,-.2cm)},
    line join=round, 
    line cap=round,  
    every node/.style={
        inner sep=1pt, 
        font=\scriptsize
    }
]

    \draw
        (0,2,0) node[above] {A} --
        (-2,0,0) node[left] {B} --
        (0,0,2) node[below] {C} --
        (2,0,0) node[right] {D} -- cycle
        (0,0,2) -- (0,2,0);
    \draw[dashed] 
        (0,2,0) -- (0,0,-2) node[below] {E} 
        (2,0,0) -- (0,0,-2) -- (-2,0,0);
        
\end{tikzpicture}
\end{document}

enter image description here

2
  • Thank you very much. If I want to color rectangle BCDE, how can I do that?
    – user118746
    Jan 7 at 17:41
  • 1
    @user118746 If you want to color the rectangle, you could add \fill[red!25] (-2,0,0) -- (0,0,2) -- (2,0,0) -- (0,0,-2); before the first \draw command. Take a look into the tutorials at tikz.dev for more information about how to draw lines and areas with TikZ. Jan 7 at 17:51

You must log in to answer this question.

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