[pstricks] Suggestions for \psPrintValue

Michael Sharpe msharpe at ucsd.edu
Wed Apr 29 00:07:43 CEST 2009


On Apr 28, 2009, at 10:34 AM, Buddy Ledger wrote:

>>> / This version changes two things. First, it now adds decplaces as a
> />>/ keyword to set the number of decimal places in the output.  
> Second, if
> />>/ decplaces=-1, it returns all precision in the input. Eg,
> />>/ \fmtnum[decplaces=-1]{12.675E-002} outputs 0.12675.
>
> Micheal,
>
> Using your code as a guide I wrote the macro below.  It uses the fp  
> package
> for the heavy lifting.  I am having trouble with spaces in the  
> output, I've tryed using \ignorespaces with no luck.  If you have  
> any ideas about how to fix it, I'd appreciate it.
>
> I wrote this to convert #.####### or ///#.#####E#// /-> #.##E# or  
> #.##x10^# or #.##
> /
Buddy,

I think the main reason for the out-of control spacing is that your  
code (in \GetNum) was not written defensively enough. Unless you end  
each line with % (except when assigning a count or a dimension, which  
requires a little more care), you are likely to introduce space  
characters in unexpected places. Most pstricks functions have built-in  
safeguards so that spaces do not break pictures, but it can be a  
problem with ordinary TeX commands such  definitions used within some  
environments, such as tabular. For example,

\def\a{a} \def\b{b}

is equivalent to

\def\a{a}
\def\b{b}

(only EOL character between them) and leaves a space character in the  
stream.

The correct form is

\def\a{a}\def\b{b}

or equivalently

\def\a{a}%
\def\b{b}

I've not always had good luck with the fp package, but it seems to  
work fine here.

Michael



More information about the PSTricks mailing list