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.

I have made a big table in L-form, and I was wondering if there is any way in Latex to write at the ege of the L where there is nothing in the table. See the following illustration:

enter image description here

So the idea is to save space in continuing the regular document when there is space left in a flating table. I know it usually looks bad, but in case of a huge (rather high) table it might not. I hope you got the idea.

\documentclass{scrreprt}

\usepackage{booktabs}
\usepackage{amsmath}

\begin{document}


\begin{table}[tbp]
\centering
\caption{This is a huge table. Guess what the magic number is...} 
\label{magic numbers}
{\small
\begin{tabular}{lcccccccc}
\toprule 
& \multicolumn{1}{c}{This} & \multicolumn{1}{c}{is} & 
\multicolumn{1}{c}{is} & \multicolumn{1}{c}{This} \\
\midrule \multicolumn{4}{l}{Magic numbers} \\ \multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42\\ 
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42& -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42  \\ 
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 & -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\ 
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 &&& \\ 
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\ 
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 &&& \\ 
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 &&& \\ 
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\ 
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 &&& \\ 
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 &&& \\ 
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\ 
\end{tabular}
}
\end{table}


\end{document}
share|improve this question
1  
Unrelated note: you may want to use math mode for all the numbers, as it stands the 'minus signs' are hyphens. \begin{tabular}{*{9}{>{$}c<{$}}} will create 9 centered columns where each cell will be in math mode (I borrowed from Werner's answer and modified it). You'll need \multicolumn for text cells. Requires \usepackage{array}. –  Torbjørn T. Jan 5 at 16:39
add comment

2 Answers

up vote 9 down vote accepted

In the example below I've set the text inside a paragraph box. The \parbox is aligned/anchored at the bottom, has a height of 0pt (so as to not influence other lines inside the tabular, and starts from the bottom moving upwards. The width is calculated to be exactly 3 columns wide (3 entries of -54.42 stored in box 1), plus the remaining \tabcolseps of between the columns:

enter image description here

\documentclass{scrreprt}% http://ctan.org/pkg/koma-script

\usepackage{booktabs}% http://ctan.org/pkg/booktabs

\begin{document}

\begin{table}[tbp]
  \centering
  \caption{This is a huge table. Guess what the magic number is...} 
  \label{ovbdiffx3to5}
  \setbox1=\hbox{-54.42}
  \small\begin{tabular}{*{9}{c}}
    \toprule 
    & This & is & is & This \\
    \midrule \multicolumn{4}{l}{Magic numbers} \\
    A & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42\\ 
    B & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\ 
    C & 54.42 & 54.42  & 54.42  & 54.42& -54.42& -54.42& -54.42 \\ 
    $D$ & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\ 
    A & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42  \\ 
    B & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\ 
    C & 54.42 & 54.42  & 54.42  & 54.42 & -54.42& -54.42& -54.42 \\ 
    $D$ & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\ 
    A & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\ 
    B & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\ 
    C & 54.42 & 54.42  & 54.42  & 54.42 &&& \\ 
    $D$ & -54.42 & -54.42 & -54.42 & -54.42 &&&\\ 
    B & -54.42 & -54.42  & -54.42  & -54.42 &&& \\ 
    C & 54.42 & 54.42  & 54.42  & 54.42 &&& \\ 
    $D$ & -54.42 & -54.42 & -54.42 & -54.42 &&&\\ 
    B & -54.42 & -54.42  & -54.42  & -54.42 &&& \\ 
    C & 54.42 & 54.42  & 54.42  & 54.42 &&& \\ 
    $D$ & -54.42 & -54.42 & -54.42 & -54.42 &&&
    \multicolumn{1}{r}{\relax\llap{\parbox[b][0pt][b]{\dimexpr3\wd1+3\tabcolsep}{%
      Here is some text. It is enough to span multiple lines, filling in from
      the bottom upwards.%
    }}}
  \end{tabular}
\end{table}

\end{document}

If the contents of your tabular contains numbers, use math mode to set the numbers (as in $-54.42$) since it will provide the appropriate spacing of the unary operator -.

share|improve this answer
    
nice solution, thanks! –  TomM Jan 5 at 12:41
add comment

This is a different approach which uses Werner's method to calculate the appropriate width. (At least, I think it does though I don't understand TeX's dimensions well enough to be certain.)

\documentclass{scrreprt}

\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{multirow}

\begin{document}


\begin{table}[tbp]
\centering
\caption{This is a huge table. Guess what the magic number is...}
\label{ovbdiffx3to5}
\setbox1=\hbox{-54.42}
\newlength{\mycols}
\setlength{\mycols}{\dimexpr3\wd1+3\tabcolsep}
{\small
\begin{tabular}{lcccccccc}
\toprule
& \multicolumn{1}{c}{This} & \multicolumn{1}{c}{is} &
\multicolumn{1}{c}{is} & \multicolumn{1}{c}{This} \\
\midrule \multicolumn{4}{l}{Magic numbers} \\ \multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42\\
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42  \\
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42& -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{A} & 54.42 & 54.42 & 54.42 & 54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 & -54.42& -54.42& -54.42 \\
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 & %
  \multicolumn{3}{p{\mycols}}{\multirow{8}{\mycols}{Here is some text. It is enough to span multiple lines, filling in from the centre upwards and downwards.}}\\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 &&& \\
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&&\\
\multicolumn{1}{l}{B} & -54.42 & -54.42  & -54.42  & -54.42 &&& \\
\multicolumn{1}{l}{C} & 54.42 & 54.42  & 54.42  & 54.42 &&& \\
\multicolumn{1}{l}{$D$} & -54.42 & -54.42 & -54.42 & -54.42 &&& \\
\end{tabular}
}
\end{table}


\end{document}

Using multirow to place text spanning 3 columns within a table

I think this might look a little less odd if the text used space to the right of the table as well so it did not look part of the table. However, I can't get that to work without giving up booktabs. I also wondered about using \cmidrule{6-8} after the preceding line but that introduces additional vertical spacing so it messes up the rest of the table.

share|improve this answer
    
also thanks a lot for your entry. You are correct with the space to the right, but in this case the table pretty much fills the whole width of a page, so the solution is fine! –  TomM Jan 5 at 12:43
add comment

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.