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.

The objective is to get fractional labels (not in decimal) for both vertical and horizontal axes.

In my experience, non-trigonometric labels are written in decimals and trigonometric labels can be written in fractional via trigLabels and trigLabelBase. I attempted to abuse these keys to get fractional non-trigonometric by using \let\pi=\relax, but it causes a problem where

  • \pi/n becomes /n (that should be 1/n),

  • -\pi/n becomes -/n (that should be -1/n),

  • -\pi becomes - (that should be -1),

  • \pi becomes <empty> (that should be 1) where <empty> stands for empty .

My question, what is the best trick to convert every \pi to relax but prevent the problems from happening?

\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-plot}
\usepackage[nomessages]{fp}

\FPeval\XMin{0-2}
\FPeval\XMax{2}
\FPeval\YMin{0-1}
\FPeval\YMax{1}
\FPeval\temp{1/3}

\psset
{
    ytrigLabels=true,
    xtrigLabels=true,
    trigLabelBase=3,
    unit=3cm,
}

\let\pi=\relax

\begin{document}
\begin{pspicture}(\XMin,\YMin)(\XMax,\YMax)
    \psaxes[dx=\temp,dy=\temp](0,0)(\XMin,\YMin)(\XMax,\YMax)
    \psplot[algebraic,plotpoints=100]{\XMin}{\XMax}{x-2/3}
\end{pspicture}
\end{document}

enter image description here

More general case

Sometimes I need to change \pi to \sqrt{2}, for example. I tried with

\let\pi={\sqrt{2}}

but it does not compile.

share|improve this question

1 Answer 1

up vote 2 down vote accepted
+50

The version 1.71 from http://texnik.dante.de/tex/generic/pst-plot/ knows fractionLabel:

\errorcontextlines=100
\documentclass[pstricks,border=12pt,12pt]{standalone}
\usepackage{pst-plot}
\psset{fractionLabels,fractionLabelBase=3,unit=3cm}

\begin{document}
\begin{pspicture}(-2,-1)(2,1)
    \psaxes[dx=0.333,dy=0.333](0,0)(-2,-1)(2,1)
    \psplot[algebraic,plotpoints=100]{-2}{2}{x-2/3}
\end{pspicture}
\end{document}

However, there is a spurious space which needs some more investigation.

enter image description here

share|improve this answer
    
Sorry, is it possible to change \pi with e, \sqrt{m}, etc such that we can have \frac{e}{n}, \frac{\sqrt{m}}{n}, etc where n is the fractionLabelBase? –  stalking is prohibited Aug 24 at 9:33
1  
for example: xlabelFactor=\sqrt{2} or \def\pi{e} –  Herbert Aug 24 at 9:38
    
Sorry. Using xlabelFactor makes the factor appear on the right of the fractional labels rather than in the numerator of the fractional labels. As a result, there are some "oddities" such as -1\sqrt{2} and 1\sqrt{2}. It will be better if we can change \pi in the numerator with \sqrt{2}, for example. –  stalking is prohibited Aug 24 at 9:49
1  
\def\pi{\sqrt{2}} for example –  Herbert Aug 24 at 9:57
    
The update of pst-plot was done on August 24 but up to now it has not been propagated to TeXLive mirrors. A weird thing happened: pst-poly updated on August 28 has been propagated to TeXLive mirrors. –  stalking is prohibited Sep 1 at 19:47

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.