# Table with different widths and rows

I am using the following code to write the table

   \documentclass[11pt, fullscreen=true, bookmarks=false]{beamer}
\usepackage[utf8x]{inputenc}
%\usepackage[T2A]{fontenc}
\usepackage{beamerthemesplit}
\usetheme{Berlin}
\usepackage[english]{babel}
\usepackage{amssymb,amsfonts,amsmath,mathtext}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{booktabs,tabularx,ragged2e}
\newcolumntype{L}{>{\RaggedRight\arraybackslash}X}
\usepackage{ragged2e}
\renewcommand{\raggedright}{\leftskip=0pt \rightskip=0pt plus 0cm}
\begin{document}
\$\begin{table}[h]
\begin{tabular}{lccl}
\hline
\multicolumn{1}{c}{}

& \multicolumn{2}{l}{Direction of Prior Stock Market Movement}                                                         &                           \\ \hline
\multicolumn{1}{c}{\begin{tabular}[c]{@{}c@{}}Incumbent Election\\ Result\end{tabular}} & \begin{tabular}[c]{@{}c@{}}Large\\ Positive\end{tabular} & \begin{tabular}[c]{@{}c@{}}Large \\ Negative\end{tabular} & Fisher's Exact Test       \\ \hline
& \multicolumn{2}{c}{In Percentage Change:}                                                                            &                           \\ \hline
Landslide Victory                                                                       & 11 (73,3\%)                                              & 0 (0\%)                                                   &                           \\ \hline
Landslide Loss                                                                          & 1 (6,7\%)                                                & 3 (20\%)                                                  & 0,009                     \\ \hline
& \multicolumn{1}{l}{}                                     & \multicolumn{1}{r}{}                                      &                           \\ \hline
& \multicolumn{2}{c}{In Lognormal Transform:}                                                                          &                           \\ \hline
Landslide Victory                                                                       & 9 (75,0\%)                                               & 0 (0\%)                                                   &                           \\ \hline
Landslide Loss                                                                          & 0 (0\%)                                                  & 3 (25,0\%)                                                & \multicolumn{1}{c}{0,005} \\ \hline
& \multicolumn{1}{l}{}                                     & \multicolumn{1}{l}{}                                      &                           \\ \hline
\end{tabular}
\end{table}
\end{document}


But the result I get is different, from what I want, and I have problems with fitting my table to a slide. I want to get table looking like this:

What is wrong in my code and may it be improved? Thak you in advance a lot!

• Made the code more readable. – Bernard Jun 22 '14 at 14:00
• Solved it! added \resizebox{\textwidth}{!} command after \begin{table} – user54875 Jun 22 '14 at 14:29

You can use the makecell package to have cells of type l, r or c that accept \\, and the \addlinespace command from booktabs to improve vertical spacing. Actually you loaded booktabs but didn't use it. Here is a simpler code; I deleted all unnecessary packages for this table:

\documentclass[11pt, fullscreen=true, bookmarks=false]{beamer}
\usepackage[utf8x]{inputenc}
%\usepackage[T2A]{fontenc}
\usepackage{beamerthemesplit}
\usetheme{Berlin}
\usepackage[english]{babel}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{makecell}

\begin{document}

\begin{table}[h]
\begin{tabular}{@{}lccc@{}}
\toprule
& \multicolumn{2}{c}{\makecell{Direction of Prior Stock\\ Market Movement}} \\
\cmidrule{2-3}
\makecell{Incumbent Election\\ Result} & \makecell{Large\\ Positive} & \makecell{Large \\ Negative} & Fisher's Exact Test \\
\midrule
\multicolumn{4}{c}{In Percentage Change:} \\
\midrule
Landslide Victory & 11 (73,3\,\%) & 0 (0\,\%) & \\
Landslide Loss & 1 (6,7\%) & 3 (20\%) & 0,009 \\
\midrule
\multicolumn{4}{c}{In Lognormal Transform:} \\
\midrule
Landslide Victory & 9 (75,0\%) & 0 (0\%) & \\
Landslide Loss & 0 (0\%) & 3 (25,0\%) & \multicolumn{1}{c}{0,005} \\
\bottomrule
\end{tabular}
\caption{The Market Romance}
\end{table}

\end{document}


• This one looks nicer, but I can't fit the table to the slide, last row is not appearing because table is too big... And could you tell me, how can I add name of the table below it? I tryed \caption, but it doesn't work – user54875 Jun 22 '14 at 14:51
• I don't understand why it doesn't fit since I used the neamer class with the prescribed theme? Anyway I'll modify my answer in a moment, with a caption. – Bernard Jun 22 '14 at 15:00
• Updated my answer, with smaller vertical spacing and a caption. The vertical spacing is obtained with addlinespace, which defaults to 0.5em, and accepts an optional argument, as you can see from the code. You can change the values or even delete \addlinespaces, if needed. – Bernard Jun 22 '14 at 15:15
• yes, deleted all \addlinespace and it fits! thanks! – user54875 Jun 23 '14 at 8:18
• but u deleted the caption, could you please add the caption as well?? Thank you. – user54875 Jun 23 '14 at 13:55