LaTeX forum ⇒ Graphics, Figures & TablesRemove trailing Zeros in Axis Labels Topic is solved

Information and discussion about graphics, figures & tables in LaTeX documents.
User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Remove trailing Zeros in Axis Labels

Postby svend_tveskaeg » Sat Jan 11, 2014 1:17 pm

I've also asked this question on TeX StackExchange.

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

\begin{document}
  \psset{xunit=2}
  \begin{pspicture}(3,1)
    \psaxes[Dx = 0.5]{->}(3,1)
  \end{pspicture}
\end{document}

Is it possible to get "1" and "2" instead of "1.0" and "2.0" (as with 0) as axis labels?
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)

User avatar
svend_tveskaeg
Posts: 478
Joined: Sun Jul 12, 2009 5:31 am

Postby svend_tveskaeg » Sun Jan 12, 2014 6:25 pm

Here is a solution from Marco Daniel:

\documentclass{article}

\usepackage{pst-plot}

\makeatletter
\def\@LabelComma#1.#2.#3\@nil{%
  \def\pst@tempA{#1}%
  \ifx\pst@tempA\@empty\the\@zero\else#1\fi% the integer part
  \def\pst@tempA{#2}
  \ifx\pst@tempA\@empty
     \@writeDecimals{}%
  \else%
    \ifnum#2=0\relax\else%
      \@writeDecimals{#2}%
   \fi%
 \fi%
}
\makeatother

\begin{document}

\psset{xunit = 2}
\begin{pspicture}(3,1)
\psaxes[
  comma,
  Dx = 0.5
]{->}(3,1)
\end{pspicture}

\end{document}
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 5 guests