两条左侧参差不齐的线右对齐

两条左侧参差不齐的线右对齐

我有两行宽度不同的小文本。我想让它们右对齐,保持左对齐和前一个文本的行高。

\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 中使用原始的装箱命令。

相关内容