Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I draw this pyramid with GeoSpacw. How to draw this figure with TeX? enter image description here Where:

  • $M$ is midpoint of the segment $SA$;

  • $I$ is midpoint of the segment $SD$;

  • $H$ is project of the point $A$ on the line $SO$;

  • $ABKE$ is a is a parallelogram;

  • The line passing through $S$ and parallel to the line $AB$.

share|improve this question
M doesn't appear to be on segment SB. Do you mean SA or SN? –  Scott H. Apr 14 '13 at 2:30
Thank you. I have just edited. –  minthao_2011 Apr 14 '13 at 2:53
Could you elaborate on what points are given, and what points are calculated? As it stands, it seems like ABKE is an arbitrary parallelogram and S is an arbitrary point (from which we can calculate M and N). It seems like there needs to be some extra information to get I, D or C. –  Scott H. Apr 14 '13 at 3:30
O.K. The line SA perpendicular to the plane (ABC). SA = AB*\Sqrt{2}$, ABCD is a square. K is projection of B on the plane (SCD). Thank you. –  minthao_2011 Apr 14 '13 at 3:36
I need some verifications. E seems to the orthogonal projection of A on SD because BK//AE and K is the orthogonal projection of B on SCD. Am I wrong? –  Alain Matthes Apr 14 '13 at 10:47

5 Answers 5

up vote 14 down vote accepted

With PSTricks.

enter image description here

share|improve this answer
The point E is defined with K. It seems that you define E and then K. I don't understand ([nodesep=1.8]{S}D){E} –  Alain Matthes Apr 14 '13 at 8:46
Are you sure of the psprojection. It is not a drawing in a plane, If S is on a line perpendicular to ABCD in O, the projection is false but perhaps I'm wrong. –  Alain Matthes Apr 14 '13 at 8:56
If BK is orthogonal to the plane SCD then AE is orthogonal to SCD to. The consequence is AE perpendicular to SD, E is the orthogonal projection of A on SD. –  Alain Matthes Apr 14 '13 at 10:44
To se the problem with the projection : \pstTranslation[PosAngle=30]{A}{S}{O}[P] \pstProjection{O}{P}{A}[Q] OP is orthogonal to ABCD so the projection orthogonal Q of A on OP is O. Then ABKE is a parallelogram and BK is orthogonal to SCD, so AE is orthogonal to SCD. The consequence is AE perpendicular to SD because A,E,S,D ar in the same plane. I think it's not the case in your construction –  Alain Matthes Apr 15 '13 at 6:50
I'm not a great expert of pstricks and pst-eucl but I would like to understand how you place E. I'm not sure that you place E to the right place. pstProjection seems to be a macro to use in 2D but in the main plane ASD or a plane parallel to ASD. –  Alain Matthes Apr 15 '13 at 17:35

General Update

I can suggest two answers, the first one with tikz-3dplot interesting because we draw the pyramid in 3D and we can change easily the point of view and the perspective; the second one with tkz-euclide in 2D with parallel projection.

I made some mistakes in my first calculations but there are two problems to draw a correct figure. The first problem is to place E and K, the second one is to place H. The methods depend of the tools used, 3D or 2D with parallel projection.

How to place K and E

BK is orthogonal to the plane SCD, ABKE is a parallelogram, so AE||BK then AE is orthogonal to SCD. AE is perpendicular to SD in the plane ASD. This method is useful with with parallel projection because ASD is the main front and is in the main plane. We can use a projection in a plane to place E.

In 3D with for example tikz-3dplot we need to calculate the coordinate of E. I named \a the side of the square ABCD.

enter image description here

The coordinates of E are (0,2*\a/3,sqrt(2)/3*\a). Remark: If the coordinates of K are (xK,yK,zK) then the coordinates of E are (0,yK,zK). Or xK=xB, so K is defined by (\a,2*\a/3,sqrt(2)/3*\a).

About K. In the first answer, I used the code from of Caramdir's answer (from this question). If you know the equation of a plane, it's possible to determine the orthognal projection of a point on this plane. I determined the coordinates of K, so I can avoid the interesting code of Caramdir. Remark: SCD has an simple equation here sqrt(2)y+z = sqrt(2)\s it's parallel to (AB) and cut axis in S and D. It's easy to get K with caramdir's code.

How to place H

H is the projection orthogonal of A on OS. OAS is orthogonal to ABCD. The projection orthognal of H on ABBCD is a point Q on the line OA. Below I determined the coordinates of Q (2/5 \a,2/5 /a,0)and then I determined the coordinates of H. It's not possible to use the orthogonal projection of TikZ.

enter image description here

