我想在latex
( xelatex
) 中垂直对齐不同大小的文本。例如,normal {\footnotesize small} normal
是基线对齐,而我想要居中对齐。我知道我可以使用\lower
或\raisebox
来处理小块,但我想允许换行也是。由于我经常需要在各种长度的文本中使用此功能,所以我想要一个宏。我该怎么做?
\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}
我读了同一行不同大小的字体垂直对齐但答案依赖于不允许换行的框。我也读过类似 \raisebox 的东西尊重换行符但我不确定是否有答案。
答案1
\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}