5

I've found (here in french https://fr.wikibooks.org/wiki/LaTeX/%C3%89crire_de_la_physique#Extension_siunitx) that I could use the package siunitx to write the unit but it doesn't work :

A minimal code to test :

\documentclass[a4paper]{article}

\usepackage{siunitx}


\title{Test}
\author{Cécile Moulin}
\date{}

\begin{document}
\maketitle
\tableofcontents

text text text
\metre

\end{document}

The error :

This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Debian) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./test.tex
LaTeX2e <2016/02/01>
Babel <3.9q> and hyphenation patterns for 81 language(s) loaded.
(/usr/share/texlive/texmf-dist/tex/latex/base/article.cls
Document Class: article 2014/09/29 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo))
(/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/expl3-code.tex)
(/usr/share/texlive/texmf-dist/tex/latex/l3kernel/l3pdfmode.def))
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/xparse/xparse.sty)
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/share/texlive/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/share/texlive/texmf-dist/tex/latex/tools/array.sty)
(/usr/share/texlive/texmf-dist/tex/latex/l3packages/l3keys2e/l3keys2e.sty)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator.sty
(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/translator-language-
mappings.tex))) (./test.aux)
(/usr/share/texlive/texmf-dist/tex/latex/beamer/translator/dicts/translator-bas
ic-dictionary/translator-basic-dictionary-English.dict)
(/usr/share/texlive/texmf-dist/tex/latex/siunitx/siunitx-abbreviations.cfg)
(./test.toc)
! Undefined control sequence.
\metre ->\ERROR 

l.18 \metre

I've tried with/without \( \) and with \meter too, it's the same

  • 2
    In order not to disturb the rest of the document the unit macros can only be used in the second argument to \SI{}{} or in the argument to \si{}. The first is used to typeset value+unit and the later is used to typeset just a unit. So use \si{\metre} instead of \metre. – daleif Jun 12 '17 at 14:02
9

Normally these units only work within \si{...} (and similar commands), but if you want to use them in normal text, you can use the free-standing-units=true of the siunitx package.

\documentclass{article}

\usepackage[free-standing-units=true]{siunitx}

\begin{document}

\si{\metre} % for the unit alone

\SI{42}{\metre} % for value and unit

\metre % this needs free-standing-units=true

\SI{10}{\nano\meter}

\SI{10}{\nm}

\SI{10}{nm}

\end{document}
  • Where can I find documentation about \SI{}{} ? I didn't find... So, the first part is for the value. What about nano and cie ? I have a unit which is '10 nm', so I think that the 10 is in the second part but is it true ? – Ccile Jun 12 '17 at 14:09
  • @Ccile You can find the documentation of siunitx at texdoc.net/texmf-dist/doc/latex/siunitx/siunitx.pdf -- for the 10 nm, please see my updated answer, \nano is prefix to meter. Why would 10 be the second part? – samcarter_is_at_topanswers.xyz Jun 12 '17 at 14:12
  • Ok, thanks. For 10 nm, you think it's better so or I can't do another way ? – Ccile Jun 12 '17 at 14:17
  • @Ccile Sorry, I don't understand your last comment, can you rephrase the question? – samcarter_is_at_topanswers.xyz Jun 12 '17 at 14:19
  • 1
    @Ccile The unit and the number should be separate \SI{10}{\nm} or \SI{10}{\nano\metre}. For exponents, do you mean \SI{10e-21}{\metre} perhaps? – Joseph Wright Jun 12 '17 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.