Part 1) With tikz-3dplot


 \tikzset{ hidden/.style = {thin, dotted}}
     add/.style args={#1 and #2}{
         to path={%



 % definitions 
    \path (0,0,0)                           coordinate (A) 
          (\a,0,0)                          coordinate (B) 
          (\a,\a,0)                         coordinate (C) 
          (0,\a,0)                          coordinate (D) 
          (0,0,{\a*sqrt(2)})                coordinate (S) 
          (0,0,{0.5*\a*sqrt(2)})            coordinate (M) 
          (0.5*\a,0.5*\a,0)                 coordinate (O) 
          (0,0.5*\a,{0.5*\a*sqrt(2)})       coordinate (I) 
          (2/5*\a,2/5*\a,{sqrt(2)/5*\a})    coordinate (H)
          ($(B)!2!(M)$)                     coordinate (N)
          (0,2*\a/3,{sqrt(2)/3*\a})         coordinate (E)
           (\a,2*\a/3,{sqrt(2)/3*\a})        coordinate (K) ;
 % drawing
    \clip (S) -- (B) -- (D) --cycle;
    \draw[hidden] (B) -- (N);
    \clip (S) -- (I) -- (N) --cycle;
    \draw (B) -- (N);

       (A) -- (C)  (A) -- (B)  (A) -- (D) (A) -- (H) (A) -- (S)
      (A) -- (E) (B) -- (D)  (O) -- (S) (I) -- (M);
 \draw (B) -- (K) -- (E)   (C) -- (N) -- (K)
       (B) --(C) -- (D) (S) -- (D)  (S) -- (B)  (S) -- (C);
 \draw[add = 1 and 1]  (S) to (N); 

 % place black circles and labels
 \foreach \point/\position in {A/left,B/left,C/right,D/right,E/right,H/above,
   \fill (\point) circle (.5pt);
   \node[\position=3pt] at (\point) {$\point$};


enter image description here

If you want to change the point of view you can try \tdplotsetmaincoords{60}{120}.

enter image description here

Part B) with tkz-euclide

If you want to use only TikZ, see Gonzalo's answer. The problem are the same, only the syntax and the macros are different. But the answers are similar. It's not very easy to show 3D objects with 2D methods.

I use the projection of A on SD to get E but it's also possible to get the coordinates. It's more difficult to get H, I used here the fact SO=5*OH.

 \tikzset{hidden/.style = {thin, dotted}}

  % definition
  \tkzDefMidPoint(A,C)                      \tkzGetPoint{O}
  \tkzDefMidPoint(S,A)                      \tkzGetPoint{M}
  \tkzDefMidPoint(S,D)                      \tkzGetPoint{I}
  \tkzDefPointBy[projection=onto S--D](A)   \tkzGetPoint{E} 
  \tkzDefPointWith[colinear= at E](A,B)     \tkzGetPoint{K}
  \tkzDefPointWith[linear,K=2](C,I)         \tkzGetPoint{N}
  \tkzDefPointWith[linear,K=1/5](O,S)       \tkzGetPoint{H}
 % drawing 
  \tkzDrawSegments[hidden](A,B A,D I,M A,C B,D S,O M,E A,E A,S  A,H)
  \tkzDrawSegments(B,C C,D B,S S,D B,K K,E C,N K,N)
   % labels
    \tkzLabelPoints[above right](I,M)
    \tkzMarkRightAngles(A,E,D D,A,S)

enter image description here

share|improve this answer
The coordinates of the point $H$ is $(2/5a, 2/5a, \frac{sqrt(2)}{5}a$. –  minthao_2011 Apr 16 '13 at 8:46
@minthao_2011 Thanks to confirm my calculations ! –  Alain Matthes Apr 16 '13 at 10:46

Here's one possibility:




\clip (-0.5,-0.5) rectangle (5.7,12.1);
\coordinate (b);
\coordinate[above right=\ymov and \xmov of b] (a);
\coordinate[right=\xside of b] (c);
\coordinate[right=\xside of a] (d);
\coordinate[above=6cm of a] (s);
\draw (b) -- (s) -- (c);
\draw[name path=edge1] (s) -- (d);
\draw[dashed] (b) -- (a) -- (d) -- (c) -- (b) -- (d);
\draw[dashed,name path=diag1] (b) -- (d);
\draw[dashed,name path=diag2] (a) -- (c);
\draw[dashed] (s) -- (a);
\coordinate[name intersections={of=diag1 and diag2,by={o}}];
\draw[dashed] (s) -- (o);
\coordinate (i) at ( $ (s)!0.5!(d) $ );
\coordinate (m) at ( $ (s)!0.5!(a) $ );
\path[dashed,name path=line1] (b) -- ( $ (b)!15cm!(m) $ );
\path[draw,name path=line2] (c) -- ( $ (c)!15cm!(i) $ );
\coordinate[name intersections={of=line1 and line2,by={n}}];
% intersection od sd with nb
\coordinate[name intersections={of=line1 and edge1,by={aux}}];
\coordinate (e) at ( $ (d)!(a)!(s) $ );
\coordinate[below left=\ymov and \xmov of e] (k);
\coordinate (h) at ($(s)!(a)!(o)$);
\draw (n) -- (aux);
\draw[dashed] (aux) -- (b);
\draw[dashed] (a) -- (h);
\draw (e) -- (k) -- (b);
\draw[dashed] (e) -- (a);
\draw (n) -- (k);
\draw (n) -- ( $ (n)!6cm!(s) $ );
% place black circles and labels
\foreach \point/\position in {a/left,b/left,c/right,d/right,e/right,h/above left,
  \fill (\point) circle (2pt);
  \node[\position=2pt] at (\point) {$\point$};


enter image description here

Midpoints were obtained using ($(s)!0.5!(o)$) and the projection was obtained with ($(s)!(a)!(o)$). Intersections were calculated with the intersections library.

Changing dashed to dotted everywhere in the code above one gets:

enter image description here

share|improve this answer
Hi Gonzalo. I think with this method you can't respect the request like : as=sqrt(2)ab and h projection of a on ao. Here you get the projection in a plane, if s is above o, I think you get a problem because the projection needs to be o. –  Alain Matthes Apr 14 '13 at 9:01
And it's not Sb perpendicular to bc but Sa perpendicular to ad. –  Alain Matthes Apr 14 '13 at 10:40
@AlainMatthes yes, but the OP kept adding new conditions after I had answered with the initial requirements. Maybe I'll update this with the new requirements, but still it's not clear to me how to determine some of the points. –  Gonzalo Medina Apr 14 '13 at 14:33
The main problem is ($(s)!(a)!(o)$) because aso is not a plane parallel to asd. If my calculations are correct, oh = os/5. –  Alain Matthes Apr 15 '13 at 17:15
Hi, @AlainMatthes. I see that you took the time to make the calculations; thanks; I didn't feel like doing them myself ;-) I'll use your result about oh and os, if it's OK with you. –  Gonzalo Medina Apr 15 '13 at 17:25

Here's a metapost version, unfortunately without altering the out of the box luamplib package, I can't seem to draw dashed lines so I've replaced them with lighter lines.

enter image description here

path p[];
pair A,B,C,D,E,H,I,K,M,N,O,S,t;
def de = withcolor .85white enddef;

k = 2.5u;
p1 = unitsquare slanted .3 xscaled 2u yscaled u;
B = point 0 of p1;
C = point 1 of p1;
D = point 2 of p1;
A = point 3 of p1;
S = A shifted (0,k*length (A--B));
M = .5[A,S];
O = .5[A,C];
N = whatever[B,M]=whatever[S,B shifted (0,k*length (A--B))];
I = (N--C) intersectionpoint (S--D);
H = whatever[S,O] = A + whatever*((S-O) rotated 90);
E = whatever[S,D] = A + whatever*((S-D) rotated 90);
K = E shifted (B-A);
t = (B--N) intersectionpoint (S--D);

draw O--A--S--O--B--A--D--O--C de;
draw A--E de;
draw M--I de;
draw A--H de;
draw B--t de;
draw S--C--B--K--E--S--N--C--D;
draw B--S--D;
draw t--N--K;



share|improve this answer

enter image description here

Asymptote version pyramid.asy:

import three;  // 3D module
import math;


triple intersectionpoint(triple a,triple b,triple c,triple d){
  real u=((d.x-c.x)*a.y+(c.y-d.y)*a.x+c.x*d.y-d.x*c.y)/
  return a*(1.0-u)+b*u;

triple A,B,C,D,EE,II,H,K,M,NN,O,SS;  // S,E and N has special meaning in asy:
                                    // as South, East and North or (0,-1), (1,0) and (0,1)
                                    // and I is a sqrt(-1)=(0,1)                                    
real a=40;    // side of the square;
real h=50;    // height, h=AS
real d=sqrt(2)/2*a;  // half of the diagonal


real phi=atan(h/a);
real u=a*cos(phi)/sqrt(a^2+h^2);

real psi=atan(h/d);
real u=d*cos(psi)/sqrt(d^2+h^2);

pair Q=intersectionpoint(project(NN--B),project(SS--D));

pen dashed=linetype(new real[] {5,5}); // set up dashed pattern
pen visLine=darkblue+0.8pt;
pen hidLine=lightblue+dashed+0.8pt;

void Dot(...triple[] v){
  for(int i=0;i<v.length;++i){

void Draw3(guide3 g, pen p=currentpen){

void labelP(string s,triple t,pair p=(0,0)){






To get a standalone pyramid.pdf run asy -f pdf pyramid.asy.

share|improve this answer
+1 and please kindly make asymptote version for this question. –  Please don't touch Apr 14 '13 at 14:04
@Bugbusters: done. –  g.kov Apr 14 '13 at 16:24
Best looking solution to this question. –  Ingo Mar 3 at 16:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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