1

I need the value (without trailing unit) of \pslinewidth in \psunit. I have done as follows but I am disappointed with the accuracy.

\documentclass{article}
\parindent=0pt
\usepackage{pstricks}
\pstFPdiv\Temp
{\the\pslinewidth}
{\the\psunit}

\begin{document}
\the\pslinewidth% prints 0.8pt

\Temp% prints 0.028116799998875328

\psset{linewidth=\Temp}
\the\pslinewidth% prints 0.80014pt
\end{document}

Is there a built-in macro to get the value (without trailing unit) of \pslinewidth in any \psunit? The value is very useful to adjust plotting domain such that the cropped curve strokes near the domain edges can be avoided.


The real scenario is as follows. Note: \Temp is the half of \pslinewidth that is not the same as the example above.

enter image description here

\documentclass{article}
\usepackage{pst-func}

\def\Left{-1}
\def\Bottom{-1}
\def\Right{1}
\def\Top{1}


\psset{unit=2cm,linewidth=20pt}


%half of linewidth tickness
\pstFPdiv\Temp{\the\pslinewidth}{\the\dimexpr2\psunit\relax}

\pstFPsub\LEFT\Left\Temp
\pstFPsub\BOTTOM\Bottom\Temp
\pstFPadd\RIGHT\Right\Temp
\pstFPsub\TOP\Top\Temp

\begin{document}
\section*{Without extending the plotting domain}
\begin{pspicture*}[showgrid](\Left,\Bottom)(\Right,\Top)
        \psPolynomial[coeff=-1 0 2,linecolor=red]{\Left}{\Right}
\end{pspicture*}

\section*{With extending the plotting domain}
\begin{pspicture*}[showgrid](\LEFT,\BOTTOM)(\RIGHT,\TOP)
        \psPolynomial[coeff=-1 0 2,linecolor=red]{\Left}{\Right}
\end{pspicture*}
\end{document}

I accepted Herbert's answer that implies that there is no such a built-in macro.

I also want to emphasize that

  • Herbert's method is less accurate than mine.
  • The length in Herbert's method cannot be passed to functions that only accept values without unit. But the value in mine can be passed to such functions.

1 Answer 1

1
\documentclass{article}
\usepackage{pst-func}

\psset{unit=2cm,linewidth=20pt}
\newdimen\Left   \Left=-1\psxunit
\newdimen\Bottom \Bottom=-1\psxunit
\newdimen\Right  \Right=1\psyunit
\newdimen\Top    \Top=1\psyunit
\advance\Left   by -0.5\pslinewidth
\advance\Bottom by -0.5\pslinewidth
\advance\Right  by 0.5\pslinewidth
\advance\Top    by 0.5\pslinewidth

\begin{document}
\section*{With extending the plotting domain}
\begin{pspicture*}[showgrid](\Left,\Bottom)(\Right,\Top)
 \psPolynomial[coeff=-1 0 2,linecolor=red]{-1}{1}
\end{pspicture*}

\end{document}

enter image description here

8
  • The value of \pslinewidth must be in the current unit rather than in pt, so I can use it for adjusting plotting domain. Jul 25, 2011 at 18:29
  • sure, nobody changed the linewidth, scaling is done on PostScript side
    – user2478
    Jul 25, 2011 at 18:33
  • The required value (without trailing unit) of \pslinewidth must be in the current unit rather than in pt, so I can use it for adjusting plotting domain. Jul 25, 2011 at 18:34
  • I will show you the real scenario. Please wait a minute. Jul 25, 2011 at 18:35
  • see edited answer
    – user2478
    Jul 25, 2011 at 18:38

You must log in to answer this question.

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