0

To display in a decent way both superscript and subscript after some text I'm using these commands

\rlap{\textsuperscript{}}\textsubscript{}

and it works.

I'm looking for a way to increase the vertical space between the superscript and the subscript.

enter image description here

3 Answers 3

4

You can define the combination more properly. With your code TeX is not aware that there are both a subscript and a superscript.

You also don't need to guess what's the shorter part.

\documentclass{article}

\makeatletter
\NewDocumentCommand{\textsubsuper}{mm}{%
  \@textsubsuper{\selectfont #1}{\selectfont #2}%
}
\newcommand{\@textsubsuper}[2]{%
 {\m@th\ensuremath{%
   _{\mbox{\fontsize\sf@size\sf@size #1}}%
   ^{\mbox{\fontsize\sf@size\sf@size #2}}%
 }}%
}
\makeatother

\begin{document}

\textbf{Friends\textsubsuper{\itshape Concentration}{\itshape Ritual}}

\end{document}

enter image description here

4
  • I can only partially understand what is happening in command definition : 1. What does the "mm" mean in \textsubsuper}{mm} ? 2. Why there is a "\sf@size" twice in line of the \mbox ? 3. Making tex aware of both subscript and superscript is done by using the math mode? Is it the only method, isn't it?
    – Paul
    Commented Apr 21 at 21:47
  • 1
    @Paul \fontsize takes two arguments: the font size proper and the baseline skip; since we're not making paragraphs, 0 as the second argument would do as well. I just merged the definitions of \textsubscript and \textsuperscript, which indeed use math mode. The mm part means that the command to be defined takes to mandatory arguments.
    – egreg
    Commented Apr 21 at 21:52
  • please have a bit more patience. I still don't understand why "\sf@size" was needed twice in these lines : _{\mbox{\fontsize\sf@size\sf@size #1}}% ^{\mbox{\fontsize\sf@size\sf@size #2}}%
    – Paul
    Commented Apr 21 at 23:18
  • 1
    @Paul As I said, \fontsize wants two arguments. In this particular case, the second one can be any dimension, because it’s about the baseline skip. Who wrote the command decided for \sf@size instead of 0.
    – egreg
    Commented Apr 22 at 8:00
4

When we are using math mode for placing these subscripts, superscripts, then the vertical spacing between them look OK. For example, using \mathbox from OpTeX:

\def\spsb#1#2{$^{\mathbox{\it #1}}_{\mathbox{\it #2}}$}

{\bf Friends}\spsb{Ritual}{Concentration}

\bye

enter image description here

1

Using the altsubsup package since 2022.

\documentclass[12pt]{article}
\usepackage{altsubsup}
\usepackage{bm}
\begin{document}
\begin{displaymath}
\bm{Friends}_{\bm{Concentration}}^{\bm{Ritual}}
\end{displaymath}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .