
긴 텍스트 문자열이 있는데 한 줄 이상을 차지합니다. 첫 번째 줄과 두 번째 줄의 너비가 동일하도록 줄 바꿈이 발생하도록 하고 싶습니다. 어떻게 해야 하나요?
A very long line of text that wraps around to the other line and needs to be broken differently.
이런 (종류의)
A very long line of text that wraps around to the
other line and needs to be broken differently.
답변1
이것은 매우 단순한 제안입니다. 텍스트의 너비를 측정하고 이 너비의 절반인 미니페이지에 넣으세요.
\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}
약간 더 정교한 솔루션: 텍스트가 두 줄에 들어갈 만큼 충분히 넓어질 때까지 반복합니다.
\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}