2

I try to add a table to my document, thus, I used the following code:

\documentclass{article}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage[figuresright]{rotating}
\begin{document}
\begin{sidewaystable} 
\centering
\caption{Caption}
\label{Label}       
\begin{tabular}{|p{1.5cm}|p{2.35cm}|p{3.12cm}|p{3.12cm}|p{3.12cm}|p{3.12cm}|}
\hline
\multicolumn{2}{|c|}{}& \multicolumn{4}{|c|}{XXXXXX XXXXXXX}\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX}&  XXXXXX XXXXXXX BXXXXXXX XXXXXX& XXXXXX XXXXXXX  &  XXXXXX XXXXXXX &   XXXXXX XXXXXXX\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX}  &  XXXXXX XXXXXXX  &  XXXXXX XXXXXXX &   XXXXXX XXXXXXX &  XXXXXX XXXXXXX\\
\hline
\multirow{3}{1.5cm}{XXXX}& XXXXXX XXXXXXX & \makebox[\linewidth][c]{-} & \makebox[\linewidth][c]{-} & \makebox[\linewidth][c]{-} & XXXXXX XXXXXXX \\
\cline{2-6}
&XXXXXX XXXXXXX & XXXXXX XXXXX XXXXXXXX XXXXXXX & XXXXXX XXXXXXX&  \makebox[\linewidth][c]{-}  & XXXXXX XXXXXXX XXXXXX XXXXXXX\\
\cline{2-6}
&XXXXXX XXXXXXX &XXXXXX XXXXXXX &    XXXXXX XXXXXXX &\makebox[\linewidth][c]{-} &\makebox[\linewidth][c]{-}\\
\cline{2-6}
&XXXXXX XXXXXXX  & XXXXXX XXXXXXX & \makebox[\linewidth][c]{-} &  \makebox[\linewidth][c]{-} &\makebox[\linewidth][c]{-} \\
\cline{2-6}
&XXXXXX XXXXXXX & XXXXXX XXXXXXX & XXXXXX XXXXXXX & XXXXXX XXXXXXX &  \makebox[\linewidth][c]{-}\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX}   & XXXXXX XXXXXXX &    XXXXXX XXXXXXX &  XXXXXX XXXXXXX    & XXXXXX XXXXXXX\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX} &  XXXXXX XXXXXXX &    XXXXXX XXXXXXX &\makebox[\linewidth][c]{-}  & \makebox[\linewidth][c]{-}\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX} &   \makebox[\linewidth][c]{-} &    \makebox[\linewidth][c]{-} &    \makebox[\linewidth][c]{-} &    XXXXXX XXXXXXX\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX} &  XXXXXX XXXXXXX &   XXXXXX XXXXXXX &   XXXXXX XXXXXXX& \makebox[\linewidth][c]{-}\\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}

However the table appear like depicted in the attached image enter image description here

  • 2
    That's curious: it's perfectly centered for me. – JPi Apr 8 '17 at 14:41
  • 2
    Are you using a different document class? Your code works fine here as well, does that exact example produce the misalignment on your system? – Torbjørn T. Apr 8 '17 at 14:42
  • I use a Springer Template thus, my document starts as follow: \begin{filecontents*} gsave newpath 20 20 moveto 20 220 lineto 220 220 lineto 220 20 lineto closepath 2 setlinewidth gsave .4 setgray fill grestore stroke grestore \end{filecontents*} \RequirePackage{fix-cm} \documentclass[smallextended]{svjour3} \smartqed % flush right qed marks, e.g. at end of proof \usepackage{graphicx} – FNY Apr 8 '17 at 15:31
  • You lost me there. Why don't you just edit your example to demonstrate the actual problem? – JPi Apr 8 '17 at 15:35
  • 1
    Either way, please make sure that the code you post actually reproduce the problem you're describing. – Torbjørn T. Apr 8 '17 at 19:36
4

