1

I would like to vertically align texts of different sizes in latex (xelatex). For example, normal {\footnotesize small} normal does base-line alignment, while I want center-align. I know I can use \lower or \raisebox for small chunks, but I want to allow line breaks too. As I want this functionality very often in texts of various lengths, I would like a macro. How could I do it?

\documentclass[12pt]{article}
\begin{document}

I have notes {\footnotesize (footnote-size, too low)}.
Want to raise it {\lower-.2ex\hbox{\footnotesize (like this)}} a bit
{\footnotesize (but I want to allow for line break)}. How could I do this?

\end{document}

enter image description here

I've read Vertical alignment of fonts of different sizes on same line but the answers rely on boxes which don't allow line breaks. I've also read Something like \raisebox that respects line breaks but I'm not sure if there is an answer.

chan1142
  • 309
  • 1
  • 9
  • 1
    you could raise each letter separately but that would break all kerning and ligatures. If you are prepared to accept breaks just between words you could separately \raise (or \lower as you have it) each word and have the word spaces outside to allow line breaking. – David Carlisle Oct 11 '16 at 14:20

1 Answers1

2

enter image description here

\documentclass[12pt]{article}

\makeatletter
\def\foo#1{{\footnotesize\xfoo#1 \xfoo}}
\def\xfoo#1 #2{%
\raisebox{.3ex}{#1}%
\ifx\xfoo#2\expandafter\@gobble
\else\expandafter\@firstofone
\fi
{ \xfoo#2}}
\makeatother
\begin{document}

I have notes  \foo{(footnote-size, too low)}.
Want to raise it \foo{(like this)} a bit
\foo{(but I want to allow for line break)}. How could I do this?

\end{document}
David Carlisle
  • 757,742