我有以下工作样本:
\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
只需翻转您的环境即可。使用\centering
insidefigure
将内容置于中心,然后放置仅有的里面(我已经为你的lstlisting
MWEminipage
删除了一些不必要的包):
\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}