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

space or no space after \textcelcius

3,571 views
Skip to first unread message

huis...@my-deja.com

unread,
Mar 3, 2000, 3:00:00 AM3/3/00
to
Hi everybody

I use \textdegree C quite often, so I defined a new command like this

\newcommand{\tc}{\textdegree C}

The problem is that no space is printed, no matter how many spaces i
give after \tc. However, adding a space after 'C' means that a space is
printed at the end of a sentence before the point, which is no option
either.

Does anybody know how i can make a command that adds a space, depending
on whether it is followed by a point or not.

Thanks a lot,

Greetings, Jacco


Sent via Deja.com http://www.deja.com/
Before you buy.

Jacco Huisman

unread,
Mar 3, 2000, 3:00:00 AM3/3/00
to

Ben De Rydt

unread,
Mar 3, 2000, 3:00:00 AM3/3/00
to

Yes, you can.

\usepackage[xspace]
\newcommand{\tc}{\textdegree C\xspace}

HTH,
--
ben . de . rydt at pandora . be ------------------ your comments
http://users.pandora.be/bdr/ ------- inl. IPv6, Linux en Pandora

Ben De Rydt

unread,
Mar 3, 2000, 3:00:00 AM3/3/00
to

ja...@uci.edu

unread,
Mar 3, 2000, 3:00:00 AM3/3/00
to
Jacco Huisman <hui...@eawag.ch> writes:

> I use \textdegree C quite often, so I defined a new command like this
>
> \newcommand{\tc}{\textdegree C}
>
> The problem is that no space is printed, no matter how many spaces i
> give after \tc.

Have you read the TeXbook or the LaTeX book? This is discussed there.

Most of the time, spaces are ignored after command tokens (you can set
up funny conditions by changing the default \catcode's where this
isn't true, but don't worry about that now).

To get a space after \foo, typing \foo\ gives you a space.

Alternatively, load the "xspace" package and use

\newcommand{\tc}{\texdegree C\xspace}

The \xspace macro attempts to "guess" whether you want a space or not
based on the following token. From what I remember, it works in many,
but not all, cases.

Jason

David Carlisle

unread,
Mar 3, 2000, 3:00:00 AM3/3/00
to huis...@my-deja.com

> Does anybody know how i can make a command that adds a space, depending
> on whether it is followed by a point or not.

xspace package, in the standard latex distribution.

David

Axel Reichert

unread,
Mar 7, 2000, 3:00:00 AM3/7/00
to
Jacco Huisman <hui...@eawag.ch> writes:

> \newcommand{\tc}{\textdegree C}

[wondering why nobody pointed this out]

\textcelsius % or \textcentigrade in older versions of textcomp.sty.

Happy TeXing!
--
Axel Reichert -- http://www.axel-reichert.de

0 new messages