4

I am using LuaLaTeX compiler with KOMA-scrbook class.

I need to define a command with superscript text, but I do not know why LaTeX disable the hyphenation of words with superscript text.

\documentclass{scrbook}

\usepackage[USenglish]{babel}

\begin{document}

\parbox{0.1cm}{
  advanced, however}

\parbox{0.1cm}{
  advanced,\textsuperscript{1} however\textsuperscript{2}, maybe\textsuperscript{†}}




\end{document}

Why the words "advanced" and "however" do not have hyphenation when used with \textsuperscript?

2 Answers 2

9

\textsuperscript is implemented using TeX's math mode, so however\textsuperscript{1} behaves similar to however$abc$. Since the inline math formula is not separated from the word and hyphenation of "words" partially consisting of mathematical expressions is not really well-defined, TeX does not try to hyphenate such constructs.

You can tell LuaTeX that the previous word ended by adding an explicit \wordboundary:

\documentclass{scrbook}

\usepackage[USenglish]{babel}

\begin{document}

\parbox{0.1cm}{
  advanced, however}

\parbox{0.1cm}{
  advanced,\wordboundary\textsuperscript{1} however\wordboundary\textsuperscript{2}, maybe\wordboundary\textsuperscript{†}}
\end{document}

enter image description here

3
  • Neat! I just found out about the \wordboundary macro.
    – Mico
    Sep 17, 2021 at 6:17
  • 1
    @Mico Not that it matters too much, but technically it's a primitive and not a macro. Sep 17, 2021 at 6:20
  • Or applying \leavevmode\nobreak at the beginning of \@textsuperscript? OK, this might change many documents.
    – egreg
    Sep 17, 2021 at 9:07
2

Another workaround would be to use a font which has real superscripts, like Libertinus, EBGaramond, Erewhon, etc., together with the realscript package. Then your example would work out of the box.

\documentclass{scrbook} 
\usepackage[USenglish]{babel}
\usepackage{realscripts} % loads fontspec
\setmainfont{erewhon}

\begin{document}
\parbox{0.1cm}{%
  advanced, however, maybe}

\parbox{0.1cm}{%
  advanced,\textsuperscript{1} however\textsuperscript{2},
  maybe\textsuperscript{†}}
\end{document}

output

You must log in to answer this question.

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