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

\textrm vs. \text

2,410 views
Skip to first unread message

Andreas Keil

unread,
Sep 26, 2003, 1:04:14 PM9/26/03
to
I know this question may be old, but I didn't find a satisfying answer yet:

What is the difference between \textrm and the AMS command \text?

The following is my understanding of \mathrm, \textrm, and \text:
- use \mathrm to change to math upright font with math spacing
- use \textrm to change to text font with text spacing
- use \text to change to text font with text spacing

Please correct me, if I'm wrong and enlighten my understanding, especially
of the definition for the AMS \text command.

--
Andreas

Please don't respond to my mail address, it's faked.


Walter Schmidt

unread,
Sep 27, 2003, 11:04:07 AM9/27/03
to
Andreas Keil schrieb:

>
> I know this question may be old, but I didn't find a satisfying answer yet:
>
> What is the difference between \textrm and the AMS command \text?

\textrm switches to the roman text font (which may
be inappropriate in a sans-serif environment) and
adopts the font size that was is use before the
formula started (which may be inappropriate, e.g.
in a subscript.)

\text, in contrast, switches to the same font that is
used in the text around the formula (not necessarily
roman), and it selects the size that is appropiate
in the particular place in formula.

HTH
Walter

Andreas Keil

unread,
Sep 27, 2003, 12:53:24 PM9/27/03
to
"Walter Schmidt" <la...@arcor.de> a écrit dans le message de
news:3F75A6E7...@arcor.de...
> Andreas Keil schrieb:

> >
> > What is the difference between \textrm and the AMS command \text?
>
> \textrm switches to the roman text font (which may
> be inappropriate in a sans-serif environment) and
> adopts the font size that was is use before the
> formula started (which may be inappropriate, e.g.
> in a subscript.)
>
> \text, in contrast, switches to the same font that is
> used in the text around the formula (not necessarily
> roman), and it selects the size that is appropiate
> in the particular place in formula.

Right! I tested the differences between \mathrm, \textrm, and \text a lot
but it seems that I must have gone mad not seeing the difference. (I really
tested it with a different outer font.)

So, am I right with the statement that the \text command works like an
opposite to \ensuremath in the way that it only escapes math mode (if
necessary) without changing size or font (compared to the outer settings)
and therefore I could use \text in any command definition where I want to
assure that I'm in text mode, right?

--
Andreas.

Walter Schmidt

unread,
Sep 27, 2003, 1:39:36 PM9/27/03
to
Andreas Keil schrieb:

>
> So, am I right with the statement that the \text command works like an
> opposite to \ensuremath in the way that it only escapes math mode (if
> necessary) without changing size or font (compared to the outer settings)
> and therefore I could use \text in any command definition where I want to
> assure that I'm in text mode, right?

I don't know whether/how \text works in text mode.
Read the AMS documentation.

Yoo may equally well use a simple \mbox for the desired
purpose. I'd say _this_ is the counterpart to \ensuremath.

The only difference to \text is, that \mbox takes the font
_size_, too, from the environemnt, so it will not work in
super- and subscripts.

HTH
Walter

Robin Fairbairns

unread,
Sep 27, 2003, 1:58:45 PM9/27/03
to
Walter Schmidt <la...@arcor.de> writes:
>Andreas Keil schrieb:
>> I know this question may be old, but I didn't find a satisfying answer yet:
>>
>> What is the difference between \textrm and the AMS command \text?
>
>\textrm switches to the roman text font (which may
>be inappropriate in a sans-serif environment) and
>adopts the font size that was is use before the
>formula started (which may be inappropriate, e.g.
>in a subscript.)

i thought this, but tried it before posting. i was rather surprised
to find \textrm _does_ change size to follow script sizes.

try (with relevant ams package loaded)

$a_{\textrm{blah}} = a_{\text{blah}} \ne a_{\mbox{blah}}$

and judge the truth of its statement for yourself.

seems to me, \text is superfluous, for the user who knows what the
surrounding text family is.
--
Robin (the partially spineless) Fairbairns, Cambridge

Harald Harders

unread,
Sep 27, 2003, 2:25:11 PM9/27/03
to
On Sat, 27 Sep 2003 19:39:36 +0200, Walter Schmidt wrote:
> Andreas Keil schrieb:
>>
>> So, am I right with the statement that the \text command works like an
>> opposite to \ensuremath in the way that it only escapes math mode (if
>> necessary) without changing size or font (compared to the outer settings)
>> and therefore I could use \text in any command definition where I want to
>> assure that I'm in text mode, right?
>
> I don't know whether/how \text works in text mode.
> Read the AMS documentation.

In text mode, \text just calles \mbox.



> Yoo may equally well use a simple \mbox for the desired
> purpose. I'd say _this_ is the counterpart to \ensuremath.

