2

I am trying to draw a hexagonal pyramid in latex like the one below? enter image description here

  • 2
    Can you show us what you've tried? – Werner Jun 5 at 23:05
  • You probably want a tikz/pgf 3-D plot. – Davislor Jun 5 at 23:09
  • PSTricks also has an awesome 3D plot package called pst-solides3d. – Too Fat Man No Neck Jun 5 at 23:13
  • Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are rarely answered. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document. This question will be very likely closed in a short time. Addition of a MWE might contribute to its reopening – Alessandro Cuttin Jun 6 at 9:59
9

A solution that allows you to switch on the perspective view, if needed.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\begin{tikzpicture}[3d view={55}{20},declare function={a=2;b=3;l=5;},
    %perspective,
    >=stealth,line cap=round,line join=round]
 \draw[->]  (tpp cs:x=0,y=0,z=0) coordinate (O) -- (tpp cs:x=l,y=0,z=0);
 \draw[->]  (O) -- (tpp cs:x=0,y=l,z=0);
 \draw[->]  (tpp cs:x=0,y=0,z=b) -- (tpp cs:x=0,y=0,z=l);
 \path foreach \X in {1,...,6}
  {(tpp cs:x={a*cos(\X*60-30)},y={a*sin(\X*60-30)},z=0) coordinate (p\X)}
  (tpp cs:x=0,y=0,z=b) coordinate (tip);
 \draw[fill=white] plot[samples at={1,...,6}] (p\x) -- cycle;
 \draw foreach \X in {1,...,6} {(p\X) edge (tip)};
 \draw[dashed] foreach \X in {1,2,3} {(p\X) edge (p\the\numexpr\X+3)}
  (O) edge (tip);
\end{tikzpicture}
\end{document}

enter image description here

If you uncomment perspective, you get

enter image description here

The details about this view can be found in section 64 Three Point Perspective Drawing Library of pgfmanual v3.1.5.

You can change the view angles, of course.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{perspective}
\begin{document}
\foreach \X in {5,15,...,355}
{\begin{tikzpicture}
 \path[use as bounding box](-6,-3) rectangle (6,6);
 \begin{scope}[3d view={\X}{20+10*sin(\X)},declare function={a=2;b=3;l=5;},
    >=stealth,line cap=round,line join=round]
  \draw[->]  (tpp cs:x=0,y=0,z=0) coordinate (O) -- (tpp cs:x=l,y=0,z=0);
  \draw[->]  (O) -- (tpp cs:x=0,y=l,z=0);
  \draw[->]  (tpp cs:x=0,y=0,z=b) -- (tpp cs:x=0,y=0,z=l);
  \path foreach \X in {1,...,6}
   {(tpp cs:x={a*cos(\X*60-30)},y={a*sin(\X*60-30)},z=0) coordinate (p\X)}
   (tpp cs:x=0,y=0,z=b) coordinate (tip);
  \draw[fill=white] plot[samples at={1,...,6}] (p\x) -- cycle;
  \draw foreach \X in {1,...,6} {(p\X) edge (tip)};
  \draw[dashed] foreach \X in {1,2,3} {(p\X) edge (p\the\numexpr\X+3)}
   (O) edge (tip);
 \end{scope}
\end{tikzpicture}}
\end{document}

enter image description here

| improve this answer | |
  • +1 I guessed you upvoted my answer. – Too Fat Man No Neck Jun 5 at 23:19
  • 2
    @MoneyOrientedProgrammer Yes, I did (even though this will unlikely give you more money. ;-) – user194703 Jun 5 at 23:23
  • I am always amazed with your full time (24/7) voluntarily support here. There must be a passive income. :-) – Too Fat Man No Neck Jun 5 at 23:32
  • 2
    @MoneyOrientedProgrammer I am a sociologists, and some individuals with remarkable personality structure hang out on this site. So I have free access to very interesting patterns of behavior. ;-) – user194703 Jun 5 at 23:34
8

A PSTricks solution just for fun purpose. Compile it with 3 steps:

  • latex mop.tex
  • dvips mop.dvi
  • ps2pdf mop.ps

% this file name is mop.tex
\documentclass[pstricks,border=0pt,12pt]{standalone}
\usepackage{pst-eucl}

\begin{document}
\begin{pspicture}[showgrid=false](-5,0)(5,11)
    \pstGeonode[PosAngle={180,-90,-90,0,45,135,90}]
        (-4,3){A}
        (-2,1){B}
        (1,1){C}
        (4,3){D}
        (2,5){E}
        (-1,5){F}
        (1,10){T}
    \foreach \i in {A,B,C,D}{\psline(T)(\i)}
    \foreach \i in {A,E,T}{\psline[linestyle=dashed](F)(\i)}
    \foreach \i in {D,T}{\psline[linestyle=dashed](E)(\i)}
    \psline(A)(B)(C)(D)
\end{pspicture}
\end{document}

enter image description here

Other parts are intentionally left for your typing exercises!

You can also compile it with a single step with xelatex mop.tex. Unfortunately, this method takes a huge amount of time to compile.

| improve this answer | |
6

My humble attempt for MetaPost. Although I've used the embedded library of LuaTeX (via ConTeXt), you can include it in LaTeX using packages such as gmp or directly saving the code in a .mp file and compiling via mpost so you include your output using \includegraphics... or any similar.

\startTEXpage
\startMPcode
%Save in figure.mp and use "mpost figure.mp"
%Uncomment the following lines in the standalone file
%prologues := 3;
%beginfig(1)
u := 1cm;
pair p[]; 
for i = 1 upto 6:
    p[i] := dir(60*i-30) xscaled 2 rotated 10 scaled u;
endfor
pair q, r;
q := origin;
r := (0,4)*u;
draw p1
for i = 2 upto 6:
    --p[i]
endfor
--cycle;
for i = 1 upto 6:
    draw q -- p[i] dashed evenly;
    draw r -- p[i];
endfor
draw q -- r dashed evenly;
drawarrow q -- 0.5[p5,p6] scaled 2;
drawarrow r -- (1.25*r);
drawarrow p1 -- (sqrt(3)*p1);
%endfig;
%end
\stopMPcode  
\stopTEXpage

enter image description here

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.