2

I am making a table which includes single columns and 2 - merged columns. I am encountering two problems, first the data is very long and is not places within the area of the page, it exceeds the borders.

How can i overcome these Issues?

the pre-ample and tabular code is here:

    \documentclass[authoryear,preprint,review,12pt]{elsarticle}
    \usepackage{graphicx}
    \usepackage{amssymb}
    \usepackage{amsthm}
    \usepackage{mathtools}


    \begin{document}
\begin{table}
    \caption{Table aaaa}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|}\label{West Hebr Indexes}
    \caption{West Hebrides Indexes for the wind datasets}
     \hline
      • &\multicolumn{8}{c|}{West Hebrides} \\ 
     \hline 
     • & \multicolumn{2}{c|}{$H_{s}$} &\multicolumn{2}{c|}{$T_{p}$} &\multicolumn{2}{c|}{$T_{z}$} & \multicolumn{2}{c|}Dir \\ 
     \hline 
     • & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR \\ 
     \hline 
     Average Buoy & • & • & • & • & • & • & • & • \\ 
     \hline 
     Average SWAN & • & • & • & • & • & • & • & • \\ 
     \hline 
     Bias & • & • & • & • & • & • & • & • \\ 
     \hline 
     rms  & • & • & • & • & • & • & • & • \\ 
     \hline 
     OPI & • & • & • & • & • & • & • & • \\ 
     \hline 
     MPI & • & • & • & • & • & • & • & • \\ 
     \hline 
     SI & • & • & • & • & • & • & • & • \\ 
     \hline 
\end{table}    
 \end{tabular}  

    \end{document}
4
  • Caption should be in floating environment. in your case it shoul follows \begin{table} \caption{<title>}\begin{tabular} ... \end{tabular}\end{table}. – Zarko Jul 31 '14 at 7:59
  • @Zarko thank you very much, that work indeed, so tabular is like a subsection of the \table ( i know its a funny logic) but will help me remember . Thank you very for that. I update the question as well so now the first part is given – George Jul 31 '14 at 8:04
  • Always test your examples. If the table is too wide, you could change the font size or consider turning it to landscape. But what you should really do is rethink the whole table. Please also have a look at package booktabs – Johannes_B Jul 31 '14 at 8:26
  • tabular is (basic) macro for constructing of table. beside it latex know for more other, as tabularx, tabulary etc. They can be used directly in text, but without a caption. Caption is designed for use in floating environment. – Zarko Jul 31 '14 at 8:27
3

As mentioned by Zarko, the caption should go out of tabular environment. Besides, you have some errors like \multicolumn{2}{c|}Dir which should be \multicolumn{2}{c|}{Dir}.

Having said that, you have some options to fit the table within page. As first one, put \footnotesize (or \small) just after \begin{table}.

    \documentclass[authoryear,preprint,review,12pt]{elsarticle}
    \usepackage{graphicx}
    \usepackage{amssymb}
    \usepackage{amsthm}
    \usepackage{mathtools}


    \begin{document}
\begin{table}
\footnotesize
%    \caption{Table aaaa}
    \caption{West Hebrides Indexes for the wind datasets}\label{West Hebr Indexes}
    \begin{tabular}{|c|c|c|c|c|c|c|c|c|}\hline
      • &\multicolumn{8}{c|}{West Hebrides} \\
     \hline
     • & \multicolumn{2}{c|}{$H_{s}$} &\multicolumn{2}{c|}{$T_{p}$} &\multicolumn{2}{c|}{$T_{z}$} & \multicolumn{2}{c|}{Dir} \\
     \hline
     • & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR \\
     \hline
     Average Buoy & • & • & • & • & • & • & • & • \\
     \hline
     Average SWAN & • & • & • & • & • & • & • & • \\
     \hline
     Bias & • & • & • & • & • & • & • & • \\
     \hline
     rms  & • & • & • & • & • & • & • & • \\
     \hline
     OPI & • & • & • & • & • & • & • & • \\
     \hline
     MPI & • & • & • & • & • & • & • & • \\
     \hline
     SI & • & • & • & • & • & • & • & • \\
     \hline
 \end{tabular}
