居中文本,左对齐

居中文本,左对齐

这可能是一个相当琐碎的问题,但我没有找到解决它的明显方法。我想将一段文本居中,但我希望居中的文本左对齐。

所以我想要:

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

但是 line1、line2 和 line3 左对齐,但仍居中。

答案1

您可以使用表格将文本左对齐,并且本身位于文本中央。这可能看起来像这样:

\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}

输出如下所示:

在此处输入图片描述

答案2

使用minipage相当简单,并且在这种情况下会很有帮助。

\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}

答案3

我将在中心tabulary环境中执行此操作:

\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}

输出

相关内容