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.

How can I adjust my table on the top of the page? I want to move slightly my table on top. Should I use some margin or padding command in order to that?

\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

share|improve this question
1  
It is at the top: i.stack.imgur.com/ODg90.png If you want it to go up further, you have to reduce the top margin. –  Harish Kumar Mar 31 at 23:33
    
You can move it by little if you use aboveskip=0pt for listings. –  Harish Kumar Mar 31 at 23:39

2 Answers 2

up vote 0 down vote accepted

After examining my own post, I found out a way to move the table on top of the page.

The command vspace simply solves my problem.

\begin{table}[ht]
\begin{adjustwidth}{-3cm}{}
\vspace{-7.5em}%
.....
\end{table}
share|improve this answer

Or notice [ht] after \begin{table}. The t stands for top (h for here). So, if you only write \begin{table}[t]...and the rest... the table should go to the top of the page.

share|improve this answer

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.