4

I rotated a table using sidewaystable but the first and last 4 cells of the first row appear with a wrong vertical alignment. Can anyone solve this problem? enter image description here

\documentclass[twoside,b5paper,12pt,fleqn]{psd_thesis}
\usepackage{amsmath,amssymb,amsfonts}           \usepackage[T1]{fontenc}
\usepackage{newtxmath,newtxtext}                
\usepackage{rotating}
\usepackage{pdflscape}
\usepackage{tabulary}                                                           
% Include the following packages 
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs}  % for \toprule, \midrule, and \bottomrule macros 

\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\begin{document}

%\begin{footnotesize}
\begin{sidewaystable}
\scriptsize
\centering
\begin{tabular}{ C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm}      C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} }    
%\begin{tabular}{c c c c c c c c c c c c c c}
\toprule
Sv,ieq  &   000436xa    &   000594xa    &   001715xa    &   001932ya    &     006040ya  &   006263xa    &   007162ya    &   007257ya    &   IT0605ya    &     IT0790xa  &   emiliaeo-retro  &   emilians-retro  \\   \midrule
0.4 &   2.447   &   2.177   &   2.304   &   4.921   &   4.298   &   2.121   &   3.928   &   3.478   &   3.462   &   1.751   &   0.875   &   0.525   \\    \hline
0.8 &   4.894   &   4.354   &   4.609   &   9.843   &   8.597   &   4.241   &   7.857   &   6.957   &   6.924   &   3.502   &   1.750   &   1.049   \\   \hline
1.2 &   7.341   &   6.530   &   6.913   &   14.764  &   12.895  &   6.362   &   11.785  &   10.435  &   10.386  &   5.252   &   2.625   &   1.574   \\   \hline
1.6 &   9.789   &   8.707   &   9.218   &   19.686  &   17.194  &   8.482   &   15.713  &   13.914  &   13.848  &   7.003   &   3.500   &   2.099   \\   \hline
2   &   12.236  &   10.884  &   11.522  &   24.607  &   21.492  &   10.603  &   19.642  &   17.392  &   17.310  &   8.754   &   4.375   &   2.624   \\   \hline
2.4 &   14.683  &   13.061  &   13.827  &   29.529  &   25.791  &   12.723  &   23.570  &   20.871  &   20.772  &   10.505  &   5.250   &   3.148   \\   \hline
2.8 &   17.130  &   15.237  &   16.131  &   34.450  &   30.089  &   14.844  &   27.498  &   24.349  &   24.234  &   12.256  &   6.125   &   3.673   \\   \hline
3.2 &   19.577  &   17.414  &   18.435  &   39.372  &   34.388  &   16.965  &   31.427  &   27.828  &   27.697  &   14.006  &   7.000   &   4.198   \\   \hline
3.6 &   22.024  &   19.591  &   20.740  &   44.293  &   38.686  &   19.085  &   35.355  &   31.306  &   31.159  &   15.757  &   7.875   &   4.723   \\   \hline
4   &   24.471  &   21.768  &   23.044  &   49.215  &   42.984  &   21.206  &   39.283  &   34.784  &   34.621  &   17.508  &   8.750   &   5.247   \\   \hline
4.4 &   26.919  &   23.945  &   25.349  &   54.136  &   47.283  &   23.326  &   43.212  &   38.263  &   38.083  &   19.259  &   9.625   &   5.772   \\   \hline
4.8 &   29.366  &   26.121  &   27.653  &   59.058  &   51.581  &   25.447  &   47.140  &   41.741  &   41.545  &   21.009  &   10.500  &   6.297   \\   \hline
5.2 &   31.813  &   28.298  &   29.957  &   63.979  &   55.880  &   27.567  &   51.068  &   45.220  &   45.007  &   22.760  &   11.375  &   6.821   \\   \hline
5.6 &   34.260  &   30.475  &   32.262  &   68.900  &   60.178  &   29.688  &   54.996  &   48.698  &   48.469  &   24.511  &   12.250  &   7.346   \\   \hline
6   &   36.707  &   32.652  &   34.566  &   73.822  &   64.477  &   31.809  &   58.925  &   52.177  &   51.931  &   26.262  &   13.125  &   7.871   \\       \bottomrule 
\end{tabular}
\caption{Caption}
\end{sidewaystable}
%\end{footnotesize}

