I need a new unit called "Stueck" (German word for piece), abbreviated
by "St.".
First of all I tried
\usepackage{xspace}
\usepackage{siunitx}
\newunit{\St}{St.\xspace}
but \SI{3}{\St} leads to 3 St (no full stop)
The next try was
\usepackage{xspace}
\usepackage{siunitx}
\newunit{\St}{\mbox{St.}\xspace}
which makes \SI{3}{\St} to 3 St.
Fine, but at the end of a sentence two periods appear.
Test with \SI{3}{\St}. => Test with 3 St..
Any suggestions? Thanks in advance.
Karl
%-------8<---------------------
\documentclass{minimal}
\usepackage{xspace}
\usepackage{siunitx}
\newunit{\St}{\mbox{St.}\xspace}
\begin{document}
Test with \SI{5}{\St}, \SI{15}{\St} and \SI{3}{\St}.
\end{document}
%-------8<---------------------
--
_ _ _ _ ____
| |/ /arl|_| | | _| Civil Engineer & PhD-Student
| | | _ |einz \ Graz, Austria
|_|\_\ |_| |_| |____|chloeglmann http://www.schloeglmann.at
Why not \usepackage[xspace]{siunitx}?
> but \SI{3}{\St} leads to 3 St (no full stop)
The full stop is active inside a unit. The best method is to make a
robust command:
\DeclareRobustCommand{\Stueck}{St.}
\newunit{\St}{\Stueck}
> Fine, but at the end of a sentence two periods appear.
>
> Test with \SI{3}{\St}. => Test with 3 St..
This is rather difficult. siunitx processes the unit without looking
ahead, as the standard units are not abbreviations. The best that I
can do on the spot is:
\documentclass{article}
\usepackage{siunitx}
\makeatletter
\newcommand*{\mySI}[2]{%
\SI{#1}{#2}%
\@ifnextchar.{}{.\xspace}}
\makeatother
\newunit{\St}{St}
\begin{document}
Test with \mySI{5}{\St}, \mySI{15}{\St} and \mySI{3}{\St}.
\end{document}
--
Joseph Wright
/Jonatan Jakobsen
Karl Heinz Schloeglmann skrev:
In compatibility mode, yes. But you'll still have the double-full
stop problem.
--
Joseph Wright
> but \SI{3}{\St} leads to 3 St (no full stop)
If this were in Spanish, what you want to use is an abbreviation, which are
written with a period, while units are symbols, which have no period and
are invariable (no plural, no capitalization).
If you really want "Stueck" to be a unit, then its symbol would properly be
"St", with no period (why would "St." have one and not "kg" or "MeV"?). But
if you want just to use "St." as an abbreviation for "Stueck", then I would
just write "3 St." or, at most "3~St." (and add a "\@" if it's not the end
of a sentence), just like "3 people" or "3 items".
--
Ignacio __ Fernández Galván
/ /\
Linux user / / \ PGP Pub Key
#289967 / / /\ \ 0x01A95F99
/ / /\ \ \
http://djelibeibi.unex.es
/________\ \ \
jellby \___________\/ yahoo.com