|
|
Home Personal Work Computers Miscellaneous LaTeX Software Projects Rendering Tutorial UNIX Commands Using CVS Case Modding Base Wiki |
Subscript and superscrint in Text ModeThe problemThe common way in Latex to have super- subscript is to use $a_x b^y$ writes out The Latex super- and subscript operators
Welcome to the 21^{st} century.
in your text since the superscript operator is not recognized in the text mode we're in. Working toward a solutionOne solution to the problem is to write
Welcome to the 21$^{st}$ century.
in order to bring Latex into math mode in order to write the superscript. But there's some problems with simply having text in math mode. For one, it is written in a different script (usually italic), and words are collated when they are offered to math mode with spaces. To solve this, we can ask math mode to go back to text mode and than write our text, i.e. with
Welcome to the 21$^{\textrm{st}}$ century.
It seems a bit weird, but we're in fact asking math mode to bring us in superscript mode, and then go back to text mode to write our text. Encapsulating this as commandsIf you're writing about centuries, or ordinal numbers such as first, second, third, ... you might want to consider writing the following new commands and put them in your Latex document's preamble. (Greggory Gruen suggested adding sufficient {}s, to ensure it works with all La Te X versions)
\newcommand{\superscript}[1]{\ensuremath{^{\textrm{#1}}}}
\newcommand{\subscript}[1]{\ensuremath{_{\textrm{#1}}}}
so you can write
Welcome to the 21\superscript{st} century.
other such quick commands can be written with
\newcommand{\th}[0]{\superscript{th}}
\newcommand{\st}[0]{\superscript{st}}
\newcommand{\nd}[0]{\superscript{nd}}
\newcommand{\rd}[0]{\superscript{rd}}
so you can write Carl took 1\st place. Elly, Tom and Ann came in 2\nd, 3\rd and 4\th.
|
|
|
All contents copyrighted 2000-2006 Anthony Liekens unless otherwise noted. Powered by PmWiki Page last modified on February 27, 2008, at 02:05 PM. |