兩條左側鋸齒線右對齊

兩條左側鋸齒線右對齊

我有兩行不同寬度的小文字。我想將它們向右刷新,保持其左對齊和上一個文字的行高。

\documentclass{article}
\usepackage{fontspec} 

\usepackage{lipsum}

\begin{document}

I was yet young in life, which I had begun early; but my intimacy with him was of a recent date: we had been educated at the same schools and university; but his progress through these had preceded mine, and he had been deeply initiated into what is called the world while I was in noviciate noviciate noviciate.

\hfill\vbox{\hbox{Foo}
\hbox{Foobar}}

\end{document}

在此輸入影像描述

答案1

您可以使用tabularwith [t]op 對齊。

\documentclass{article}
\usepackage{fontspec}

\usepackage{lipsum}

\begin{document}

I was yet young in life, which I had begun early; but my intimacy with him was of a recent date: we had been educated at the same schools and university; but his progress through these had preceded mine, and he had been deeply initiated into what is called the world while I was in noviciate noviciate noviciate.

\hspace*{\fill}
\begin{tabular}[t]{l@{}}
Foo\\
Foobar
\end{tabular}

\end{document}

在此輸入影像描述

答案2

最簡單的解決方案是將\strut兩者放在前面文字的末尾和內部\hbox

\documentclass{article}
\usepackage[T1]{fontenc} 

\usepackage{lipsum}

\begin{document}

I was yet young in life, which I had begun early; but my intimacy with him
was of a recent date: we had been educated at the same schools and
university; but his progress through these had preceded mine, and he had
been deeply initiated into what is called the world while I was in
noviciate noviciate noviciate.\strut

\hfill\vbox{\hbox{\strut Foo}
\hbox{Foobar}}

\end{document}

但不建議在 LaTeX 中使用原始裝箱指令。

相關內容