The issue is a result of the lines

\setlength\@fptop{0\p@}
\setlength\@fpsep{12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\@fpbot{0\p@ \@plus 1fil}

in svjour3.cls.

When you load rotating \rotFPtop is automatically set to \@fptop and \rotFPbot to \@fpbot. Therefore the rotated table shifts to the right (top).

You can change this if you set \rotFPtop explicitly: either to 0pt plus 1fil or to \rotFPbot.

\documentclass{article}
%%% the following  5 lines only for simualating the issue
\makeatletter
\setlength\@fptop{0\p@}
\setlength\@fpsep{12\p@ \@plus 2\p@ \@minus 2\p@}
\setlength\@fpbot{0\p@ \@plus 1fil}
\makeatother
%%%

\usepackage{graphicx}
\usepackage{multirow}
\usepackage[figuresright]{rotating}
\setlength{\rotFPtop}{0pt plus 1fil}% <- add this line after loading rotating
\setlength{\rotFPbot}{0pt plus 1fil}% <- maybe its better to add this line too

\begin{document}
\begin{sidewaystable} 
\centering
\caption{Caption}
\label{Label}       
\begin{tabular}{|p{1.5cm}|p{2.35cm}|p{3.12cm}|p{3.12cm}|p{3.12cm}|p{3.12cm}|}
\hline
\multicolumn{2}{|c|}{}& \multicolumn{4}{|c|}{XXXXXX XXXXXXX}\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX}&  XXXXXX XXXXXXX BXXXXXXX XXXXXX& XXXXXX XXXXXXX  &  XXXXXX XXXXXXX &   XXXXXX XXXXXXX\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX}  &  XXXXXX XXXXXXX  &  XXXXXX XXXXXXX &   XXXXXX XXXXXXX &  XXXXXX XXXXXXX\\
\hline
\multirow{3}{1.5cm}{XXXX}& XXXXXX XXXXXXX & \makebox[\linewidth][c]{-} & \makebox[\linewidth][c]{-} & \makebox[\linewidth][c]{-} & XXXXXX XXXXXXX \\
\cline{2-6}
&XXXXXX XXXXXXX & XXXXXX XXXXX XXXXXXXX XXXXXXX & XXXXXX XXXXXXX&  \makebox[\linewidth][c]{-}  & XXXXXX XXXXXXX XXXXXX XXXXXXX\\
\cline{2-6}
&XXXXXX XXXXXXX &XXXXXX XXXXXXX &    XXXXXX XXXXXXX &\makebox[\linewidth][c]{-} &\makebox[\linewidth][c]{-}\\
\cline{2-6}
&XXXXXX XXXXXXX  & XXXXXX XXXXXXX & \makebox[\linewidth][c]{-} &  \makebox[\linewidth][c]{-} &\makebox[\linewidth][c]{-} \\
\cline{2-6}
&XXXXXX XXXXXXX & XXXXXX XXXXXXX & XXXXXX XXXXXXX & XXXXXX XXXXXXX &  \makebox[\linewidth][c]{-}\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX}   & XXXXXX XXXXXXX &    XXXXXX XXXXXXX &  XXXXXX XXXXXXX    & XXXXXX XXXXXXX\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX} &  XXXXXX XXXXXXX &    XXXXXX XXXXXXX &\makebox[\linewidth][c]{-}  & \makebox[\linewidth][c]{-}\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX} &   \makebox[\linewidth][c]{-} &    \makebox[\linewidth][c]{-} &    \makebox[\linewidth][c]{-} &    XXXXXX XXXXXXX\\
\hline
\multicolumn{2}{|c|}{XXXXXX XXXXXXX} &  XXXXXX XXXXXXX &   XXXXXX XXXXXXX &   XXXXXX XXXXXXX& \makebox[\linewidth][c]{-}\\
\hline
\end{tabular}
\end{sidewaystable}
\end{document}

enter image description here

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.