4

When I put a center environment at the beginning of an item in a list, the item itself becomes indented. How can I fix this?

MWE:

\documentclass{article}

\begin{document}

\emph{\large Enumerate}:
\begin{enumerate}
\item Foo.
\item
  \begin{center}
    Bar.
  \end{center}
\item Baz.
  \begin{center}
    Quux.
  \end{center}
\end{enumerate}

\emph{\large Itemize}:
\begin{itemize}
\item Foo.
\item
  \begin{center}
    Bar.
  \end{center}
\item Baz.
  \begin{center}
    Quux.
  \end{center}
\end{itemize}
\end{document}

enter image description here

2
  • What do you want to fix? Do you want to maintain a left-aligned numbering/bullet and the item in the middle?
    – Werner
    Commented Aug 11, 2016 at 23:41
  • Yes, exactly that.
    – JamesNZ
    Commented Aug 11, 2016 at 23:48

3 Answers 3

4

Use \hfil (see Bar under itemize)

\documentclass{article}

\begin{document}

\emph{\large Enumerate}:
\begin{enumerate}
\item Foo.
\item
  \begin{center}
    Bar.
  \end{center}
\item Baz.
  \begin{center}
    Quux.
  \end{center}
\end{enumerate}

\emph{\large Itemize}:
\begin{itemize}
\item Foo.
\item
{\hfil  Bar.}
\item Baz.
  \begin{center}
    Quux.
  \end{center}
\end{itemize}
\end{document}
1
  • I compiled your code in sharelatex and it still had the same weird indent and the bullet point for "Bar." under Enumerate was off to the left below "Foo." Maybe I missed something...?
    – auden
    Commented Aug 12, 2016 at 0:08
2

When you place the item in a box of width \linewidth, you can manage the alignment much more easily:

enter image description here

\documentclass{article}

\begin{document}

Original:
\begin{enumerate}
  \item Foo.
  \item
    \begin{center}
      Bar.
    \end{center}
  \item Baz.
    \begin{center}
      Quux.
    \end{center}
\end{enumerate}

Updated:
\begin{enumerate}
  \item Foo.
  \item \makebox[\linewidth]{Bar.}
  \item \makebox[0pt][l]{Baz.}%
      \makebox[\linewidth]{Quux.}
\end{enumerate}

\end{document}

By default \makebox[<wd>]{<stuff>} is equivalent to \makebox[<wd>][c]{<stuff>} that centres <stuff> within a box of width <wd>.

3
  • You included a before picture...could you maybe include an after picture?
    – auden
    Commented Aug 11, 2016 at 23:58
  • @heather: The picture includes an "Original" and an "Updated". The "Original" uses the OP's center, while the "Updated" uses \makebox constructions. itemize would work the same as enumerate, so I don't include it.
    – Werner
    Commented Aug 11, 2016 at 23:59
  • I see, sorry. The two seems to have teleported to the left...=)
    – auden
    Commented Aug 12, 2016 at 0:01
2

JPi's answer is good, but I thought I'd add an alternate solution - make it a table.

My code is

\documentclass{article}
\usepackage{graphicx}

\begin{document}

\begin{table}[h]
    \centering
    \resizebox{\columnwidth}{!}{
    \begin{tabular}{l c}
        \textit{Enumerate:} \\
       1. Foo.  &  2. Bar.\\
       \\
        3. Baz. & Quux. \\
        \\
        \textit{Itemize:} \\
        \textbullet Foo. & \textbullet Bar. \\
        \\
        \textbullet Baz. & Quux. \\
    \end{tabular}}
\end{table}

\end{document}

Which gives

enter image description here

I think this solution works just as well as using a list. If you wanted, you could change it from {l c} to {l l} and it'll look neater - the second column will be lined up but still in the middle.

Hope this helps!

2
  • I think you should definitely avoid the table floating environment.
    – Johannes_B
    Commented Aug 12, 2016 at 7:14
  • never use [h] on its own it usually generates a warning fron latex that it is being changed to ht and any option without p increases the chance of the table going to the end of the document. (but as Johannes says, you don't want table here at all.) Commented Aug 12, 2016 at 7:45

You must log in to answer this question.

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