
Tengo una larga cadena de texto y ocupa más de una línea. Quiero que se produzca el salto de línea para que la primera línea y la segunda línea tengan el mismo ancho. ¿Cómo hago esto?
A very long line of text that wraps around to the other line and needs to be broken differently.
en este (tipo de)
A very long line of text that wraps around to the
other line and needs to be broken differently.
Respuesta1
Esta es una propuesta muy simplista: mide el ancho del texto y colócalo en una minipágina de la mitad de ese ancho.
\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}
Una solución un poco más sofisticada: hacer un bucle hasta que el texto sea lo suficientemente ancho como para caber en dos líneas.
\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}