Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted
\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

share|improve this answer
    
The value of \pslinewidth must be in the current unit rather than in pt, so I can use it for adjusting plotting domain. –  xport Jul 25 '11 at 18:29
    
sure, nobody changed the linewidth, scaling is done on PostScript side –  Herbert Jul 25 '11 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. –  xport Jul 25 '11 at 18:34
    
I will show you the real scenario. Please wait a minute. –  xport Jul 25 '11 at 18:35
    
see edited answer –  Herbert Jul 25 '11 at 18:38
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.