Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In TeX, one can center a single line of text with \centerline. How would one implement a center justification environment for a single long line of text in plain TeX without the addition of any packages. That is, the first line of TeX should justify to the center. Any wrapping text should also justify to the center.

share|improve this question
    
Welcome to TeX.sx! –  Marco Daniel Aug 29 '12 at 9:36
    
Thank you, egreg. This answers my question. –  C j Aug 29 '12 at 11:56

1 Answer 1

up vote 20 down vote accepted
\def\startcenter{%
  \par
  \begingroup
  \leftskip=0pt plus 1fil
  \rightskip=\leftskip
  \parindent=0pt
  \parfillskip=0pt
}
\def\stopcenter{%
  \par
  \endgroup
}
\long\def\centerpars#1{\startcenter#1\stopcenter}

You can now choose between

\startcenter
Some text to be centered
\stopcenter

and

\centerpars{Some text to be centered}

An empty line in the text will end the line.

share|improve this answer
    
Thank you, egreg. This answers my question. –  C j Aug 29 '12 at 11:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.