\end{table}


    \end{document}

enter image description here

Or use resizebox from graphicx package or better use adjustbox.

    \documentclass[authoryear,preprint,review,12pt]{elsarticle}
    \usepackage{graphicx}
    \usepackage{amssymb}
    \usepackage{amsthm}
    \usepackage{mathtools}
    \usepackage{adjustbox}


    \begin{document}
\begin{table}
%    \caption{Table aaaa}
    \caption{West Hebrides Indexes for the wind datasets}\label{West Hebr Indexes}
    \begin{adjustbox}{max width=\textwidth}
    \begin{tabular}{*{9}{|c}|}\hline
      • &\multicolumn{8}{c|}{West Hebrides} \\
     \hline
     • & \multicolumn{2}{c|}{$H_{s}$} &\multicolumn{2}{c|}{$T_{p}$} &\multicolumn{2}{c|}{$T_{z}$} & \multicolumn{2}{c|}{Dir} \\
     \hline
     • & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR \\
     \hline
     Average Buoy & • & • & • & • & • & • & • & • \\
     \hline
     Average SWAN & • & • & • & • & • & • & • & • \\
     \hline
     Bias & • & • & • & • & • & • & • & • \\
     \hline
     rms  & • & • & • & • & • & • & • & • \\
     \hline
     OPI & • & • & • & • & • & • & • & • \\
     \hline
     MPI & • & • & • & • & • & • & • & • \\
     \hline
     SI & • & • & • & • & • & • & • & • \\
     \hline
 \end{tabular}
 \end{adjustbox}
\end{table}


    \end{document}

enter image description here

As the third option, You can use a landscape page. Put \usepackage{pdflscape} in the preamble and enclost table inside landscape environment.

    \documentclass[authoryear,preprint,review,12pt]{elsarticle}
    \usepackage{graphicx}
    \usepackage{amssymb}
    \usepackage{amsthm}
    \usepackage{mathtools}
    \usepackage{pdflscape}


    \begin{document}
\begin{landscape}
\begin{table}
%    \caption{Table aaaa}
    \caption{West Hebrides Indexes for the wind datasets}\label{West Hebr Indexes}

    \begin{tabular}{*{9}{|c}|}\hline
      • &\multicolumn{8}{c|}{West Hebrides} \\
     \hline
     • & \multicolumn{2}{c|}{$H_{s}$} &\multicolumn{2}{c|}{$T_{p}$} &\multicolumn{2}{c|}{$T_{z}$} & \multicolumn{2}{c|}{Dir} \\
     \hline
     • & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR & ECMWF & CFSR \\
     \hline
     Average Buoy & • & • & • & • & • & • & • & • \\
     \hline
     Average SWAN & • & • & • & • & • & • & • & • \\
     \hline
     Bias & • & • & • & • & • & • & • & • \\
     \hline
     rms  & • & • & • & • & • & • & • & • \\
     \hline
     OPI & • & • & • & • & • & • & • & • \\
     \hline
     MPI & • & • & • & • & • & • & • & • \\
     \hline
     SI & • & • & • & • & • & • & • & • \\
     \hline
 \end{tabular}
\end{table}
\end{landscape}


    \end{document}

enter image description here

3
  • 2
    Please, use squeezing (reducing cell padding and font size) only as a last resort. I, for one, don't allow it in articles I copy edit, it's ugly and inconsistent. – yo' Jul 31 '14 at 9:15
  • @HarishKumar wow, thank you very much for the option provided, i tried the second with the resize and adjustbox, and will try to see what else they do..again thank you very much for the help – George Jul 31 '14 at 9:24
  • @tohecz I agree. But people have different needs. ;) Personally, I discourage the use of big tables themselves! – user11232 Jul 31 '14 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.