# Insert a paragraph into a list that uses the whole text width

I want to insert a paragraph or possibly even a box with a background color into a list that uses the whole \textwidth. Something like this:

1st item
a subitem 1
b subitem 2

2nd item
a subitee

\begin{use the full width}
[ Here the text should use the full text width ignoring the list indent]
\end{use the full width}
b subitem
3rd item


The list is a normal enumerate.

-

## migrated from stackoverflow.comMay 29 '11 at 15:14

This question came from our site for professional and enthusiast programmers.

– Martin Scharrer May 29 '11 at 16:29

If you want a oneliner a very simple command is

\makeatletter
\newcommand{\shiftleft}{\hspace*{-\@totalleftmargin}}
\makeatother


If you want an environment that takes up the whole width and breaks accross pages define a list

\makeatletter
\newenvironment{fullwidth}
{\par
\setlength{\@totalleftmargin}{0pt}%
\setlength{\linewidth}{\hsize}%
\list{}{\setlength{\leftmargin}{0pt}}
\item\relax}
{\endlist}
\makeatother


Look at example below:

\documentclass{article}
\usepackage{calc}
\usepackage{color}

\makeatletter
\newcommand{\shiftleft}{\hspace*{-\@totalleftmargin}}
\newenvironment{fullwidth}
{\par
\setlength{\@totalleftmargin}{0pt}%
\setlength{\linewidth}{\hsize}%
\list{}{\setlength{\leftmargin}{0pt}}
\item\relax}
{\endlist}
%% colored minipage (do not break across pages!)
\newsavebox{\cminibox}
\newlength{\cminilength}
\newenvironment{cminipage}[1][\linewidth]
{\setlength{\cminilength}{#1-2\fboxsep}
\begin{lrbox}{\cminibox}%
\begin{minipage}{\cminilength}}%
{\end{minipage}\end{lrbox}%
\makeatother
\begin{document}
\noindent\hrulefill\par
\begin{enumerate}
\item Item
\begin{enumerate}
\item subitem 1

\item subitem 2
\end{enumerate}

\item Item
\begin{enumerate}
\item subitem 1

\begin{fullwidth}
\begin{cminipage}
This is a long sentence to test if it fills the
whole line again and again and again.
This is a long sentence to test if it fills the
whole line again and again and again.
\end{cminipage}
\end{fullwidth}

\item subitem 2
\end{enumerate}
\item Item
\end{enumerate}
\noindent\hrulefill\par
\end{document}


-

You can use the \rlap command; in the following example I used this idea and the shaded environment form the framed package to define a command to achieve what you want:

\documentclass{article}
\usepackage{xcolor}
\usepackage{framed}

\newcommand\MyInd[1]{%

\begin{document}

\begin{enumerate}
\item 1st item
\begin{enumerate}
\item  a subitem 1
\MyInd{Here the text is using the full text width ignoring the list indent.}
\item b subitem 2
\end{enumerate}
\item 2nd item
\begin{enumerate}
\item  a subitem 1
\par\rlap{Here the text is using the full text width ignoring the list indent.}
\item b subitem 2
\end{enumerate}
\item 3rd item
\end{enumerate}

\end{document}


EDIT: the result:

-
Interesting. Why isn't the \rlap code indented? – Martin Scharrer May 29 '11 at 17:29
@Martin: \rlap is a red herring here. \rlap is basically \hbox to 0pt{#1\hss}. The important thing here is that it's just an \hbox in vertical mode and TeX does the usual thing. – TH. May 29 '11 at 18:53

Just quit enumerate at the right place and use enumitem's [resume] option:

\documentclass{article}
\usepackage{lipsum}
\usepackage{enumitem}
\begin{document}

\begin{enumerate}
\item \lipsum*[1]
\end{enumerate}
\lipsum*[2]

\begin{enumerate}[resume]
\item \lipsum*[3]
\end{enumerate}

\end{document}


If you want no indentation, either don't leave a blank line after \end{enumerate} (which is what I have done), or use \noindent.

-