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.

Possible Duplicate:
How to typeset subscript in usual text mode?

I sometimes want to typeset something simple like $N_2$ or $3^2$ in a Heading, other times in a paragraph of normal text. I want all of it to be typeset in the surrounding font. In normal text this works quite good with $\textrm{N}^\textrm{2}$, even though it is too complicated. For Headings I have to know how my headings are typeset (if they use sans, italic, bold, etc.) And if I then use the appropriate command and later change my mind about heading formatting, I have to redo it. Is there a command to somehow "step out" of math into whatever is the highermost level of current formatting?

So far I could only find answers like: use this package, or this command (that only solves a specialized case). I am looking for a more general understanding of what's going on, does someone have a link at hand to a short summary to the fonts and their interaction in LaTeX?

share|improve this question
2  
See tex.stackexchange.com/q/1013/16895 –  Guido Sep 10 '12 at 16:06
add comment

marked as duplicate by percusse, Tom Bombadil, diabonas, cgnieder, Harish Kumar Sep 13 '12 at 3:00

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2 Answers

up vote 5 down vote accepted

Type your superscripts and subscripts using \textsuperscript and \textsubscript respectively. The former is defined in latex.ltx while the latter could be defined similarly:

enter image description here

\documentclass{article}
\makeatletter
% \textsubscript defined equivalent to \textsuperscript in latex.ltx
\DeclareRobustCommand*\textsubscript[1]{%
  \@textsubscript{\selectfont#1}}
\def\@textsubscript#1{%
  {\m@th\ensuremath{_{\mbox{\fontsize\sf@size\z@#1}}}}}
\makeatother
\begin{document}
\tableofcontents
\section{Section $N^2$ and $N_2$}
\section{Section N\textsuperscript{2} and N\textsubscript{2}}
\end{document}

fixltx2e also provides the above defintion by default. So, adding

\usepackage{fixltx2e}% http://ctan.org/pkg/fixltx2e

to your document preamble would allow you to use \textsubscript.

share|improve this answer
3  
fixltx2e defines \textsubscript: I'd always load this package for the fix to \( ... \) anyway. –  Joseph Wright Sep 12 '12 at 6:36
add comment

To avoid the complicated phrases, which I often encounter when I want multi-character subscripts, I would normally put macros like these at the start of the document.

%Macros    
% Italic text with italic exponent
\newcommand{\me}[2]{\ensuremath{\mathit{#1}^\mathit{#2}}}
% Normal text with normal exponent
\newcommand{\te}[2]{\ensuremath{\textrm{#1}^\textrm{#2}}} 
% Italic text with italic multi-character subscript index
\newcommand{\ms}[2]{\ensuremath{\mathit{#1}_\mathit{#2}}}
% Normal text with normal subscript index
\newcommand{\ts}[2]{\ensuremath{\textrm{#1}_\textrm{#2}}} 

They can be used inside or outside of the math environments.

share|improve this answer
add comment

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