有人能从以下 LaTeX 片段中看出为什么页面的格式如下图所示吗?出于某种原因,所有内容都垂直居中。
\section{Another way to double-space a file}
\begin{lstlisting}
awk 'BEGIN { ORS="\n\n" }; 1'
\end{lstlisting}
\bb{BEGIN} is a special kind of pattern which is not tested against the input.
It is executed before any input is read. This one-liner double-spaces the file
by setting the \bb{ORS} variable to two newlines. As I mentioned previously,
statement "\bb1" gets translated to "\bb{\{ print \}}", and every print statement
gets terminated with the value of \bb{ORS} variable.
\pagebreak
我正在做任何奇特的事情,我的文件声明如下所示:
\usepackage{amsmath} %Never write a paper without using amsmath for its many new commands
\usepackage{amssymb} %Some extra symbols
\usepackage{makeidx} %If you want to generate an index, automatically
\usepackage{graphicx} %If you want to include postscript graphics
\usepackage{listings}
\usepackage{xcolor}
\usepackage{textcomp}
\begin{document}
\newcommand{\bb}[1]{\textbf{#1}}
\definecolor{codebg}{HTML}{EEEEEE}
\definecolor{codeframe}{HTML}{CCCCCC}
\lstset{language=Awk}
\lstset{backgroundcolor=\color{codebg}}
\lstset{frame=single}
\lstset{framesep=10pt}
\lstset{rulecolor=\color{codeframe}}
\lstset{upquote=true}
\lstset{emph={awk}, emphstyle=\textbf}
答案1
这是因为你使用了\pagebreak
。所以 LaTeX 会将文本分散到整个页面上。如果你想避免这种情况,你需要使用\newpage
。