Выравнивание по правому краю двух левых неровных линий

Выравнивание по правому краю двух левых неровных линий

У меня есть две небольшие строки текста разной ширины. Я хочу выровнять их по правому краю, сохранив выравнивание по левому краю и высоту строки предыдущего текста.

\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

Вы можете использовать выравнивание tabularс [t]оп.

\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

Самое простое решение — поместить \strutboth в конце предыдущего текста и внутри \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 не рекомендуется.

Связанный контент