7

I would like to place an unindented \fbox inside an enumerate environment.

\begin{enumerate}
    \item Some text.
    \par\fbox{a}
    \item Some more text.
\end{enumerate}

The above code produces:

1. Some text.
   a
2. Some more text.

Is there a way to get the following?

1. Some text.
a
2. Some more text.

Of course I could fiddle around with \hspace{somenegativelength}. However, is there nothing like \reallynoindent?

yo'
  • 51,322
severin
  • 539

2 Answers2

9

You could interrupt and resume your enumerate with the enumitem package, so that the \fbox{a} becomes part of the main body again.

\documentclass{article}
\usepackage{enumitem}


\begin{document}
\noindent{}Text before.
\begin{enumerate}
  \item Some text.
\end{enumerate}
\fbox{a}
\begin{enumerate}[resume]
  \item Some more text
\end{enumerate}
Text after.
\end{document}
mafp
  • 19,096
5

Making it an item on its own is a way to go:

\begin{enumerate}
    \item Some text.
    \item[\fbox{a}]
    \item Some more text.
\end{enumerate} 

To answer your question about \reallynoindent: Process of making a list "indented" is not the same as making a paragraph indented. If you put \the\parindent inside default enumerate, you'll get 0pt. The point here is that the whole left margin is increased by the amount of "indent". You can check that this is true by putting \the\leftmargin in the list, which in my case output soomething like 27.3747pt. If you want to "reallynoindent", you can do the following:

\begin{enumerate}
\item Some text.

{\setlength{\parindent}{-\leftmargin}\fbox{a}} Foo bar

\item Some more text.
\end{enumerate}
yo'
  • 51,322
  • 1
    +1 for the explanation of how margins work inside enumerate. A limitation of your solution is that it only works if \box{a} is quite short. The custom label expands to the left. – severin Feb 15 '13 at 09:00