For reasons I cannot explain \def's don't seem to always work in/with \psplot as shown below

\documentclass[english, landscape, a4paper]{slides}



            \psplot{0.0}{1.0}{x \tI sub}   % does not work
            % \psplot{0.0}{1.0}{x \tI sub} % works

I compile the above file with xelatex file and get the error

Error: /undefined in 0.0sub
Operand stack:
   --nostringval--   0.0   0.0
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %s
  --nostringval--   --nostringval--   false   1   %stopped_push   1910   1   3   %oparray_
pop   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop   --nostringval--   %error
ingval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nos
** WARNING ** Filtering file via command -->mgs.exe -q -dNOPAUSE -dBATCH -sPAPERSIZE=a0 -s
yLevel=1.3 -dAutoFilterGrayImages=false -dGrayImageFilter=/FlateEncode -dAutoFilterColorIm
/FlateEncode -dUseFlateCompression=t

Can someone please suggest a workaround for this problem?

  • use \space after \tl – kiss my armpit Sep 29 '12 at 17:45
  • Use: \psplot{0.0}{1.0}{x \tI\space sub} – Marco Daniel Sep 29 '12 at 17:45
  • 1
    Just to add why: the space after \tI gets ignored while reading the input (it follows a command name) and the error line 0.0sub shows it. However, the common trick of putting {} after the command can't work here, while \space does the right thing. – egreg Sep 29 '12 at 17:47

Comments for your MWE:

  1. When you want to get a tight, separate PDF output for each pspicture, you can use standalone class instead of preview package to save some keystrokes.
  2. Only use graphicx (the modern one) and it loads graphics internally.
  3. Remove unnecessary packages.
  4. No need to use center environment if you need to generate a tight, separate PDF output for each pspicture.
  5. Only use pspicture* to trim the objects outside the canvas. If no objects outside the canvas exist, just use pspicture without stars.

enter image description here


\psplot{0.0}{1.0}{x \tI\space sub}

Now let's discuss your problem. Control words will eat spaces following them. So x \tI sub becomes x 0.0sub that is no meaning. To preserve the spaces, you need to use \space as shown in the code above.

Another solution:

Make sure you put at least one space before the closing } in your macro definition. See the code below.


\def\tI{0.0 }% can you see there is one space before the closing }?
\psplot{0.0}{1.0}{x \tI sub}
| improve this answer | |
  • 1
    I think I don't need to add an animated version. – kiss my armpit Sep 29 '12 at 18:35

use always a definition with a space at the end:

\def\tI{0.0 }

then you do not need the \space macro for the function.

| improve this answer | |
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. – Tom Bombadil Sep 29 '12 at 19:21
  • it could be good idea that you read the question! – user2478 Sep 29 '12 at 19:24
  • 1
    It's the same what ガベージコレクタ did and also commented in his code. So your answer is nothing additional and should, in my humble opinion be a comment to ガベージコレクタ's answer. – Tom Bombadil Sep 29 '12 at 19:26

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.