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.

How to define a macro, say \pretextsuperscript, to get a presuperscript ahead a word in text mode?

Just simply write \textsuperscript{2}hormone and \textsuperscript{2}population is incorrect. Why say that you can see from

\usepackage{mathtools}
\begin{document}
$\prescript{2}{}{h}$ $\prescript{2}{}{p}$
\end{document}

The prescript (in former sample is "2") should be vertically adjusted with the first letter of the argument of prescript. Also, the prescript should be upshape. I found the \prescript can only be used in math mode.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Text mode

If you want a \textpresuperscript to be used in text mode, then

\newcommand{\textpresuperscript}[1]{%
  \textsuperscript{#1}\nobreak\hspace{0pt}}

will give you the possibility to write

\textpresuperscript{2}longword

with the result that "longword" can be hyphenated, but there will be no break between the superscript and the (first segment of the) following word. Here's an example:

\parbox{4cm}{What's \textpresuperscript{2}supercalifragilisticexpialidocious?}

produces


enter image description here


Math mode

If one needs to put a word in the presuperscript, then (mathtools is required)

$\prescript{\text{word}}{}h$

should be the solution. If the word should be in upright shape independent of the context outside the formula, then

$\prescript{\text{\normalfont word}}{}h$

will do. Of course one can define one's own macro:

\newcommand{\pretextsuperscript}[1]{\prescript{\text{#1}}{}}

(possibly adding \normalfont).

share|improve this answer
    
Thanks for your reply. There is a shortcoming in your solution: the word with superscript cannot automatically be hyphenated because the \text is basically a hbox. –  afternoon Dec 28 '11 at 14:40
    
You can't have hyphenation in superscripts; the only way would be using an "all-superscript-font". Moreover, text in math mode is never hyphenated. What's precisely your problem? –  egreg Dec 28 '11 at 14:51
    
I want the letter "h" (almost a word for notation, like \pretextsuperscript{2}{notation}) in upshape and can have hyphenation. If I place the all thing in math environment, I think I have to put "notation" in a box. –  afternoon Dec 28 '11 at 15:05
    
Please, edit your message to show your needs more clearly: where's the "h" in your last comment? –  egreg Dec 28 '11 at 15:07
    
Okey. By the way, "h" is in your solution too. –  afternoon Dec 28 '11 at 15:08

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.