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.

I create superscripts for indexes for notes manually with \raisebox. What I don't like is that Latex changes the line spacing to fit a manual superscript into a line. For instance:

\documentclass{article}\usepackage{setspace}\begin{document}
\scriptsize
\parbox{3cm}{
\begin{spacing}{0.8}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST {\tiny\raisebox{3pt}{b}}TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST\end{spacing}}
\ \ \ \ \ \ \ \ \ 
\parbox{3cm}{
\begin{spacing}{0.8}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST\end{spacing}}
\end{document}

creates (without the black lines)

Left \parbox with manual superscript (-> too much spacing in line before the superscript), right \parbox without (-> equal spacing). How can I get rid of the extra spacing in the left \parbox. \raisebox can be replaced if there is a better way. It is ok if the superscript overlaps with the text in the previous line.

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted

You need to use the (first) optional argument of \raisebox to compensate. It allows you to tell LaTeX how high the raised box officially is. So setting it to 0pt would ignore its height. There is also a second optional argument which determines the depth. The dimensions \height, \width, \depth and \totalheight can be used in all three arguments and hold the original dimensions of the content.

\documentclass{article}\usepackage{setspace}\begin{document}
\scriptsize
\parbox{3cm}{
\begin{spacing}{0.8}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST {\tiny\raisebox{3pt}[0pt]{b}}TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST\end{spacing}}
\ \ \ \ \ \ \ \ \ 
\parbox{3cm}{
\begin{spacing}{0.8}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST\end{spacing}}
\end{document}
share|improve this answer
    
I normally use \raisebox{verticalshift}[0pt][0pt]{text}, but this will make the box have zero height/depth. What are the best values to supply for the two optional middle arguments to give the box exactly ordinary line height/depth? I would think that this is relevant if the line consists only of such material. –  Lover of Structure Jan 21 '13 at 22:43
1  
@LoverofStructure: You can use the dimension macros mentioned in the answer: \raisebox{<shift>}[\height][\depth]{text} will typeset a raised (or lowered for negative shifts) "text" but with the original height and depth. You can also do calculations based on the original dimensions if you use the calc package or e-TeXs \dimenexpr .. \relax. Also, my adjustbox package provides similar modificators which all allow arithmetic expressions. –  Martin Scharrer Jan 21 '13 at 22:57
    
Many thanks! The reason why I asked is that I wasn't sure whether the dimensions of \height, \depth, etc are those of the supplied text or those of any potential text around the \raisebox; it's the latter I am interested in. Could you very briefly confirm? –  Lover of Structure Jan 22 '13 at 1:03
    
@LoverofStructure: Yes, it is the height and depth of the content of \raisebox (see the last sentence of my answer again). Macros do not have knowledge about the potential text around them. –  Martin Scharrer Jan 22 '13 at 6:51
1  
@LoverofStructure: I don't understand why you need to do this with the text around the raised material. Simply use \raisebox{<shift>}[\height][\depth]{text} to make LaTeX take the original height and depth of the raised content. The height and depth of the line is always the maximum height and depth of any content, so as long the rest of the line isn't higher or deeper than the native height and depth of the raised text you will get a normal line. –  Martin Scharrer Jan 22 '13 at 10:35
show 2 more comments

Generally, you could use \smash to remove a height, such as

{\tiny\raisebox{3pt}{\smash{b}}}
share|improve this answer
add comment

Why don't you simply use \textsuperscript?

\documentclass{article}
\usepackage{setspace}

\begin{document}
\scriptsize

\parbox{3cm}{
\begin{spacing}{0.8}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST \textsuperscript{\smash{b}}TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST\end{spacing}}
\ \ \ \ \ \ \ \ \ 
\parbox{3cm}{
\begin{spacing}{0.8}
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST 
T    EST TEST TEST TEST TEST TEST TEST TEST\end{spacing}}

\end{document}
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.