# Caption does not work with pspicture

I would like to include a caption below a tree drawn using pspictures. Here is my code.

\documentclass[12pt]{article}
\usepackage{pst-pdgr,pstricks,pst-pdf,graphicx}
\usepackage[top=2cm, left=2cm, bottom=2cm,right=2cm]{geometry}
\usepackage{caption}

\begin{document}

Blah blah.

\begin{figure}
\begin{pspicture}(7,7)
%\psgrid
\psset{descarmA=1.2}
\rput(2.5,4.5){\pstPerson[male]{A}}
\rput(4.5,4.5){\pstPerson[female]{B}}
\rput(2.5,2.5){\pstPerson[male, affected, belowtext={\small A1}]{C}}
\rput(4.5,2.5){\pstPerson[female]{D}}
\pstRelationship[descentnode=AB]{A}{B}
\pstDescent{AB}{C}
\pstDescent{AB}{D}
\end{pspicture}
\caption{figure}{figure text}
\end{figure}

More blah.

\end{document}

Tree looks fine, however, caption is missing. There is no error message so I do not really have a clue as to what I am missing here. Thank you.

• Not sure... but if you use a caption inside a figure environment , a simple \caption{figure text} would be enough. the caption package is needed for captions outside of float environments. Not inside them. – koleygr Oct 2 '17 at 19:53
• How exactly are you compiling your document? – Torbjørn T. Oct 2 '17 at 19:55

With auto-pst-pdf and a pdflatex compilation, it works fine:

\documentclass[12pt]{article}
\usepackage[margin=2cm]{geometry}
\usepackage{pst-pdgr, pstricks, graphicx}%
\usepackage{auto-pst-pdf}
\usepackage{caption}

\begin{document}

Blah blah.

\begin{figure}
\centering \begin{pspicture}(7,7)
\psset{descarmA=1.2}
\rput(2.5,4.5){\pstPerson[male]{A}}
\rput(4.5,4.5){\pstPerson[female]{B}}
\rput(2.5,2.5){\pstPerson[male, affected, belowtext={\small A1}]{C}}
\rput(4.5,2.5){\pstPerson[female]{D}}
\pstRelationship[descentnode=AB]{A}{B}
\pstDescent{AB}{C}
\pstDescent{AB}{D}
\end{pspicture}
\caption{figure text}
\end{figure}

More blah.

\end{document}

• Did you change anything in the code to make it work? Perhaps a different method of compilation? – Werner Oct 2 '17 at 20:53
• @Werner: I only simplified the options of geometry (unrelated) and removed the first argument of \caption, but mainly, I replaced loading pst-pdf with auto-pst-pdf, and compiled with pdflatex, of course. – Bernard Oct 2 '17 at 21:19
• Thank you, Bernard. Replacing pst-pdf with auto-pst-pdf recovered the caption, and everything looks good. – user3131944 Oct 2 '17 at 21:23
• @user3131944: This being said, I don't understand exactly why pst-pdf doesn't work, since auto-pst-pdf is supposed to be a wrapper for pst-pdf. I guess it sets some parameters so that it finally works. – Bernard Oct 2 '17 at 21:26