[Tex/LaTex] Multiple files with new command causes undefined control sequence

errorspstricks

I am working on a scientific paper and recently I moved from Ubuntu with TeX Live to Mac OS. My document is splitted on more .tex files, to make it easier to work over it. With my old latex machine I had no issues at all, my pdf were genereted as intended.

Right now, I am having an undefined control sequence on the tex sources where is used a command defined on the root file. First thing I checked was if I had all the needed packages are installed correctly, but it seems I am not missing anything. My source looks like this.

main.tex

[ ... ]
\usepackage{graphicx}
\usepackage{pst-all}
\newcommand{\mycircle}[1]{\pscirclebox{\ensuremath{#1}}}
[ ... ]
\begin{document}

\input{auxiliary}

auxiliary.tex

\chapter{Elements of something }
Whatever.
\section{Whatever}
\begin{figure}
\centering
\begin{psmatrix}[colsep=2cm,rowsep=3cm]
        & \mycircle{S_2}    &   \\
\mycircle{S_1}  &           & \mycircle{S_3} 
\psset{arrows=->,labelsep=3pt,nodesep=3pt}
\ncarc[arcangle=-20]{1,2}{2,1}\ncput*{$0.2$}
\ncarc[arcangle=-20]{2,1}{1,2}\ncput*{$0.3$}
\ncarc[arcangle=-20]{2,3}{2,1}\ncput*{$0.1$}
\ncarc[arcangle=-20]{2,1}{2,3}\ncput*{$0.1$}
\ncarc[arcangle=-20]{2,3}{1,2}\ncput*{$0.7$}
\ncarc[arcangle=-20]{1,2}{2,3}\ncput*{$0.3$}
\nccircle{->}{1,2}{.6cm}\ncput*{$0.5$}
\nccircle[angleA=120]{->}{2,1}{.6cm}\ncput*{$0.6$}
\nccircle[angleA=240]{->}{2,3}{.6cm}\ncput*{$0.2$}
\end{psmatrix}
\vspace{0.8cm}
\caption{Bla bla.}
\label{fig:weather}
\end{figure}

What I receive is an Undefined Control Sequence pointing to that \mycircle on auxiliary.tex. Someone has any idea on how I should resolve this?
What I can't understand is why the same document with no differences was working on the other latex distribution.

Best Answer

pstricks and its packages needs some care when compiling. You can either use xelatex or else the latex->dvips->ps2pdf routine; you can use pdflatex, but you have to ask it correctly as detailed in How to use PSTricks in pdfLaTeX?

Presumably, your old setup had one of these compilation sequences to be used by default.

Here is your code mocked up into a complete MWE- note that I have used the arara tool to help with the automation- simply run

arara main

to get a pdf

latex->dvips->ps2pdf

% arara: latex
% arara: dvips
% arara: ps2pdf
\documentclass{report}

\usepackage{pst-all}
\newcommand{\mycircle}[1]{\pscirclebox{\ensuremath{#1}}}
\begin{document}

\input{auxiliary}

\end{document}

xelatex

% arara: xelatex
\documentclass{report}

\usepackage{pst-all}
\newcommand{\mycircle}[1]{\pscirclebox{\ensuremath{#1}}}
\begin{document}

\input{auxiliary}

\end{document}

pdflatex

% arara: pdflatex: {shell: yes}
\documentclass{report}

\usepackage[pdf]{pstricks}
\usepackage{pst-all}
\newcommand{\mycircle}[1]{\pscirclebox{\ensuremath{#1}}}
\begin{document}
\input{auxiliary}

\end{document}

I didn't change auxilary.tex.

If you'd prefer not to use arara, then you'll have to run the commands either using the command line, or by telling your editor/development environment the correct commands- arara makes all this much easier.