TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to know if there is a package that automatically draw solids (spheres, cylinders, cubes, prisms).

I know I can do this kind of drawing using TikZ or PSTricks. But what about a package where you can type \cube{2cm} and it draws a cube of side 2 cm.

I am not posting a MWE because I just want to know if such package exists.

share|improve this question
up vote 9 down vote accepted

There is pst-solides3d. The package readme mentions:

The pack­age is de­signed to draw solids in 3D per­spec­tive. Fea­tures in­clude:

  • cre­ate prim­i­tive solids;

  • cre­ate solids by in­clud­ing a list of its ver­tices and faces;

  • faces of solids and sur­faces can be col­ored by choos­ing from a very large palette of col­ors;

  • draw para­met­ric sur­faces in al­ge­braic and re­verse pol­ish no­ta­tion;

  • cre­ate ex­plicit and pa­ram­e­ter­ized al­ge­braic func­tions drawn in 2 or 3 di­men­sions;

  • project text onto a plane and onto the faces of a solid;

  • sup­port for in­clud­ing ex­ter­nal database files.

Here's a small example (compile with LaTeX or XeLaTeX):

enter image description here

\rule[-1cm]{2cm}{2cm} \qquad\qquad
\psset{viewpoint=100 30 20,Decran=100,unit=1cm}
share|improve this answer

You might be interested in asymptote, a vector graphics language that you uses TeX for labels and can be used from within LaTeX.

Asymptote can draw standard shapes (spheres, cylinders, cubes, etc) which you can then scale, rotate, and shift to create many other shapes. (Asymptote can also do many other things.)

Here's a brief example.



import three;
//Setup View

//Draw Axes
pen thickblack = black+0.75;
real axislength = 2.0;
draw(L=Label("$x$", position=Relative(1.1), align=SW), -axislength*X--axislength*X,thickblack, Arrow3); 
draw(L=Label("$y$", position=Relative(1.1), align=E), -axislength*Y--axislength*Y,thickblack, Arrow3); 
draw(L=Label("$z$", position=Relative(1.1), align=N), -2*axislength*Z--2*axislength*Z,thickblack, Arrow3); 

//Define cube surfaces
surface c1 = unitcube;
surface c2 = shift(-2Z)*rotate(45,X)*c1;
surface s1 = unitsphere;
surface s2 = rotate(75,Z)*shift(1.5Z)*xscale3(2)*yscale3(0.5)*zscale3(0.1)*s1;

//Draw cube surfaces


enter image description here

share|improve this answer
Great illustration! Suggestion in constructing s2: use scale(2, 0.5, 0.1). – Charles Staats May 1 '14 at 14:38
@mrc WinEdt "asymptote.sty" not found? – Micky K May 1 '14 at 15:51
Actually asymptote.sty should be included in TeX Live, as should the alternative package asypictureB (if your package list was recently updated). – Charles Staats May 1 '14 at 19:20
@CharlesStaats I was unaware for asypictureB . . . I am looking forward to not recompiling figures I haven't changed!. Thanks! – Chris Chudzicki May 2 '14 at 1:32

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.