\end{document}

The psd_thesis.cls is reported below:

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{psd_thesis}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}

\ProcessOptions

\LoadClass{report}

\renewcommand{\baselinestretch}{1.5}  % Double-spaced

\usepackage[round]{natbib}  % bib style

%\usepackage[tx]{sfmath}      % a package of fonts
%\usepackage{helvet}             % For Helvetica (Arial is just a bad copy of Helvetica)
%\renewcommand\familydefault{\sfdefault}  

\renewcommand{\@makechapterhead}[1]{%
\vspace*{50\p@}%  {\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
    \large \scshape \bfseries \@chapapp\space \thechapter
    \par\nobreak
    \vskip 20\p@
\fi
\interlinepenalty\@M
\large \bfseries #1\par\nobreak
\vskip 40\p@  }}

\renewcommand{\@makeschapterhead}[1]{%
\vspace*{50\p@}%{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\large \scshape \bfseries  #1\par\nobreak
\vskip 40\p@  }}  

\renewcommand{\section}{\@startsection{section}% % the name{1}% % the level{0mm}% % the indent{3.0\baselineskip}% % the before skip{2.5\baselineskip}% % the after skip{\normalfont \normalsize}} % the style

\renewcommand{\subsection}{\@startsection{subsection}% % the name
{2}% % the level{0mm}% % the indent{-\baselineskip}% % the before skip{1.5\baselineskip}% % the after skip{\normalfont \normalsize}} % the style

\endinput
1
  • Is the psd_thesis document class available online? Please advise.
    – Mico
    Commented Jul 6, 2016 at 21:50

2 Answers 2

4

I made test with document class book, since your problem is tied with definition of \newcolumtype. Instead yours try to use:

\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

and align of texts in the first row will become:

enter image description here

In test I use for page layout package geometry with option b5paper and showframe. The latter option is only for seeing page layout. With this option your table is to wide, so I alo add \setlength\tabcolsep{3pt}. So my preamble and few rows of table was:

    \documentclass[twoside,12pt,fleqn]{book}
        \usepackage[b5paper,showframe]{geometry}
    \usepackage[T1]{fontenc}
    %\usepackage{amsmath,amssymb,amsfonts}
    %\usepackage{newtxmath,newtxtext}
    %\usepackage{textgreek}
    \usepackage{rotating}
    %\usepackage{pdflscape}
    %\usepackage{tabulary}
    % Include the following packages
    %\usepackage{amsmath} % second time ...
    \usepackage{array}
    \usepackage{booktabs}  % for \toprule, \midrule, and \bottomrule macros
    \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

    \begin{document}
        \begin{sidewaystable}
    \scriptsize
    \setlength\tabcolsep{3pt}
        \begin{tabular}{ C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm}      C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} C{1.1cm} }
    %\begin{tabular}{c c c c c c c c c c c c c c}
    \toprule
    Sv,ieq  &   000436xa    &   000594xa    &   001715xa    &   001932ya    &     006040ya  &   006263xa    &   007162ya    &   007257ya    &   IT0605ya    &     IT0790xa  &   emiliaeo-retro  &   emilians-retro  \\   \midrule

    \end{tabular}
\caption{Caption}
    \end{sidewaystable}
\end{document}

Addendum: First off-topic. To my taste the table will look better if you

  • use S column type from siunitx package
  • omit all \hline in table

In this case code becomes:

\documentclass[twoside,12pt,fleqn]{book}
    \usepackage[b5paper,showframe]{geometry}
\usepackage[T1]{fontenc}
\usepackage{rotating}
\usepackage{booktabs}  % for \toprule, \midrule, and \bottomrule macros
\usepackage{siunitx}  % for better formatting columns with decimal numbers

\begin{document}
    \begin{sidewaystable}
\scriptsize
\setlength\tabcolsep{3pt}
    \begin{tabular}{@{}S[table-format=1.1]*{12}{S[table-format=2.3]}@{}}
\toprule
\multicolumn{11}{c}{}   &   \multicolumn{2}{c}{retro}   \\
    \cmidrule{12-13}
{Sv,ieq} & {000436xa} & {000594xa} & {001715xa} & {001932ya}    & {006040ya}  & {006263xa}    & {007162ya} & {007257ya} & {IT0605ya} & {IT0790xa}  & {emiliaeo} &  {emilians} \\   \midrule
0.4 &   2.447   &   2.177   &   2.304   &   4.921   &   4.298   &   2.121   &   3.928   &   3.478   &   3.462   &   1.751   &   0.875   &   0.525   \\    
0.8 &   4.894   &   4.354   &   4.609   &   9.843   &   8.597   &   4.241   &   7.857   &   6.957   &   6.924   &   3.502   &   1.750   &   1.049   \\   
1.2 &   7.341   &   6.530   &   6.913   &   14.764  &   12.895  &   6.362   &   11.785  &   10.435  &   10.386  &   5.252   &   2.625   &   1.574   \\  
...
    \bottomrule
    \end{tabular}
\caption{Caption}
    \end{sidewaystable}
\end{document}

and gives:

enter image description here

Regarding additional question in your comment:

  1. Table in my test is centeret on page
  2. don't do it this. Table already ocupay whole text height and any further reducing font in table will make it not readable. Also is natural that caption is below or above table
6
  • @Zarco I solved that problem using \newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}} and \setlength\tabcolsep{3pt} There is another problem now: my table is aligned at the top of the page, how can I move it to the center? Moreover I would like the caption with the normal orientation, not rotated, can you solve this problem as well? Thank you in advance
    – Luca
    Commented Jul 6, 2016 at 22:24
  • See addendum to my answer.
    – Zarko
    Commented Jul 6, 2016 at 22:39
  • +1 for trying to dissuade the OP from placing the caption in a different place.
    – Mico
    Commented Jul 6, 2016 at 22:43
  • @Zarco I want to have on top the first row with a column of 1 cell and a multicolumn of 12 cells and the second a row of 13 columns. If possible I would like the vertical alignment of the first single column in the middle of the first 2 rows. The rest of the rows from 3 onward below should be of 13 columns. Do you have suggestions? Thank you
    – Luca
    Commented Jul 16, 2016 at 23:18
  • I would like to have on the top a row with a single column on the left and then a multicolumn of 12 cells. Then the second row should be of 13 columns. The content of the first single column should have the vertical alignment in the middle of the first and second rows. Can anyone solve this problem mantaining the columns large C{1.1cm}? Thank you. I tried this: '\begin{tabular}{c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} c{1.1} } \toprule {single column} & \multicolumn{12}{c}{multicolumn} \\ \cmidrule{2-13}'
    – Luca
    Commented Jul 17, 2016 at 10:26
3

