1

Quite similar to this question but not exact.

I am writing a thesis, and I would like to create a table that holds information in a tree shape. I was able to fit the table within the page, but I would like it to be on the same margins that the text have at that page. Look in the following picture how is my table looks like:

enter image description here

The code that I have written to create it is the following:

\begin{table}[H]
\centering
\begin{tabular}{|l|l|l|l|}
\hline
\multicolumn{1}{|c|}{Premise 1} & \multicolumn{1}{c|}{Premise 2} & \multicolumn{1}{c|}{=\textgreater} & \multicolumn{1}{c|}{hypothesis} \\ \hline
\texttt{\small [are:VX [?Y:NN [both:DT]} & \texttt{\small [?Y:NN [?X:JJ]} & &  \texttt{\small [are:VX [?Y:NN [both:DT]} \\
\hspace*{7.4em}\texttt{\small [?X:JJ]]} & \hspace*{3.5em}\texttt{\small [are:VX [who:WP]} & $\Rightarrow$  & \hspace*{7.4em}\texttt{\small [?X:JJ]]} \\
\hspace*{3.8em}\texttt{\small [?Z:JJ]]} & \hspace*{7.6em}\texttt{\small [?Z:JJ]} &  & \hspace*{3.8em}\texttt{\small [?A:JJ]]} \\
& \hspace*{7.2em}\texttt{\small [are:VX[?A:JJ]]]]} &   & \\ \hline
\end{tabular}
\caption{The dependency tree for a multi-premise FraCaS rule}
\label{showDTreeFraCaS}
\end{table}

Any clues?

cgnieder
  • 66,645
lol745
  • 173

2 Answers2

2

You can simply shrink a little bit your table so that it fits to the scale that you need. Since you've already used \centering, you should not be worried about the proportional position of the table in the page. It would be centered automatically.

Here is my solution for you:

\begin{table}[H]
\centering
\scalebox{.8}{
\begin{tabular}{|l|l|l|l|}
\hline
\multicolumn{1}{|c|}{Premise 1} & \multicolumn{1}{c|}{Premise 2} & \multicolumn{1}{c|}{=\textgreater} & \multicolumn{1}{c|}{hypothesis} \\ \hline
\texttt{\small [are:VX [?Y:NN [both:DT]} & \texttt{\small [?Y:NN [?X:JJ]} & &  \texttt{\small [are:VX [?Y:NN [both:DT]} \\
\hspace*{7.4em}\texttt{\small [?X:JJ]]} & \hspace*{3.5em}\texttt{\small [are:VX [who:WP]} & $\Rightarrow$  & \hspace*{7.4em}\texttt{\small [?X:JJ]]} \\
\hspace*{3.8em}\texttt{\small [?Z:JJ]]} & \hspace*{7.6em}\texttt{\small [?Z:JJ]} &  & \hspace*{3.8em}\texttt{\small [?A:JJ]]} \\
& \hspace*{7.2em}\texttt{\small [are:VX[?A:JJ]]]]} &   & \\ \hline
\end{tabular}
}
\caption{The dependency tree for a multi-premise FraCaS rule}
\label{showDTreeFraCaS}
\end{table}

Which yields the following table:

enter image description here

\scalebox{.8}{} helps you shrink your environment to the size you want.

Mensch
  • 65,388
  • Advice to perform linear shrinking (via a \scalebox directive) is of rather questionable value. At the very least, if you give such advice, you should also mention some of its severe drawbacks, such as running the risk of making the table undecipherable because the font is effectively too small. In short, linear shrinking should be contemplated only as a last-resort, desperate measure, not as the first step. – Mico Aug 26 '17 at 05:47
2

To assure that the tabular material fits inside the width of the text block, I suggest you use a tabularx environment and change the \small directives to \footnotesize. With these modifications in place, the only manual adjustment was to change the indentation amount for the final line from 7.2em to 3.7em.

enter image description here

\documentclass{article}
\usepackage{tabularx}
\begin{document}

\begin{table}
\setlength\extrarowheight{1pt}
\footnotesize
\setlength\tabcolsep{3pt} % default: 6pt
\begin{tabularx}{\textwidth}{|X|X|c|X|}
\hline
\multicolumn{1}{|c|}{Premise 1} & 
\multicolumn{1}{c|}{Premise 2} & 
$\Rightarrow$ & 
\multicolumn{1}{c|}{Hypothesis} \\ 
\hline
\texttt{[are:VX [?Y:NN [both:DT]} & 
\texttt{[?Y:NN [?X:JJ]} & &  
\texttt{[are:VX [?Y:NN [both:DT]} \\
\hspace*{7.4em}\texttt{[?X:JJ]]} & 
\hspace*{2.9em}\texttt{[are:VX [who:WP]} & 
$\Rightarrow$  & 
\hspace*{7.4em}\texttt{[?X:JJ]]} \\
\hspace*{3.4em}\texttt{[?Z:JJ]]} & 
\hspace*{7.6em}\texttt{[?Z:JJ]} & & 
\hspace*{3.8em}\texttt{[?A:JJ]]} \\
& 
\hspace*{3.7em}\texttt{[are:VX[?A:JJ]]]]} & & \\ 
\hline
\end{tabularx}
\caption{The dependency tree for a multi-premise FraCaS rule}
\label{showDTreeFraCaS}

\end{table}
\end{document}
Mico
  • 506,678