12

The \textsuperscript command makes the superscripted text go above the top of capital letters. Here's an example showing what I mean:

\textsuperscript{3} И сказ

enter image description here

As you can see, the superscripted 3 goes above the capital letter height.

I would like something similar to a superscript, but that is constrained by the capital letter height, as shown below.

enter image description here

Is there a relatively simple way to do this in TeX?

10

You can define a command \Textsuperscript in a similar fashion to the kernel's \textsuperscript, but using an appropriate \raise instead of the original ^; something along these lines:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}

\makeatletter
\newlength\mylen
\DeclareRobustCommand*\Textsuperscript[1]{%
\@Textsuperscript{\selectfont#1}}
\def\@Textsuperscript#1{%
\settoheight\mylen{\fontsize\f@size\z@ A}%
{\m@th\ensuremath{\raise.3\mylen\hbox{\fontsize\sf@size\z@#1}}}}
\makeatother

\begin{document}

\textsuperscript{3}И сказ

\Textsuperscript{3}И сказ

\Large
\textsuperscript{3}И сказ

\Textsuperscript{3}И сказ

\Huge
\textsuperscript{3}И сказ

\Textsuperscript{3}И сказ

\end{document}

enter image description here

Here are the original definitions:

\DeclareRobustCommand*\textsuperscript[1]{%
  \@textsuperscript{\selectfont#1}}
\def\@textsuperscript#1{%
   {\m@th\ensuremath{^{\mbox{\fontsize\sf@size\z@#1}}}}}
7

The constraint you pose is not easy to achieve, because it's contradictory: some capital letters (and even numbers), don't cover the whole capital height. Some glyphs are short of it, others overshoot it. Therefore one has to accept a compromise. In the following I used A for getting the height; if your superscripts have only numbers, it's sensible to use 0 in the second measurement using \fontcharht.

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}

\makeatletter
\DeclareRobustCommand*\lowsuperscript[2][\sf@size]{%
  \@lowsuperscript{#1}{#2}}
\newcommand\@lowsuperscript[2]{%
  {\check@mathfonts % be sure \sf@size is defined
   \dimen0=\fontcharht\font`A
   \fontsize{#1}\z@\selectfont
   \advance\dimen0-\fontcharht\font`A % might be \fontcharht\font`0
   \raisebox{\dimen0}{#2}%
  }%
}
\makeatother

\begin{document}
\textsuperscript{3AI}И сказ \quad\lowsuperscript{3AI}И сказ

\Huge\textsuperscript{3AI}И сказ \quad\lowsuperscript{3AI}И сказ

\Huge\textsuperscript{3AI}И сказ \quad\lowsuperscript[10]{3AI}И сказ
\end{document}

The \lowsuperscript command has an optional argument for supplying an explicit font size for the cases, like in \Huge where the subscript size (\sf@size) as determined by LaTeX is too big. I used 10 by way of example, it's probably too small, however.

enter image description here

6

This way works for different font scales (after several edits).

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{stackengine}
\newcommand\myss[1]{\belowbaseline[0pt-\heightof{И}]{\scriptsize#1}}
\begin{document}
\myss{3} И сказ

\LARGE
\myss{3} И сказ
\end{document}

enter image description here

For a version having the superscript scale, I use a \scalebox, in this case with a scale ratio set to 60%

\documentclass{article}
\usepackage[T2A]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{stackengine}
\usepackage{graphicx}
\newcommand\myss[1]{\belowbaseline[0pt-\heightof{И}]{\scalebox{.6}{#1}}}
\begin{document}
\myss{3} И сказ

\LARGE
\myss{3} И сказ
\end{document}

enter image description here

  • +1 for the optical illusion. Both 3s are the same size, but the one on top looks larger. – Peter Olson Sep 9 '13 at 17:44
  • @PeterOlson "Fixed" by adding another package (graphicx) and using a \scalebox. Some would say adding another package is not a fix :^) – Steven B. Segletes Sep 9 '13 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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