Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

When I try to add subscript(I write O_L and O_R to denote left and right ) in my text all the text after that becomes italicized. Any ideas what might be causing this?

share|improve this question
4  
see also tex.stackexchange.com/questions/1013/… –  Caramdir Jun 8 '11 at 17:27
    
i'm surprised that nobody has mentioned the fact that unless O_L and O_R are entered in math mode, the job should stop with the error message ! Missing $ inserted. that's an unambiguous indication that math mode is being entered as tex tries to recover. the _ and what's being subscripted need to be explicitly in math mode to avoid side effects. –  barbara beeton Jun 9 '11 at 12:35
add comment

4 Answers

\documentclass{article}
\begin{document}
Age of empire: O$_\textrm{\scriptsize R}$ and O$_\textrm{\scriptsize L}$. What is next?
\end{document}
share|improve this answer
    
It worked ! Thanks –  rty Jun 8 '11 at 17:13
1  
Semantically there is a better solution. Check the link Caramdir posted in a comment above (this question is a duplicate of that question). –  N.N. Jun 8 '11 at 17:33
add comment

You can't use the subscripts in text mode but only in math mode, so you have two options: the one suggested by xport or using the specific command given by the babel package. For example if you write in italian, the package babel allows you to use the command \ped in this way:

\documentclass{article}
\usepackage[italian]{babel}
\begin{document}
Hi\ped{hi}
\end{document}

I think it will exist a similar command for your language too!

EDIT:

It looks like that the \ped and \ap commands are defined only for italian! If you want to use them you can copy the definitions from the babel manual. So the next example will work:

\documentclass{article}
\usepackage[<your language>]{babel}

\makeatletter
\DeclareRobustCommand*{\bbl@ap}[1]{\textormath{\textsuperscript{#1}}{^{\mathrm{#1}}}}%
\DeclareRobustCommand*{\bbl@ped}[1]{\textormath{$_{\mbox{\fontsize\sf@size\z@ \selectfont#1}}$}{_\mathrm{#1}}}%
\let\ap\bbl@ap
\let\ped\bbl@ped
\makeatother

\begin{document}
Hi\ped{hi}\ap{hi}
$Hi_{hi}^{hi}$
\end{document}

As you can see the positions of subscript and superscript together is a bit different than the one in math mode!

share|improve this answer
add comment

The way I use subscript and superscript in regular text is using the following two commands

\newcommand{\sur}[1]{\ensuremath{^{\textrm{#1}}}}
\newcommand{\sous}[1]{\ensuremath{_{\textrm{#1}}}}

Then it's just a matter of using

O\sur{superscript}
O\sous{subscript}

Of course, you can name those as you want, you don't hate to keep the french names I use :)

share|improve this answer
add comment

What is causing this behavior is the difference between TeX's math mode and text mode. In math mode, each character is a separate entity. Mathematicians, unlike programmmers, don't believe in long expressive names. To a mathematician, a two-character identifier is one character too long.

It's not just your subscripted names that are subject to this treatment. Suppose you have some variable named 'foobar' and you want to use this name in some math expression. To you, that 'foobar' is just a multi-character identifier. That is not how TeX views things in math mode. In math mode, TeX views 'foobar' as if it were 'f*o*o*b*a*r', but with implicit rather than explicit multiplication. TeX will insert a small amount of space between each letter to show that each letter is indeed a separate entity and that these entities are connected by implicit multiplication.

You need to override this behavior whenever you have a multi-character identifier, a multi-character subscript, a multi-character superscript, or any other multi-character entity and TeX is in math mode. There are lots of ways to accomplish this. All of them temporarily throw TeX back into LR (text) mode. One simple approach is to put the entity in a box. Another, and my personal choice, is to use the \text command provided by the AMS math package. Then again, that is because I \RequirePackage{amsmath} or \usepackage{amsmath} in all of my LaTeX documents.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.