9

This MWE:

\documentclass{article}
% translate with >> pdflatex -shell-escape <file>

% This file is an extract of the PGFPLOTS manual, copyright by Christian Feuersaenger.
% 
% Feel free to use it as long as you cite the pgfplots manual properly.
%
% See
%   http://pgfplots.sourceforge.net/pgfplots.pdf
% for the complete manual.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\pagestyle{empty}

\usepgfplotslibrary{units}

\begin{document}
\begin{tikzpicture}
  \begin{axis}[change x base,
    x SI prefix=kilo,x unit=m,
    y SI prefix=milli,y unit=N,
    xlabel=Distance,ylabel=Force]
    \addplot coordinates {
        (1000,1)
        (2000,1.1)
        (3000,1.2)
        (4000,1.3)
    };
  \end{axis}
\end{tikzpicture}
\end{document}

results in units set in square brackets. This conflicts to the SI-brochure 8 and the German standard DIN 1313.

How can I switch that off or change it to "/unit" or "+in+unit"? I am not able to report that on sourceforge which is a pity as this wrong unit formatting is getting more and more popular.

If Mr. Feuersänger is reading here on TEX.SX, I am having this feature requests regarding the units:

  • never use brackets at all, but slash or "in" (Edit: for slash notation round brackets for divided units could be useful as mentioned in the comments. E.g. $a$/(m/s^2))
  • possibility to set unit after the symbol (axis label) or between the last two tick labels (or in place of the second last ticks label if to less space)
  • allow siunitx-syntax
  • automatically set angle units (°, ' and '') and time units (^h, ^min and ^s) (not to be confused with time period units (a, h, min and s)) directly next to each tick label
  • set powers of ten or units like %, or ppm between the last two tick labels
19
  • 3
    simply do unit markings=slash space
    – nickpapior
    Commented Jul 31, 2013 at 11:11
  • Thanks, your idea works, but it has a space in front and after the slash which are both forbidden. unit markings=slash is not working. I will search for other unit markings-commands in the manual. Still, a wrong default should be changed.
    – LaRiFaRi
    Commented Jul 31, 2013 at 11:17
  • 2
    Note that the use of a slash follows from the idea that you are dividing a quantity by the unit to leave unitless values for the axes: there is a reason for the standard!
    – Joseph Wright
    Commented Jul 31, 2013 at 11:28
  • 2
    @zeroth For multiple division I use brackets on the divisor: I find that OK but I can see that not everyone does. You write a package to support units, you get some very definite ideas about how units work :-)
    – Joseph Wright
    Commented Jul 31, 2013 at 11:32
  • 1
    @LaRiFaRi: The part with the ticks isn't implemented, there was a question about this recently (tex.stackexchange.com/questions/123977/…). Generally though, I think that "forbidden" and "wrong" are rather strong words for this discussion: These are conventions, not laws. The goal is to communicate information, and for different audiences, different ways of presenting information can be more suitable.
    – Jake
    Commented Jul 31, 2013 at 11:47

1 Answer 1

10

You have the possibility to alter the way it looks. The units library is not fully implemented, and will probably never fully be. Attaching units can be a rather integrate matter.

However you can accomplish your request by:

\begin{tikzpicture}
  \begin{axis}[change x base,
    x SI prefix=kilo,x unit=m,
    y SI prefix=milli,y unit=N,
    unit markings=slash space,
    % Or do it by your self...
    % unit marking pre={\text{in }}, % requires amsmath
    % unit marking post={},
    xlabel=Distance,ylabel=Force]
    \addplot coordinates {
        (1000,1)
        (2000,1.1)
        (3000,1.2)
        (4000,1.3)
    };
  \end{axis}
\end{tikzpicture}

which produces (both examples shown):

enter image description here

EDIT: per the comments I have added a better way to make what the op would like. It can be accommodated by:

unit marking pre={\!\!/},
unit marking post={},
ylabel=$F$

where the negative space \!\! should gobble one \space (I can never remember if this is exactly so or not, please fill in the gaps if you know the exact negative space to insert).
This should produce what the OP is asking for.

9
  • could you try to write $F$/mN or $F/si{\milli\Newton}$ and I'll mark it as an answer. Thanks.
    – LaRiFaRi
    Commented Jul 31, 2013 at 11:27
  • ok, thats quite tricky, you may try $F/\si{\milli\newton}$ :-) . Sorry for the typo.
    – LaRiFaRi
    Commented Jul 31, 2013 at 11:36
  • 1
    @LaRiFaRi Remove the y unit prefix and use y unit={\si{F\per\milli\newton}}, then siunitx will figure out what to do with the per whether fraction of / symbol.
    – percusse
    Commented Jul 31, 2013 at 11:50
  • @LaRiFaRi I was just away, I think percusse's suggestion is the best way to get around it. I am not sure why you want mN to be siunitxified and F not?
    – nickpapior
    Commented Jul 31, 2013 at 11:52
  • 1
    @LaRiFaRi I have added a way which I think is a bit more clean, and portable to other units. :)
    – nickpapior
    Commented Jul 31, 2013 at 12:55

You must log in to answer this question.

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