TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Possible Duplicate:
How can I ensure that a listing is not going to be split?

My listing goes at the bottom of a page and fits good. But the header is separated and moved to another page. Is it possible to keep them together?

share|improve this question

marked as duplicate by lockstep, Kurt, Stefan Kottwitz Jan 24 '13 at 14:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Welcome to TeX.sx! Please add a Minimal Working Example (MWE) the provides a complete document including package dependencies that reproduces the problem your describe. This will make it easier to provide an answer or help. – Peter Jansson Jan 24 '13 at 13:29
I believe, that this question doesn't require MWE, since I clearly explained what's the problem – damluar Jan 24 '13 at 13:43
Try putting float as the option for your listing. – Harish Kumar Jan 24 '13 at 13:47
@damluar: I think it would be helpful. For example which list you are using. – Jana Jan 24 '13 at 13:50
@HarishKumar Move it to answers. It helped. – damluar Jan 24 '13 at 13:54
up vote 2 down vote accepted

Using the float option to your lstinputlisting will make your code to float and floats never break across the pages. Hence the solution will be to use

\lstinputlisting[float,caption=My code here]{your file that has code}
share|improve this answer

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