我怎样才能将表格移至页面顶部?

我怎样才能将表格移至页面顶部?

如何调整页面顶部的表格?我想稍微移动顶部的表格。我应该使用一些边距或填充命令来实现这一点吗?

\documentclass[english,a4paper,12pt]{report}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{listings}
\usepackage{changepage}

\begin{document}

\clearpage
\begin{table}[ht]
\begin{adjustwidth}{-3.7cm}{}
\begin{tabular}{|p{.6\textwidth}|p{.75\textwidth}|}
\hline
{\begin{lstlisting}[basicstyle={\scriptsize\ttfamily},
identifierstyle={\color{black}},
tabsize=2,language={Java},
numbersep=8pt,numbers=left,xleftmargin=0.5cm,frame=tlbr,framesep=2pt,framerule=0pt,
morekeywords={class,run}]
class PrintHelloThread ext Thread {
    void run(Dummy x) {
        out.println("Hello world")
    }
}
class X ext ProxifiedObject {
    PrintHelloThread thread
    void main(X x) {
        x.thread := new PrintHelloThread;
        x.thread.start(0);
        x.thread.join(0);
    }
}
\end{lstlisting}}
&
{\begin{lstlisting}[
basicstyle={\scriptsize\ttfamily},
identifierstyle={\color{black}},
tabsize=2,
language={Java},
numbersep=8pt,
numbers=left,
xleftmargin=0.5cm,frame=tlbr,framesep=2pt,framerule=0pt,
morekeywords ={class,run}
]
class PrintHelloThread ext Thread {
    void run(Dummy x) {
        out.println("Hello world")
    }
}
class X ext ProxifiedObject {
    PrintHelloThread thread
    void main(X x) {
        x.thread := new PrintHelloThread;
        x.thread.start(0);
        x.thread.join(0);
    }
}
\end{lstlisting}}
\\
\hline
\end{tabular}
\end{adjustwidth}
\caption{\label{fig:text}text experiment ent experiment experiment}
\end{table}
\end{document}

enter image description here

答案1

检查了我自己的帖子后,我找到了一种将表格移动到页面顶部的方法。

命令空间完全解决了我的问题。

\begin{table}[ht]
\begin{adjustwidth}{-3cm}{}
\vspace{-7.5em}%
.....
\end{table}

答案2

或者注意[ht]后面的\begin{table}t代表顶部(h此处)。因此,如果您只写\begin{table}[t]...和其余部分...表格应该位于页面顶部。

相关内容