Rechtsbündige Ausrichtung zweier linker unregelmäßiger Linien

Rechtsbündige Ausrichtung zweier linker unregelmäßiger Linien

Ich habe zwei kleine Textzeilen mit unterschiedlicher Breite. Ich möchte sie rechtsbündig ausrichten und dabei ihre Linksbündigkeit und die Zeilenhöhe des vorherigen Textes beibehalten.

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

Bildbeschreibung hier eingeben

Antwort1

tabularSie können eine mit OP-Ausrichtung verwenden [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}

Bildbeschreibung hier eingeben

Antwort2

\strutDie einfachste Lösung besteht darin, ein „beide“ am Ende des vorhergehenden Textes und innerhalb des „ “ einzufügen \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}

Die Verwendung primitiver Boxbefehle in LaTeX wird jedoch nicht empfohlen.

verwandte Informationen