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.
\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
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.
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
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
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
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
> 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
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
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.
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.
>> 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
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.)
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.
Only one Rowland!
Jon