
Ich habe eine lange Textfolge, die sich über mehrere Zeilen erstreckt. Ich möchte, dass der Zeilenumbruch so erfolgt, dass die erste und die zweite Zeile die gleiche Breite haben. Wie mache ich das?
A very long line of text that wraps around to the other line and needs to be broken differently.
in diese (Art von)
A very long line of text that wraps around to the
other line and needs to be broken differently.
Antwort1
Dies ist ein sehr einfacher Vorschlag: Messen Sie die Breite des Textes und platzieren Sie ihn auf einer Miniseite mit der halben Breite.
\documentclass{article}
\newcommand\BreakEven[1]{\setbox0\hbox{#1}%
\begin{minipage}{\dimexpr0.5\wd0}
#1
\end{minipage}}
\begin{document}
\BreakEven{A very long line of text that wraps around to the other line and
needs to be broken differently.}
\end{document}
Eine etwas ausgefeiltere Lösung: Schleife, bis der Text gerade breit genug ist, um in zwei Zeilen zu passen.
\documentclass{article}
\newlength\TestWidth
\newlength\MyBaseLineskip
\newcommand\BreakEven[2][1.5]{\setbox0\hbox{#2\global\MyBaseLineskip=\baselineskip}%
\TestWidth=0.45\wd0\relax
\loop
\setbox0\hbox{\begin{minipage}{\TestWidth}
#2
\end{minipage}}
\ifdim\ht0>#1\MyBaseLineskip\relax
\advance\TestWidth by 1pt\relax
\repeat
\begin{minipage}{\TestWidth}
#2
\end{minipage}}
\begin{document}
\BreakEven{A very long line of text that wraps around to the other line and
needs to be broken differently.}
\BreakEven{\footnotesize\textit{Sundays in Advent at Prime, and on the day of Saint Paul the apostle}}
\end{document}