Here I provide \centerlines[<delta length>]{<n>}{<content>}
to assist in the process of setting content
over n
lines. It sets the content in an hbox, and divides the content width by n
. It then creates a parbox of that width + delta length
(default 5pt) and resets the content in that \parbox
, which has been centered.
\documentclass{article}
\usepackage[showframe,pass]{geometry}
\usepackage{fp}
\makeatletter
\newcommand\centerlines[3][5pt]{%
\sbox0{#3}%
\FPdiv\result{\strip@pt\wd0}{#2}
{\noindent\hfill
\parbox{\dimexpr #1+\result pt}{\centering\strut#3\strut}%
\hfill\mbox{}\par}
}
\makeatother
\begin{document}
\centerlines{2}{To be or not to be, that is the question}
\centerlines[9pt]{8}{When in the Course of human events, it becomes necessary
for one people to dissolve the political bands which have connected them
with another, and to assume among the powers of the earth, the separate
and equal station to which the Laws of Nature and of Nature's God entitle
them, a decent respect to the opinions of mankind requires that they
should declare the causes which impel them to the separation.}
\end{document}

Here is a slightly different take on it. With this verion, a \parbox
is not used. Rather, \leftskip
nad \rightskip
are employed, and so the result can break across pages. However, each line of the \centerlines
output will be forced to the same width, and hyphenation is now active.
\documentclass{article}
\usepackage[showframe,pass]{geometry}
\usepackage{fp}
\makeatletter
\newcommand\centerlines[3][5pt]{%
\sbox0{#3}%
\FPdiv\result{\strip@pt\wd0}{#2}
\FPdiv\theskip{\strip@pt\dimexpr\linewidth-\result pt-#1\relax}{2}%
{\centering\leftskip\theskip pt\rightskip\theskip pt#3\par}
}
\makeatother
\begin{document}
\centerlines{2}{To be or not to be, that is the question}
\centerlines[1pt]{8}{When in the Course of human events, it becomes necessary
for one people to dissolve the political bands which have connected them
with another, and to assume among the powers of the earth, the separate
and equal station to which the Laws of Nature and of Nature's God entitle
them, a decent respect to the opinions of mankind requires that they
should declare the causes which impel them to the separation.}
Back to normal
\end{document}
