[Tex/LaTex] How to set units in pgfplots without square brackets

pgfplotssiunitxunits

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

Best Answer

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.

Related Question