使圖形標題更寬

使圖形標題更寬

我有下面的工作範例:

\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}

怎麼樣才能讓標題再長一點呢?換句話說,我希望標題全部位於一行而不是換行

答案1

只需翻轉您的環境即可。使用\centeringinsidefigure將內容置中,然後放置僅有的裡面(我已經為你的lstlistingMWEminipage刪除了一些不必要的包):

在此輸入影像描述

\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}​

相關內容