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.

I have the working sample below:

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage[T1]{fontenc}
\usepackage{amsmath, graphicx, tikz, enumerate, amssymb, pgf}

\usepackage{setspace}
\usepackage{pgfplots}
\usepackage{slashbox}
\usepackage{bchart}
\usepackage{float}
\restylefloat{table}
\usepackage{caption}

\usepackage{listings}
\usepackage{color}
\usepackage{textcomp}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{
%frame=tb,
  language=C++,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  %basicstyle={\small\ttfamily},
  basicstyle=\ttfamily\footnotesize\bfseries,
  numbers=none,
  numberstyle=\tiny\color{gray},
  %keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  %stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}



\begin{document}

\begin{center}
\begin{minipage}{.45\linewidth}
\begin{figure}[H]
\begin{lstlisting}
# Query 0 -- Type: Truth, Instructions: 0
array stat_1[144] : w32 -> w8 = symbolic
(query [(Eq false
            (Eq 0
                N0:(ReadLSB w64 56 stat_1)))
        (Eq false
            (Eq 0 N1:(URem w64 8 N0)))
        (Eq false
            (Eq 0 (URem w64 N0 N1)))]
       (Eq false
           (Eq 0 N2:(Read w8 56 stat_1))))
#   OK -- Elapsed: 39.8942
#   Is Valid: true


\end{lstlisting}
\caption{A query instance logged by the PC-Logging Solver}
\end{figure}
\end{minipage}

\end{center}

\end{document}

How can I make the caption be longer ? I other words, I want the caption all be on a single line and not do a line break

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Just flip around your environments. Use \centering inside figure to centre the content, and put only the lstlisting inside a minipage (I've removed some of the unnecessary packages for your MWE):

enter image description here

\documentclass[a4paper,11pt,twoside]{report}
\usepackage[left=2.5cm,right=2cm,top=2cm,bottom=2cm]{geometry}% http://ctan.org/pkg/geometry

\usepackage{listings}% http://ctan.org/pkg/listings
\usepackage{color}% http://ctan.org/pkg/color
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{
%frame=tb,
  language=C++,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  %basicstyle={\small\ttfamily},
  basicstyle=\ttfamily\footnotesize\bfseries,
  numbers=none,
  numberstyle=\tiny\color{gray},
  %keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  %stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}

\begin{document}

\begin{figure}
\centering
\begin{minipage}{.45\linewidth}
\begin{lstlisting}
# Query 0 -- Type: Truth, Instructions: 0
array stat_1[144] : w32 -> w8 = symbolic
(query [(Eq false
            (Eq 0
                N0:(ReadLSB w64 56 stat_1)))
        (Eq false
            (Eq 0 N1:(URem w64 8 N0)))
        (Eq false
            (Eq 0 (URem w64 N0 N1)))]
       (Eq false
           (Eq 0 N2:(Read w8 56 stat_1))))
#   OK -- Elapsed: 39.8942
#   Is Valid: true
\end{lstlisting}
\end{minipage}
\caption{A query instance logged by the PC-Logging Solver}
\end{figure}

\end{document}​
share|improve this answer
    
Nice worked perfectly. Thanks so much! –  Cemre Aug 24 '12 at 16:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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