# vertically align texts of different sizes and allow line breaks

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}


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.

• 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

\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}

• Wow! Amazing! I confirm it works. Thanks. Now time to understand your codes. – chan1142 Oct 11 '16 at 14:34
• So David, you implemented what you suggested in your first comment. Superb! – chan1142 Oct 11 '16 at 14:51