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.

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
share|improve this question
3  
simply do unit markings=slash space –  zeroth Jul 31 '13 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 Jul 31 '13 at 11:17
1  
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 Jul 31 '13 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 Jul 31 '13 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 Jul 31 '13 at 11:47

1 Answer 1

up vote 7 down vote accepted

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.

share|improve this answer
    
could you try to write $F$/mN or $F/si{\milli\Newton}$ and I'll mark it as an answer. Thanks. –  LaRiFaRi Jul 31 '13 at 11:27
    
ok, thats quite tricky, you may try $F/\si{\milli\newton}$ :-) . Sorry for the typo. –  LaRiFaRi Jul 31 '13 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 Jul 31 '13 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? –  zeroth Jul 31 '13 at 11:52
    
Because F is the symbol, which gets divided through its unit. So the result would be: unit marking pre={}, unit marking post={}, y unit={\si{$F$\per\milli\newton}} which doesn't really look like intuitive writing. The F shouldn't be inside an unit argument of the axis. –  LaRiFaRi Jul 31 '13 at 11:58

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.