# Ignore whitespaces inside of a table

I would like to eliminate blank parts of a table. Here is my LaTeX snippet:

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

\begin{document}

\clearpage
\begin{table}[ht]
\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}]
void run(Dummy x) {
out.println("Hello world")
}
}
class X ext ProxifiedObject {
void main(X x) {
}
}
\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}
]
void run(Dummy x) {
out.println("Hello world")
}
}
class X ext ProxifiedObject {
void main(X x) {
}
}
\end{lstlisting}}
\\
\hline
\end{tabular}
\caption{\label{fig:text}text experiment ent experiment experiment}
\end{table}
\end{document}


-
You can reduce the column size in {|p{.6\textwidth}|p{.75\textwidth}|} Is that what you want? –  Harish Kumar Mar 31 at 23:36
The table only has so much white space as you specified the second column to be very wide |p{.6\textwidth}|p{.75\textwidth}|} –  David Carlisle Mar 31 at 23:36
what if I have a large code snippet and need to set textwidth as .8? –  Hakan Mar 31 at 23:50
If your text is wider, how can you hope to miss out the space at the end of the (shorter) lines? –  Joseph Wright Apr 1 at 10:37

In order to refine the whitespace of the table, I have found a quick way to do that. First inside of the table there are two listings so that if the following commands aboveskip,belowskip are used in these listings' properties, below and above empty spaces are gone.

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

\begin{document}

\clearpage
\begin{table}[ht]
\begin{tabular}{|p{.6\textwidth}|p{.75\textwidth}|}
\hline
{\begin{lstlisting}[basicstyle={\scriptsize\ttfamily},aboveskip=-8pt,belowskip=-10pt,
identifierstyle={\color{black}},
tabsize=2,language={Java},
numbersep=8pt,numbers=left,xleftmargin=0.5cm,frame=tlbr,framesep=2pt,framerule=0pt,
morekeywords={class,run}]
void run(Dummy x) {
out.println("Hello world")
}
}
class X ext ProxifiedObject {
void main(X x) {
}
}
\end{lstlisting}}
&
{\begin{lstlisting}[
basicstyle={\scriptsize\ttfamily},aboveskip=-8pt,belowskip=-10pt,
identifierstyle={\color{black}},
tabsize=2,
language={Java},
numbersep=8pt,
numbers=left,
xleftmargin=0.5cm,frame=tlbr,framesep=2pt,framerule=0pt,
morekeywords ={class,run}
]
void run(Dummy x) {
out.println("Hello world")
}
}
class X ext ProxifiedObject {
void main(X x) {
}
}
\end{lstlisting}}
\\
\hline
\end{tabular}
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.9782271385192871, "perplexity": 11227.657449674012}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2014-23/segments/1406510273874.36/warc/CC-MAIN-20140728011753-00055-ip-10-146-231-18.ec2.internal.warc.gz"}