14

This is probably a rather trivial question, but I don't see an obvious way on how to solve it. I want to center a piece of text, but i want to have the centered text be aligned left.

So I would like:

\begin{center}
line1
line2
line3
\end{center}

but where line1, line2 and line3 are aligned left, but still are centered.

4
  • Do you mean you don't want to use the whole width of a line? ␣␣␣␣␣text␣␣␣␣␣
    – Johannes_B
    Commented Dec 12, 2013 at 9:51
  • Do you mean the whole body is aligned left but individual lines are centered among themselves? It is not very clear what you are asking for. Do you think you can show a simulated output?
    – Masroor
    Commented Dec 12, 2013 at 9:51
  • Sorry, what I mean is: I want to center the block of lines, but I want align the lines to the left of that centered block (i.e. I want to let all the lines start at the same point).
    – MaVe
    Commented Dec 12, 2013 at 9:54
  • 4
    Well then use a minipage \begin{center}\begin{minipage}{0.5\linewidth}<content>\end{minipage}\end{center}
    – Johannes_B
    Commented Dec 12, 2013 at 9:57

3 Answers 3

13

You could use a tabular which aligns the text to the left and is itself centered in the text. This could look like this:

\documentclass{scrreprt}
\usepackage{lipsum}
\begin{document}
 \lipsum[1]
 \begin{center}
  \begin{tabular}{l}
    This is line 1 with some text. \\
    This is line 2 with a slightly different text \\
    Line 3 is completely different and also a bit longer. \\
  \end{tabular}
 \end{center}
\end{document}

The output looks like this:

enter image description here

3
  • 1
    This solution is fine, only when the lines are rather short. If one of the lines is v-e-r-y long, this it won't do the job.
    – Dror
    Commented Dec 12, 2013 at 13:22
  • Thats right. You could use a table with fixed width, but these are centered, if I remember correct.
    – Chris
    Commented Dec 12, 2013 at 13:47
  • Define a new coloumntype with the ragged2e package and the definition of \newcolumntype{A}{>{\RaggedRight}p{1\textwidth}} and you have a defined width with left aligned text. But seriously, doing it with a minipage and maybe \hfill{} is better.
    – Ulle
    Commented Dec 12, 2013 at 14:35
7

Using a minipage is rather simple and can be helpful in this case.

\documentclass{scrreprt}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\begin{center}
  \begin{minipage}{0.5\linewidth}
    \lipsum[2]

    \begin{itemize}
    \item This is line 1 with some text.
    \item This is line 2 with a slightly different text
    \item Line 3 is completely different and also a bit longer.
    \item And what about really really really really really
      really really really really really really really really really
      really lines?
    \end{itemize}
  \end{minipage}
\end{center}
\end{document}
2
  • Why the itemize environment? Works without it and a parskip too and i guess that is what he searched for.
    – Ulle
    Commented Dec 12, 2013 at 14:31
  • @JohannesO: Just for the sake of demonstration. It seemed like the OP referred to a list which is centered and indented. You could tweak the itemize environment as you want.
    – Dror
    Commented Dec 12, 2013 at 15:49
1

I would do this with a centered tabulary environment:

\documentclass{article}
\usepackage{tabulary}
\begin{document}
  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
  tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
  quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
  consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
  cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
  proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

  \begin{center}
    \begin{tabulary}{\linewidth}{@{}L@{}}
      This is line 1 with some text. \\
      This is line 2 with a slightly different text. \\
      Line 3 is completely different and also a bit longer.
    \end{tabulary}
  \end{center}
\end{document}

Output

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .