3

If I uncomment the last \rput, I get an error as follows:

enter image description here

How to fix this issue?

MWE

\documentclass[pstricks,border=1cm]{standalone}
\usepackage[nomessages]{fp}

\makeatletter
\def\scale{%
    \psline(100,0)
    \foreach \x in {0,10,...,100}{%
        \pstVerb{/x {\x} bind def 
                        /y {dup 100 mod 0 eq {-18} {dup 50 mod 0 eq {-9} {-3} ifelse} ifelse} bind def}%
        \psline(!x y)(!x y neg)
        }%
}

\def\caliper#1{%
    \psset{xunit=1mm,yunit=2pt,linewidth=3pt}
    \pspicture(0,-20)(100,20)
        \scale
        \rput(#1,0){\psset{xunit=.9\psxunit,yunit=.5\psyunit,linecolor=red,linewidth=.5\pslinewidth}\scale}%
        \FPeval\Label{trunc(#1/10:1)}
        %\rput(50,15){$\Label$} % this line causes an error!
    \endpspicture
}

\begin{document}
\foreach \i in {0,...,10}{\caliper{\i}}
\end{document}

2 Answers 2

4

It is not a good idea to define /y and /x with \pstVerb. They are global and causes error with internal values.

\documentclass[pstricks,border=1cm]{standalone}
\usepackage{pst-calculate}
\def\scale{%
    \psline(100,0)
    \foreach \x in {0,10,...,100}{%
        \pstVerb{/xCoor {\x} bind def 
            /yCoor {dup 100 mod 0 eq {-18} 
                    {dup 50 mod 0 eq {-9} {-3} ifelse} ifelse} bind def
            }%
        \psline(!xCoor yCoor)(!xCoor yCoor neg)
}}

\def\caliper#1{%
    \psset{xunit=1mm,yunit=2pt,linewidth=3pt}
    \pspicture(0,-20)(100,20)
    \rput(#1,0){\psset{xunit=.9\psxunit,yunit=.5\psyunit,
            linecolor=red,linewidth=.5\pslinewidth}\scale}%
    \scale
    \rput(50,15){\psCalculate[round-integer-to-decimal,
                      round-precision=1,round-mode=places]{#1/10}}
    \endpspicture}

\begin{document}
    \foreach \i in {0,1,...,10}{\caliper{\i}}
\end{document}
4
  • see edited answer
    – user2478
    Commented Jul 19, 2018 at 10:58
  • Will be fixed in the next update ...
    – user2478
    Commented Jul 22, 2018 at 21:24
  • 2.85 2018-08-22 - fix for trailing space in \radians , August or July?
    – D G
    Commented Jul 24, 2018 at 6:56
  • uh, my fault. It is July
    – user2478
    Commented Jul 24, 2018 at 7:45
3

Try this:

\documentclass[pstricks,border=1cm]{standalone}
\usepackage[nomessages]{fp}

\makeatletter
\def\scale{%
    \psline(100,0)
    \foreach \x in {0,10,...,100}{%
        \pstVerb{/x {\x} bind def
                        /y {dup 100 mod 0 eq {-18} {dup 50 mod 0 eq {-9} {-3} ifelse} ifelse} bind def}%
        \psline(!x y)(!x y neg)
        }%
}

\def\caliper#1{%
    \FPeval{\Label}{trunc(#1/10:1)}%
    \psset{xunit=1mm,yunit=2pt,linewidth=3pt}
    \pspicture(0,-20)(100,20)
        \rput(50,15){$\Label$}%
        \scale
        \rput(#1,0){\psset{xunit=.9\psxunit,yunit=.5\psyunit,linecolor=red,linewidth=.5\pslinewidth}\scale}%
    \endpspicture
}

\begin{document}
\foreach \i in {0,...,10}{\caliper{\i}}
\end{document}

enter image description here

2
  • Do you know the culprit?
    – D G
    Commented Jul 18, 2018 at 15:10
  • No, unfortunately not really. That was done by intuition.
    – user151328
    Commented Jul 18, 2018 at 15:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .