Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Possible Duplicate:
Force figure placement in text
How to influence the position of float environments like figure and table in LaTeX?

How can I force LaTeX to insert a figure exactly where I want.

Here's the code I use:

\lstset{framexleftmargin=0mm, frame=shadowbox, rulesepcolor=\color{black},basicstyle=\ttfamily\small,breaklines,
columns=fullflexible}
\begin{figure} [htbp!]
\begin{lstlisting}
root@bt:~# nmap -O www.we****t***.com

Starting Nmap 6.01 ( http://nmap.org ) at 2012-12-21 15:38 CET
Nmap scan report for www.we****t***.com (217.6*.***.**)
Host is up (0.0087s latency).
Not shown: 990 filtered ports
PORT     STATE  SERVICE
21/tcp   open   ftp
22/tcp   open   ssh
53/tcp   open   domain
80/tcp   open   http
110/tcp  open   pop3
143/tcp  open   imap
443/tcp  open   https
587/tcp  closed submission
3306/tcp open   mysql
Device type: general purpose
Running (JUST GUESSING): Linux 2.6.x (90%)

Aggressive OS guesses: Linux 2.6.22 (90%),
OpenWrt Kamikaze 7.09 (Linux 2.6.27) (89%),
Linux 2.6.18 - 2.6.24 (89%),
Linux 2.6.23 (86%)

No exact OS matches for host (test conditions non-ideal).

OS detection performed.
Please report any incorrect results at http://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 79.16 seconds
\end{lstlisting}
\caption{Nmap -O}
\end{figure}

LaTeX places the figure on another page which is astonishing since it makes the whole work ugly.

Here's the preamble I use:

\documentclass[a4paper,singleside,11pt]{report}
\usepackage{ia_urb_thesis}
\usepackage[italian]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{color}
%\usepackage {listingsutf8}
%\usepackage{tikz}
\usepackage[thinlines]{easytable}
\usepackage{upquote}
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{listings}
%\lstset{language=PHP}
\usepackage{url}
%\usepackage[pdftex]{graphicx}
\usepackage{amsmath}% http://ctan.org/pkg/amsmath
%\usepackage{epsfig}
%\usepackage{textcomp}

\begin{document}

\titolo{...Injection ...
\\[5mm]}
\candidato{xxx}
\relatore{Chiar.mo xxxx}
\annoaccademico{2011-2012}

\copertinatesi

\dedica{Ai miei genitori}
\indice
\indicefigure
\indicetabelle
\iniziatesto

\include{cap_1}
\include{cap_2}
\include{cap_3}
\include{cap_4}

\appendix
\include{app_a}
\include{biblio}

\ringraziamenti
Vorrei ringraziare ...

\end{document}
share|improve this question

marked as duplicate by tohecz, Martin Schröder, Kurt, Werner, lockstep Jan 2 '13 at 0:08

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.

2  
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Benedikt Bauer Jan 1 '13 at 22:54
1  
Could Frank Mittelbach's answer to this question be of any help? –  Marc van Dongen Jan 1 '13 at 22:56
2  
See also Force figure placement in text (duplicate, perhaps) –  Torbjørn T. Jan 1 '13 at 23:03
5  
Your profile shows "14% accept rate". I'm sure that you have some good solutions to your questions and you should consider accepting the answers, giving the answerers the site reputation. This would motivate people to be more approaching and willing to help. –  tohecz Jan 1 '13 at 23:08
2  
Not exactly, read Werner's comment, and/or search the listings documentation for the word "caption". –  Torbjørn T. Jan 1 '13 at 23:15
show 4 more comments

Browse other questions tagged or ask your own question.