# Errors in code, pstricks

I want to write an equation with some arrows above and under with text. Below is my code. When I compile this code i get errors and I don't understand why. Can anyone help?

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsfonts}

\usepackage{tcolorbox}

\newtcolorbox{question}[1]{arc=1mm,colframe=cyan,before
skip=11pt,after skip=11pt,breakable,colbacktitle=cyan,colback=white,coltitle=black,fonttitle=\bfseries,title=#1}

\begin{document}

\begin{question}
\begin{center}
\begin{pspicture*}(-0.1,-1.4)(0.1,1.6)
\rnode{A}{\psframebox{$\alpha\beta + \alpha\gamma$}} $=$ \rnode{B}{\psframebox{$\alpha(\beta + \gamma$)}}
\ncbar[nodesep=5pt,angle=90]{->}{A}{B}
\naput{\text{{\small some text}}}
\ncbar[nodesep=5pt,angle=-90]{->}{B}{A}
\naput{\text{{\small some text}}}
\end{pspicture*}
\end{center}
\end{question}

\end{document}

• If you delete the \centering command the whole thing seems to break again. It's like some package is missing, or there's a misplaced curly brace, but I don't think either is true. Maybe something about how you formatted \begin{pspicture*}... – heather Aug 16 '16 at 15:01
• You need to compile in XeLaTeX, first. Then, when I do that, it gives one error on the \centering line. (See comment above). I think you formatted pspicture correctly. I'm not really sure what's wrong. It gives 8 errors when the \centering line is removed. – heather Aug 16 '16 at 15:08
• @heather: One can also compile with  pdfLaTeX with the auto-pst-package. – Bernard Aug 16 '16 at 15:35
• @jalex: The breakable option seems unknown to tcolorbox. – Bernard Aug 16 '16 at 15:36
• @Bernard, can't you also compile with \usepackage[pdf]{pstricks}? Though, I said XeLaTeX because that is easiest... – heather Aug 16 '16 at 15:36

The problem was to add a \leavevmode on entering the environment. It's better to use centeringinstead of the center environment, to avoid unwanted vertical spaces.

You don't have to specify the dimensions of the pspicture environment (not starred!), and if you use auto-pst-pdf to compile with pdflatex, you can use the postscript environment instead.

I suggest a simpler way to code: put the contents of the equation inside a , and used \boxed from amsmath rather than the unnecessary \psframebox.

Here are both codes:

\documentclass[a4paper,12pt]{article}

\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{amsfonts}

\usepackage{tcolorbox}

\newtcolorbox{question}[1]{arc=1mm,colframe=cyan,before
skip=11pt,after skip=11pt,colbacktitle=cyan,colback=white,coltitle=black,fonttitle=\bfseries,title=#1}%breakable,

\begin{document}

\begin{question}
\leavevmode
\centering
\begin{postscript}%
\rnode{A}{\psframebox{$α\beta + α\gamma$}} $=$ \rnode{B}{\psframebox{$α(β+ \gamma$)}}
\ncbar[nodesep=5pt,angle=90]{->}{A}{B}
\naput{\text{{\small some text}}}
\ncbar[nodesep=5pt,angle=-90]{->}{B}{A}
\naput{\text{{\small some text}}}
\end{postscript}
\end{question}
\bigskip
\begin{question}
\leavevmode%
\setlength\fboxrule{0.8pt}
$% \begin{postscript} \rnode{A}{\boxed{α\beta + α\gamma}} = \rnode{B}{\boxed{α(β+ γ)}} \ncbar[nodesep=5pt,angle=90]{->}{A}{B} \naput{\text{{\small some text}}} \ncbar[nodesep=5pt,angle=-90]{->}{B}{A} \naput{\text{{\small some text}}} \end{postscript}$%
\end{question}

\end{document}