I would like to include a display equation in an EPS figure using the pstool package. When the command for the replacement text is $\sum_{i=1}^{N} x_i^2$, then it compiles fine (see the vertical axis label):

enter image description here

However, when I use $$\sum_{i=1}^{N} x_i^2$$, or more generally \begin{equation} \sum_{i=1}^{N} x_i^2 \end{equation} I get the following error:

enter image description here

I can use \displaystyle to force the large summation (and this does work), but the question is more general (as I may want to include equations that have more complicated formatting like a \begin{cases}...\end{cases} situation): How to use general display style equations within pstools?

Here is my minimal working example:






And here is the contents of mwe.tex:

% Generated using matlabfrag
% Version: v0.6.16
% Version Date: 04-Apr-2010
% Author: Zebb Prime
%% <text>
\psfrag{013}[bc][bc]{\matlabtextA $\sum_{i=1}^{N} x_i^2$}%
\psfrag{014}[bc][bc]{\matlabtextA Peaks}%
\psfrag{015}[tr][tr]{\matlabtextA y}%
\psfrag{016}[tl][tl]{\matlabtextA x}%
%% </text>
%% <xtick>
\psfrag{000}[ct][ct]{\matlabtextA $\matlabfragNegXTick 3$}%
\psfrag{001}[ct][ct]{\matlabtextA $\matlabfragNegXTick 2$}%
\psfrag{002}[ct][ct]{\matlabtextA $\matlabfragNegXTick 1$}%
\psfrag{003}[ct][ct]{\matlabtextA $0$}%
\psfrag{004}[ct][ct]{\matlabtextA $1$}%
\psfrag{005}[ct][ct]{\matlabtextA $2$}%
\psfrag{006}[ct][ct]{\matlabtextA $3$}%
%% </xtick>
%% <ytick>
\psfrag{007}[rc][rc]{\matlabtextA $-2$}%
\psfrag{008}[rc][rc]{\matlabtextA $0$}%
\psfrag{009}[rc][rc]{\matlabtextA $2$}%
%% </ytick>
%% <ztick>
\psfrag{010}[cr][cr]{\matlabtextA $-5$}%
\psfrag{011}[cr][cr]{\matlabtextA $0$}%
\psfrag{012}[cr][cr]{\matlabtextA $5$}%
%% </ztick>

This was generated by using the matlabfrag package from here.

  • $\displaystyle ...$ or \parbox{3cm}{\[......\]} – David Carlisle Jan 24 '14 at 0:22
  • @DavidCarlisle: Thanks for the suggestion. As noted in the question I have tried \displaystyle and it does compile correctly. However, the question is more general. Say that I want to include an equation that involves more complicated (and usually written on multiple lines) formatting, e.g. a \begin{cases} environment. I need pstool to be able to handle whatever I might put inside of a generic \begin{equation}...\end{equation}. Any suggestions? – okj Jan 24 '14 at 0:45
  • 1
    That's why I gave the second suggestion, for a display environment you need the parbox form. and \[ or \begin{align} or whatever you need – David Carlisle Jan 24 '14 at 0:49
  • @DavidCarlisle: Ahhh, I see. I have never used \parbox so I am unfamiliar with how I would use it. I looked up the documentation and it seems that I need to know the width beforehand (i.e your 3cm), but how do I know the width of my expression before i have seen it? Is there a rule of thumb you use to make sure the parbox is big enough to contain the contents? – okj Jan 24 '14 at 1:01
  • It is a general rule in tex that either you are in horizontal mode for one line stuff (\mbox), or vertical mode (\parbox or the outer main page) where you can have math displays and linebreaking but you need to know the width in advance. – David Carlisle Jan 24 '14 at 1:48

In order to use display constructs you need to be in vertical (paragraph) mode so you need something like

\parbox{3cm}{\[\sum_{i=1}^{N} x_i^2\]}

choosing a suitable width for your context.

Note this is not particular to psfrag it is a general TeX feature, for example you can not have a display environment in \mbox or a tabular c column, you need a \parbox or tabular p column for the same reason.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.