Is this really true? \mbox inhibits line breaks. And \ensuremath doesn't.

Yours
Harald

--
Harald Harders Langer Kamp 8
Institut für Werkstoffe D-38106 Braunschweig
Technische Universität Braunschweig Germany
E-Mail: h.ha...@tu-bs.de Tel: +49 (5 31) 3 91-3062
WWW : http://www.tu-bs.de/institute/ifw/ Fax: +49 (5 31) 3 91-3058

Walter Schmidt

unread,
Sep 28, 2003, 9:59:21 AM9/28/03
to
Robin Fairbairns schrieb:
>
> Walter Schmidt <la...@arcor.de> writes:
> [...]

> >\textrm switches to the roman text font (which may
> >be inappropriate in a sans-serif environment) and
> >adopts the font size that was is use before the
> >formula started (which may be inappropriate, e.g.
> >in a subscript.)
>
> i thought this, but tried it before posting. i was rather surprised
> to find \textrm _does_ change size to follow script sizes.
>
> try (with relevant ams package loaded)
>
> $a_{\textrm{blah}} = a_{\text{blah}} \ne a_{\mbox{blah}}$

Oh, I didn't know, either. Apparently the amstext
package redefines \textrm.

> \text is superfluous, for the user who knows what the
> surrounding text family is.

With all due respect: this would not be in the spirit
of logical markup!

Walter

Rowland McDonnell

unread,
Sep 28, 2003, 7:16:25 PM9/28/03
to
Walter Schmidt <la...@arcor.de> wrote:

> Robin Fairbairns schrieb:
> >
[snip]

> > \text is superfluous, for the user who knows what the
> > surrounding text family is.
>
> With all due respect: this would not be in the spirit
> of logical markup!

Or, from the practical point of view, how about cutting and pasting
equations between different docs? Ease of re-use - there's a practical
benefit to having the benefits of logical markup in this case.

Rowland.

--
Remove the animal for email address: rowland....@dog.physics.org
PGP pub key 0x62DCCA78 Sorry - the spam got to me
http://www.mag-uk.org
UK biker? Join MAG and help keep bureaucracy at bay

Robin Fairbairns

unread,
Sep 29, 2003, 3:05:30 AM9/29/03
to
real-addr...@flur.bltigibbet (Rowland McDonnell) writes:
>Walter Schmidt <la...@arcor.de> wrote:
>> Robin Fairbairns schrieb:
>> > \text is superfluous, for the user who knows what the
>> > surrounding text family is.
>>
>> With all due respect: this would not be in the spirit
>> of logical markup!
>
>Or, from the practical point of view, how about cutting and pasting
>equations between different docs? Ease of re-use - there's a practical
>benefit to having the benefits of logical markup in this case.

text in maths is one of the answers i had written for the faq while
convalescing; thanks both for further arguments in favour of the "one
true way" ;-)

Andreas Keil

unread,
Sep 29, 2003, 5:46:31 AM9/29/03
to
"Robin Fairbairns" <r...@cl.cam.ac.uk> a écrit dans le message de
news:bl8ljq$eke$2...@pegasus.csx.cam.ac.uk...

> text in maths is one of the answers i had written for the faq while
> convalescing; thanks both for further arguments in favour of the "one
> true way" ;-)

Robin, did you already provide this answer in the "UK TeX FAQ"? I didn't
manage to find it.

--
Andreas

For replying, remove the fruit from my address:
andrea...@apple.nurfuerspam.de


Robin Fairbairns

unread,
Sep 29, 2003, 10:48:59 AM9/29/03
to
"Andreas Keil" <andrea...@apple.nurfuerspam.de> writes:
>"Robin Fairbairns" <r...@cl.cam.ac.uk> a écrit ...

>> text in maths is one of the answers i had written for the faq while
>> convalescing; thanks both for further arguments in favour of the "one
>> true way" ;-)
>
>Robin, did you already provide this answer in the "UK TeX FAQ"? I didn't
>manage to find it.

i've not been at work for more than a month, and i don't put new
versions on the web except when i'm at work. so the stuff i've
written while convalescing is still sitting, waiting.

David Klassen

unread,
Sep 29, 2003, 1:41:16 PM9/29/03
to
r...@cl.cam.ac.uk (Robin Fairbairns) wrote in message news:<bl4j4l$hqc$1...@pegasus.csx.cam.ac.uk>...

