[pstricks] Spurious blanks

Denis Girou Denis.Girou at idris.fr
Tue Sep 24 00:53:13 CEST 2002

>>>>> "Christophe.Jorssen" == Christophe JORSSEN <christophe.jorssen at noos.fr> writes:

    Christophe.Jorssen> I seem to get into a lot of minor troubles with spurious blancks in some
    Christophe.Jorssen> PSTricks code. I read the documentation p 3-4 and I begin to understand what
    Christophe.Jorssen> I must look after. Nevertheless...

  This is a problem seen very often, and you can found a lot of examples of
codes sent on TeX mailing lists and also some (La)TeX packages which will
insert spurious blanks... But when your document contain texts and external
images only, this wrong effect is very tiny and most of the time never seen.
Nevertheless, if you program some graphics with TeX packages, a single
spurious blank is often seen immediately as it perturbate the graphic, so many
ones change it completely, as you seen yourself...

    Christophe.Jorssen> 1) I do not understand the reason why spurious blanks cause, in particular,
    Christophe.Jorssen> slight horizontal shifts. What do they do internally regarding PSTricks code
    Christophe.Jorssen> ?

  This question is rather easy: most PSTricks macros (pure graphics objects,
\rput and it variants) does not change the current point and only insert a
0-dimensional box, which are not directly seen by a TeX compiler (this is the
meaning of the \special TeX macro) and does not change it formatting. So, you
can superimpose various elementary graphics objects using the same coordinate
system. But if one of these objects (macros) introduce a space, TeX will see
it, use it inside it formatting and horizontally translate a little your
coordinate system, which is not at all what you expect...

  You can perhaps reread too the manual paragraph 23, pages 41-42, which also
speak indirectly of this question.

    Christophe.Jorssen> 2) In a recent talk with Denis Girou, he pointed out some (a lot!) of
    Christophe.Jorssen> spurious blanks in my code. In addition to those reported in the
    Christophe.Jorssen> documentation, he underlined

    Christophe.Jorssen> \setkeys{ }{ }%
    Christophe.Jorssen> \pst at Verb{ }%
    Christophe.Jorssen> \expandafter{ }%
    Christophe.Jorssen> \ifx\blabla\blublu%

  Not this last one, but this was not what you used in your code...
You used "\ifx\foo #1", which was not the same thing... And this one require
a continuation character.

    Christophe.Jorssen> and a few more.

  For instance, take also special care to the macro definitions (\def, \edef,
\gdef, \xdef) inside macros.

    Christophe.Jorssen> and a few more. Do you know more "problematic" macros ? Is it a good

  This question is not so easy. The best reference that I know on this subject
(but I can ignore other good ones!) is on the excellent book of David Salomon,
"The Advanced TeXbook", Springer Editions, 1995, paragraph 5.3 "Spurious
spaces", pages 111-113.

    Christophe.Jorssen> solution to put systematically a % at the end of every lines ?

  This will work most of the time, but take care that PSTricks is a special
case where you cannot do it systematically... When the TeX PSTricks macros
embed some PostScript codes, you must often leave a blank in the lines of
PostScript, blank which will be automatically inserted by TeX at the end of
each line).

  You can found some packages which have a % continuation character at each
end of lines. This avoid problems (but is considered as poor technic and
knowledge by experts...)


More information about the PSTricks mailing list