# Linebreak after \lstinputlisting

Is there any way for me to insert a linebreak after a \lstinputlisting? At the moment text proceeding the code in the lstinputlisting follows directly after but I'd prefer to have a linebreak but can't seem to put it in.

This is what it looks like:

With this code:

\lstinputlisting{newtonsMethod.m}

The derivative function implements the central difference method. The simple implementation is shown below.


This doesn't compile if I put \\ after the \lstinputlisting.

I can't answer my own question cause I'm too new to the site but I managed to figure it out:

Got what I was after by putting \ after the lstinputlisting, like so.

\lstinputlisting{newtonsMethod.m}\

The derivative function implements the central difference method. The simple implementation is shown below.

-
What do you mean with "a linebreak"? Do you want to increase the vertical space between the bottom of the listing and the first line of the following text? –  Gonzalo Medina Aug 28 '12 at 0:37

\lstinputlisting automatically ends the paragraph at the end. It seems like you're after a bigger skip below this, which you can do in multiple ways:

1. Insert a vertical skip (something like \smallskip, \medskip or \bigskip):

\lstinputlisting{newtonMethod.m}
\bigskip
The derivative function ...

2. Insert vertical space using \vspace{<len>} where <len> is any TeX length:

\lstinputlisting{newtonMethod.m}
\vspace{\baselineskip}
The derivative function ...

3. Use the key belowskip (default set to \medskipamount):

\lstinputlisting[belowskip=40pt]{newtonMethod.m}
The derivarive function ...

-
Method 3 should is built into the listings package and, thus, should be considered as the recommended way. By putting something like \lstset{belowskip=2ex} into the preamble, the spacing below all listings can easily be defined (and changed) consistently. –  Daniel Aug 28 '12 at 6:21