> Walter Schmidt <la...@arcor.de> writes:
> >Andreas Keil schrieb:
> >> I know this question may be old, but I didn't find a satisfying answer yet:
> >>
> >> What is the difference between \textrm and the AMS command \text?
> >
> >\textrm switches to the roman text font (which may
> >be inappropriate in a sans-serif environment) and
> >adopts the font size that was is use before the
> >formula started (which may be inappropriate, e.g.
> >in a subscript.)
>
> i thought this, but tried it before posting. i was rather surprised
> to find \textrm _does_ change size to follow script sizes.
>
> try (with relevant ams package loaded)
>
> $a_{\textrm{blah}} = a_{\text{blah}} \ne a_{\mbox{blah}}$
>
> and judge the truth of its statement for yourself.
It also appears that $a_{\mbox{\scriptsize blah}}$
is the same as the first two. But that may be just obvious...?

Robin Fairbairns

unread,
Sep 29, 2003, 3:44:50 PM9/29/03
to
kla...@rowan.edu (David Klassen) writes:
>r...@cl.cam.ac.uk (Robin Fairbairns) wrote...

>> try (with relevant ams package loaded)
>>
>> $a_{\textrm{blah}} = a_{\text{blah}} \ne a_{\mbox{blah}}$
>
>It also appears that $a_{\mbox{\scriptsize blah}}$
>is the same as the first two. But that may be just obvious...?

well, obvious to me; but who knows if it's obvious to everyone else.
it's painful to type, for sure. and it's not actually the same if the
surrounding text is a different size from the document body font.

Frank Mittelbach

unread,
Sep 29, 2003, 4:54:30 PM9/29/03
to
Walter Schmidt wrote:

>> i thought this, but tried it before posting. i was rather surprised
>> to find \textrm _does_ change size to follow script sizes.
>>
>> try (with relevant ams package loaded)
>>
>> $a_{\textrm{blah}} = a_{\text{blah}} \ne a_{\mbox{blah}}$
>
> Oh, I didn't know, either. Apparently the amstext
> package redefines \textrm.

no it sort of uses \text if it is around :-) else \mbox



>> \text is superfluous, for the user who knows what the
>> surrounding text family is.
>
> With all due respect: this would not be in the spirit
> of logical markup!

indeed -- in some sense i should never made them accessible in math

frank

Rowland McDonnell

unread,
Sep 30, 2003, 8:47:06 PM9/30/03
to
Robin Fairbairns <r...@cl.cam.ac.uk> wrote:

The bit that I find mildly exasperating is that `the one true way' of
logical markup really does work out better almost all the time (I did a
quick and dirty hack the day before yesterday in a quick and dirty LaTeX
document which was never going to be used beyond today so I could save
myself the bother of looking something up in the docs - and then looked
up what I should have done and `did it right' yesterday (the day after I
wrote the dog originally) because, erm, I ran into a need to use the
code elsewhere. Argh). I expect most long-term LaTeX users have
scattered archives of ancient documents containing hideous bodges (I
know I have). Ever tried re-using an 8 year old 2.09 doc with 2e? When
the original doc's so old you can't really remember writing it, let
alone what it was you were getting at with *that* (yuck - was that me?
Yep. Urgh.) mess? Not good - but if you've used logical markup, even
if the code's broken with 2e you can usually figure out what you *meant*
and re-create it.

I have a trite and irritating little saying I repeat to myself these
days when LaTeXing: `Spend a little extra time and bother now, and
you'll save yourself a lot of time and bother in the future' (as it
happens, I use the same saying when mechanicking, doing work on the
house, and, erm, virtually everything I do. It works, damnit.)

David Klassen

unread,
Oct 1, 2003, 8:51:03 AM10/1/03
to
r...@cl.cam.ac.uk (Robin Fairbairns) wrote in message news:<bla23i$k8h$2...@pegasus.csx.cam.ac.uk>...

> kla...@rowan.edu (David Klassen) writes:
> >r...@cl.cam.ac.uk (Robin Fairbairns) wrote...
> >> try (with relevant ams package loaded)
> >>
> >> $a_{\textrm{blah}} = a_{\text{blah}} \ne a_{\mbox{blah}}$
> >
> >It also appears that $a_{\mbox{\scriptsize blah}}$
> >is the same as the first two. But that may be just obvious...?
>
> well, obvious to me; but who knows if it's obvious to everyone else.
> it's painful to type, for sure. and it's not actually the same if the
> surrounding text is a different size from the document body font.

Oooh! Now, that's interesting. OK, so now I have another reason to
change my method of subscripting words. Other than the obvious one
of \text is FAAAAAR less cumbersome.

Jon

unread,
Oct 2, 2003, 6:28:28 PM10/2/03
to

"Rowland McDonnell" <real-addr...@flur.bltigibbet> wrote in message
news:1g23j3i.16ing7w10lzjjgN%real-addr...@flur.bltigibbet...
wrote:

>
> I have a trite and irritating little saying I repeat to myself these
> days

Only one Rowland!

Jon


0 new messages