Fun with LaTeX

Here’s a quick diagram of the interior of a Sun-like star I used in a presentation not so long ago.


The picture was generated with a bit of LaTeX code.  Here it is:



% Star

\pscustom[fillstyle=ccslope,slopecenter=0 0,slopebegin=yellow!30,slopeend=red!10!orange!60,linestyle=none]{\pswedge(0,0){4.5}{0}{90}}

% Core
\pscustom[fillstyle=ccslope,slopecenter=0 0,slopebegin=yellow!2,slopeend=orange!10,linestyle=none]{%


% Radiative zone lines

\multido{\iA=5+15}{6}{\pnode(1.4;\iA){A}\pnode(3.15;\iA){B}\ncsin[linewidth=0.1pt,amplitude=0.05,periods=4,coilarm=0pt,function=dup 0.1 mul sin exch sin add]{A}{B}}

% Convective zone lines

\multido{\iB=7+15}{6}{\rput{\iB}(3.25;\iB){\pccurve[angleA=-70, angleB=250,linewidth=0.25pt,ArrowInside=->,ArrowInsideNo=3]{->}(0,0)(1.2,0)}
\rput{\iB}(3.25;\iB){\pccurve[angleA=110, angleB=70,linewidth=0.25pt,ArrowInside=->,ArrowInsideNo=3]{->}(1.2,0)(0,0)}}

% Axes and labels

\psaxes[labelFontSize=\scriptscriptstyle,labels=y,ticks=y,Dy=0.2,dy=0.9,linewidth=0.25pt,ticksize=-3pt 0]{-}(0,0)(4.5,4.5)
\tiny \rput[l](0.15,-0.3){Core}
\rput[l](1.5,-0.4){\parbox{1cm}{\centering Radiative \\ Zone}}
\rput[l](3.2,-0.4){\parbox{1cm}{\centering Convective \\ Zone}}





    1. I’ll try to help. Some of the packages may not be installed in LaTeX distribution by default (e.g. pst-slpe). You should check. Take a look at the .log file generated when you compile and look for errors in there. If you’d prefer to correspond by email – you can reach me on

    2. Also, make sure your compiling like this.

      >> latex sun.tex
      >> dvips sun.dvi
      >> ps2pdf

      So LaTeX > DVI > Postscript > PDF.

      It also compiles to PDF with XeLaTeX:

      >> xelatex sun.tex

      Hope that helps!

Leave a Reply