Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

siunitx: new unit "Stueck"

43 views
Skip to first unread message

Karl Heinz Schloeglmann

unread,
Oct 23, 2008, 10:28:33 AM10/23/08
to
Hello,

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

Joseph Wright

unread,
Oct 23, 2008, 10:59:16 AM10/23/08
to
On Oct 23, 3:28 pm, Karl Heinz Schloeglmann

<karl.schloeglm...@tugraz.at> wrote:
> Hello,
>
> 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}

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

unread,
Oct 24, 2008, 3:49:41 AM10/24/08
to
As I remember there is defined a command \pnt to make punctuation marks
in unit definitions.

/Jonatan Jakobsen


Karl Heinz Schloeglmann skrev:

Joseph Wright

unread,
Oct 24, 2008, 6:24:32 AM10/24/08
to
On Oct 24, 8:49 am, Jonatan Jakobsen <eng...@civil.aau.dk> wrote:
> As I remember there is defined a command \pnt to make punctuation marks
> in unit definitions.

In compatibility mode, yes. But you'll still have the double-full
stop problem.
--
Joseph Wright

Jellby

unread,
Nov 1, 2008, 9:12:17 AM11/1/08
to
Among other things, Karl Heinz Schloeglmann saw fit to write:

> 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

0 new messages