[pstricks] Tick labels and math mode

Alan Ristow ristow at ece.gatech.edu
Fri Jul 30 23:02:14 CEST 2004


Hi all,

I noticed recently that tick labels on the axes are typeset as text,
rather than math. As a result, negative numbers on the axes are preceded
by hyphens rather than negative signs. I solved this for the y-axis by
putting $ around the arguments of \pshlabel and \psvlabel in
\pst@@hlabels and \pst@@vlabels, respectively.

Can anybody think of any complications that could result from this? If
not, I would like to suggest this as a permanent change to \psaxes.
After all, the tick labels are typically mathematical in nature, and
since they are computed via multido it seems that they would *have* to
be numerical (IOW, text tick labels do not seem to be an issue).

Comments?

Regards,

Alan


\documentclass{article}
\usepackage{pstricks}
\usepackage{pst-plot}
\usepackage{pstricks-add}
\pagestyle{empty}
\parindent=0pt

\makeatletter%

\def\pst@@hlabels{%
  \pst at dimm=\pst at xticksizeC\advance\pst at dimm by \pslabelsep%
  \vbox to\z@{%
    \ifdim\pst at dimd>\z@\vskip\pst at dimm\else\vss\fi%
    \ifnum\pst at cnta<\z@\pst at dimb=-\pst at dimb\fi%
    \hbox to\z@{%
      \ifshoworigin\hbox to \z@{\hss\pshlabel{$\psk at Ox$}\hss}\fi%
      \mmultido{\n=\psk at Ox+\psk at Dx}{\pst at cnta}{%
        \hskip\pst at dimb\hbox to \z@{\hss\pshlabel{$\n$}\hss}%
      }\hss%
    }%
    \ifdim\pst at dimd>\z@\vss\else\vskip\pst at dimm\fi%
}}%

\def\pst@@vlabels{%
  \pst at dimm=\pst at yticksizeC%
  \advance\pst at dimm by \pslabelsep%
  \vbox to\z@{%
    \ifnum\pst at cnta>\z@\pst at dima=-\pst at dima\fi%
    \offinterlineskip%
    \ifshoworigin
      \vbox to \z@{\vss\hbox to\z@{%
        \ifdim\pst at dimc>\z@\hss\else\hskip\pst at dimm\fi
        \psvlabel{$\psk at Oy$}%
        \typeout{-----------------DID IT!----------------------}%
        \ifdim\pst at dimc>\z@\hskip\pst at dimm\else\hss\fi}\vss}%
    \fi%
    \mmultido{\n=\psk at Oy+\psk at Dy}{\pst at cnta}{%
      \vbox to\pst at dima{\vss}
      \vbox to \z@{%
        \vss\hbox to\z@{%
          \ifdim\pst at dimc>\z@%
            \hss\psvlabel{$\n$}\hskip\pst at dimm%
          \else%
            \hskip\pst at dimm\psvlabel{$\n$}\hss%
          \fi
        }\vss%
    }}%
    \vss%
}}

\makeatother%

\begin{document}

\psset{unit=0.125in}%
\psset{xAxisLabel=\relax,yAxisLabel=\relax}%
\begin{psgraph}[axesstyle=frame,Ox=-16,Dx=4,Oy=-8,%
    Dy=4,tickstyle=bottom](0,0)(32,16){4in}{2in}%
\end{psgraph}

\end{document}





More information about the PSTricks mailing list