0

I'm trying to insert a block of text, set at full line width, in the middle of an indented and nested list item. I've asked the general question, though in my case it involves the listings package. What I need is something like this:

\item ....

\begin{fullwidth}
\begin{lstlisting)
blah blah too long for indented width but fits in full column width
\end{lstlisting}
\end{fullwidth}

blah blah blah

\item ...

I have a stopgap solution using the figure envirnoment plus \FloatBlock (from memoir), but I'm not keen.

Any better ideas?

1

The solution comes from the listings package itself: you can use the option resetmargins=true in the lstlisting environment.

I created a few example just for fun. The one you probably want is the 6th.

\documentclass{article}

\usepackage{listings}
\usepackage{fullwidth}% if your really need the fullwidth environment

\begin{document}
    Inside the \verb|itemize| environment:
    \begin{itemize}
        \item example 1

        blah blah too long for indented width but fits in full column width

        \item example 2
        \begin{flushleft}
            blah blah too long for indented width but fits in full column width
        \end{flushleft}

        \item example 3
        \begin{fullwidth}
            blah blah too long for indented width but fits in full column width
        \end{fullwidth}

        \item example 4
        \begin{fullwidth}[skipabove=0pt, skipbelow=0pt]
            blah blah too long for indented width but fits in full column width
        \end{fullwidth}

        \item example 5
\begin{lstlisting}
blah blah too long for indented width but fits in full column width
\end{lstlisting}

        \item example 6 (THIS IS THE ONE)
\begin{lstlisting}[resetmargins=true]
blah blah too long for indented width but fits in full column width
\end{lstlisting}

        \item example 7
        blah blah too long for indented width but fits in full column width
    \end{itemize}

    Outside the \verb|itemize| environment:
\begin{lstlisting}
blah blah too long for indented width but fits in full column width
\end{lstlisting}
\end{document}

Result looks like this: enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.