[Tex/LaTex] Centered but left-aligned paragraph

horizontal alignmentindentationparagraphs

I want to have a paragraph, that is centered but in itself left-aligned. Does somebody of you know how to achieve this?

(I have text in a paragraph, on each line the text is shorter than the width, but if I just put "flushleft" around it comes to much to the left margin of the page)

Best Answer

It is possible to create a stand-alone environment that can do it all in one - both centering and and internally align elements:

\documentclass{article}
\usepackage{lipsum}% http://ctan.org/pkg/lipsum
\usepackage{environ}% http://ctan.org/pkg/environ
\NewEnviron​{centerbox}[1][\linewidth]{% \begin{centerbox}[..] ... \end{centerbox}
  \noindent\makebox[\linewidth][c]{%
    \begin{minipage}{#1}%
      \raggedright% Minipage alignment
      \BODY% Typeset body/contents
    \end{minipage}%
  }
}%
\begin{document}
\lipsum[1]

\begin{centerbox}[0.5\linewidth]
  \lipsum[2]
\end{centerbox}

\lipsum[3]
\end{document}

​ The above code produces the centerbox environment (using the environ package). An optional argument specifies the width of the centered box, which defaults to \linewidth.

Centered box

Related Question