(I can't get your custom document class to work -- too many error messages. In what follows, I use the report document class, largely because the psd_thesis class appears to be built on the report class.)

First and foremost, you need to make sure that the table fits inside the text block. (As one can tell from the screenshot you've posted, your table is currently much too wide.) I suggest you use a tabularx environment (with width set to \textwidth) instead of a tabular environment with fixed-width columns. Getting rid of the AFAICT unnecessary \hspace{0pt} directive inside the definition of the C column type let you get rid of the vertical spacing anomaly you've encountered.

I would further like to recommend that you align the numbers on their respective decimal markers; this will make it easier on your readers to actually take in the information you're looking to provide. Do also consider getting rid of all \hline directives and simply adding a bit more vertical whitespace after every fifth data row.

enter image description here

\documentclass[twoside,b5paper,12pt,fleqn]{report}
\usepackage{geometry,amsmath,amssymb,amsfonts}           
\usepackage[T1]{fontenc}
\usepackage{newtxmath,newtxtext}                
\usepackage{rotating,tabularx,booktabs,siunitx,caption}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\newcommand\mc[1]{\multicolumn{1}{C}{#1}} % handy shortcut macro
\begin{document}

\begin{sidewaystable}
\scriptsize
\captionsetup{size=scriptsize} % match font size to body of table
\setlength\tabcolsep{3pt}  % less space between columns
\setlength\extrarowheight{2pt}
\begin{tabularx}{\textwidth}{@{} 
          S[table-format=1.1] *{11}{S[table-format=2.3]} S[table-format=1.3] @{}}
\toprule
{Sv,ieq} & \mc{000436xa} & \mc{000594xa} & \mc{001715xa} & \mc{001932ya} & 
\mc{006040ya} & \mc{006263xa} & \mc{007162ya} & \mc{007257ya} & 
\mc{IT0605ya} & \mc{IT0790xa} & \mc{emiliaeo-retro} & \mc{emilians-retro}  \\   
\midrule
0.4 &   2.447   &   2.177   &   2.304   &   4.921   &   4.298   &   2.121   &   3.928   &   3.478   &   3.462   &   1.751   &   0.875   &   0.525   \\    
0.8 &   4.894   &   4.354   &   4.609   &   9.843   &   8.597   &   4.241   &   7.857   &   6.957   &   6.924   &   3.502   &   1.750   &   1.049   \\   
1.2 &   7.341   &   6.530   &   6.913   &   14.764  &   12.895  &   6.362   &   11.785  &   10.435  &   10.386  &   5.252   &   2.625   &   1.574   \\   
1.6 &   9.789   &   8.707   &   9.218   &   19.686  &   17.194  &   8.482   &   15.713  &   13.914  &   13.848  &   7.003   &   3.500   &   2.099   \\   
2   &   12.236  &   10.884  &   11.522  &   24.607  &   21.492  &   10.603  &   19.642  &   17.392  &   17.310  &   8.754   &   4.375   &   2.624   \\   
\addlinespace  % a bit more space after every 5th row
2.4 &   14.683  &   13.061  &   13.827  &   29.529  &   25.791  &   12.723  &   23.570  &   20.871  &   20.772  &   10.505  &   5.250   &   3.148   \\   
2.8 &   17.130  &   15.237  &   16.131  &   34.450  &   30.089  &   14.844  &   27.498  &   24.349  &   24.234  &   12.256  &   6.125   &   3.673   \\   
3.2 &   19.577  &   17.414  &   18.435  &   39.372  &   34.388  &   16.965  &   31.427  &   27.828  &   27.697  &   14.006  &   7.000   &   4.198   \\   
3.6 &   22.024  &   19.591  &   20.740  &   44.293  &   38.686  &   19.085  &   35.355  &   31.306  &   31.159  &   15.757  &   7.875   &   4.723   \\   
4   &   24.471  &   21.768  &   23.044  &   49.215  &   42.984  &   21.206  &   39.283  &   34.784  &   34.621  &   17.508  &   8.750   &   5.247   \\   
\addlinespace
4.4 &   26.919  &   23.945  &   25.349  &   54.136  &   47.283  &   23.326  &   43.212  &   38.263  &   38.083  &   19.259  &   9.625   &   5.772   \\   
4.8 &   29.366  &   26.121  &   27.653  &   59.058  &   51.581  &   25.447  &   47.140  &   41.741  &   41.545  &   21.009  &   10.500  &   6.297   \\   
5.2 &   31.813  &   28.298  &   29.957  &   63.979  &   55.880  &   27.567  &   51.068  &   45.220  &   45.007  &   22.760  &   11.375  &   6.821   \\   
5.6 &   34.260  &   30.475  &   32.262  &   68.900  &   60.178  &   29.688  &   54.996  &   48.698  &   48.469  &   24.511  &   12.250  &   7.346   \\   
6   &   36.707  &   32.652  &   34.566  &   73.822  &   64.477  &   31.809  &   58.925  &   52.177  &   51.931  &   26.262  &   13.125  &   7.871   \\       
\bottomrule 
\end{tabularx}
\caption{Caption}
\end{sidewaystable}

\end{document}
1
  • (+1) ... you bit me for time which I need to typing answers in Op comment (this evening I'm extra slow ... :-(
    – Zarko
    Commented Jul 6, 2016 at 22:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .