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 several dimensions to put in a table in LaTeX, these are actually results of an experiment. I am not sure what is the best way to do it in LaTeX. Here is a snapshot of one of the possibilities:

enter image description here

What is the syntax of obtaining such a table or if there is a better way to present tables with multi dimensions.

share|improve this question
2  
Can you please post what you have tried so far? If you are not already doing so you should consider using the booktabs package. –  Peter Grill Feb 15 '13 at 5:27
2  
have you seen the questions tagged with tables –  cmhughes Feb 15 '13 at 5:29
    
Take a look to this guide –  zunbeltz Feb 15 '13 at 8:49
add comment

2 Answers

You should load the booktabs package and siunitx; the former provides nice rules for tables, the latter is essential for typesetting correctly quantities with their unit of measure and numeric tabular data.

\documentclass{article}
\usepackage{booktabs} % for better looking tables
\usepackage{siunitx}  % for units of measure and data in tables

\begin{document}
\begin{tabular}{
 l % left aligned column
 l % left aligned column
 *{3}{S[table-format=4.0]} % three columns with numeric data       
}
\toprule
&&\textbf{Backward} & \textbf{Forward} & \textbf{Bidirectional}\\
\midrule
atis  & Training &  345 & 235 &  345\\
      & Test     &  356 & 252 &  345\\
brown & Training &  465 & 345 &  346\\
      & Test     &  456 & 342 &  253\\
wsj   & Training &  345 & 235 &  254\\
      & Test     & 4336 & 634 & 3434\\
\bottomrule
\end{tabular}
\end{document}

I used 4.0 as the format because the numbers have four digits in the integral part and no decimal part. Of course you can specify as many columns as you wish, the *{3}{...} shortcut avoids multiple specifications.

The headers for the numeric columns are automatically centered.

You'll probably insert the tabular environment in a table float; there's plenty of examples in the site.

enter image description here

share|improve this answer
add comment

I think the syntax might be straight forward, but the layout of your columns should highly depend on what your trying to explain/show/tell. Just straight taking your tabular and putting it into LaTeX using booktabs for style and floatrow to center the tabular and putting the caption above using the code

\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,floatrow}

%center tables
\floatsetup[table]{objectset=centering,capposition=top}

\begin{document}
    For a straight forward thingy see Table~\ref{Tab1}.
    \begin{table}
        \begin{tabular}{lllll}\toprule
            &&\textbf{Backward} & \textbf{Forward} & \textbf{Bidirectional}\\\midrule
            atis & Training & 345 & 235 & 345\\
                 & Test & 356 & 252 & 345\\
            brown & Training & 465 & 345 & 346\\
                  & Test & 456 & 342 & 253\\
            wsj & Training & 345 & 235 & 254\\
                & Test & 4336 & 634 & 3434
            \\\bottomrule
        \end{tabular}
        \caption{The Results}\label{Tab1}
    \end{table} 
\end{document}

results in the tabular as seen here Tabular1

But to me it looks like you want to compare Training and Test for certain methods, each applied to one „Object of interes“ (artis, brown & wsj) - so maybe you want to spend one column for each object and get a better way to compare those two by using something like „subcolumns“ as in the following MWE

\documentclass[a4paper,12pt]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,floatrow}

%center tables
\floatsetup[table]{objectset=centering,capposition=top}
\begin{document}
    But maybe also the Table~\ref{Tab2} might be nice?
    \begin{table}
        \begin{tabular}{lrrrrrr}\toprule
            &\multicolumn{2}{c}{\textbf{Backward}}&\multicolumn{2}{c}{\textbf{Forward}}&\multicolumn{2}{c}{\textbf{Bidirectional}}
            \\\cmidrule(r){2-3}\cmidrule(r){4-5}\cmidrule(r){6-7}   
            &Training&Test&Training&Test&Training&Test\\\midrule
            atis    & 345 & 356
                    & 235 & 252
                    & 345 & 345\\
            brown   & 465& 456
                    & 345 & 342
                    & 346 & 253\\
            wsj     & 345 & 4336 
                    & 235 & 634
                    & 254 & 3434
            \\\bottomrule
        \end{tabular}
        \caption{The Results}\label{Tab2}
    \end{table} 
\end{document}

Where i used \cmidrow additionally to group each of the Training-Test-Pairs and used \multicolumn to give these two columns a common title. The result is

Tabular2

But that of course depends on your data, I assumed here, that Training and Test belonged to the same object, (atis for example) hence putting them in one row seems to be a good idea.

Edit: For the first idea i just used l as left for the column layout, the second one is the one i prefer (r for right), but of course egreg's answer using siunitx is quite nice, too.

share|improve this answer
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.