2

I'm using the below script to rotate the table, but it keeps giving an error l.208 \end{table}

\documentclass[12pt]{report}
\usepackage{float}
\usepackage[centertags]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb} %AAB95
\usepackage{amsthm}
\usepackage{tabularx}
\usepackage{comment}
\usepackage{newlfont}
\usepackage{XThesis_TJBLACK} 
\usepackage{xtocinc} 
\usepackage{graphicx}
\usepackage{changebar}
\usepackage{subfig}
\usepackage{algorithmic}
\usepackage{subfloat}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{cite}
\usepackage{amsmath}
\usepackage[T1]{fontenc}
\newtheorem{theorem}{Theorem}[section]
\usepackage[active]{srcltx} \newlength{\defbaselineskip}
\setlength{\defbaselineskip}{\baselineskip}
\newcommand{\setlinespacing}[1]%
{\setlength{\baselineskip}{#1 \defbaselineskip}}
\newcommand{\doublespacing}{\setlength{\baselineskip}%
{1.5 \defbaselineskip}}
\newcommand{\singlespacing}{\setlength{\baselineskip}{\defbaselineskip}}
\renewcommand{\baselinestretch}{1.3}
\renewcommand*{\bibname}{References}
\usepackage{tabularx,booktabs,ragged2e}
\newcolumntype{Y}{>{\RaggedRight\hsize=1.35\hsize}X}
\newcolumntype{Z}{>{\Centering\hsize=.95\hsize\arraybackslash}X}
\newcommand{\A}{{\cal A}}
\newcommand{\h}{{\cal H}}
\newcommand{\s}{{\cal S}}
\newcommand{\W}{{\cal W}}
\newcommand{\BH}{\mathbf B(\cal H)}
\newcommand{\KH}{\cal K(\cal H)}
\newcommand{\Real}{\mathbb R}
\newcommand{\Complex}{\mathbb C}
\newcommand{\Field}{\mathbb F}
\newcommand{\RPlus}{[0,\infty)}
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
\newcommand{\essnorm}[1]{\norm{#1}_{\text{\rm\normalshape ess}}}
\newcommand{\abs}[1]{\left\vert#1\right\vert}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\seq}[1]{\left<#1\right>}
\newcommand{\eps}{\varepsilon}
\newcommand{\To}{\longrightarrow}
\newcommand{\RE}{\operatorname{Re}}
\newcommand{\IM}{\operatorname{Im}}
\newcommand{\Poly}{{\cal{P}}(E)}
\newcommand{\EssD}{{\cal{D}}}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\theoremstyle{remark}
\newtheorem{rem}{Remark}[section]
\numberwithin{equation}{chapter}
\renewcommand{\theequation}{\thechapter.\arabic{equation}}
\usepackage{mwe,subfig,calc}
\def\trans{^{\mathsf{T}}}
\newlength{\tempheight}
\newlength{\tempwidth}
\newcommand{\rowname}[1]
{\rotatebox{90}{\makebox[\tempheight][c]{#1}}}
\newcommand{\columnname}[1]% #1 = text
{\makebox[\tempwidth][c]{#1}}
\usepackage{courier}

\begin{document}
    \begin{sidewaystable}
        \centering
        \caption{Your caption here}
    \begin{tabular}{l|lllllll}
    \hline
    sssssssss/sssss ss ssssssssss & sssssssss & ssssssss & ssssssss                                   & sssssssssss                 & ssssssssss & sssssssss ssss sssssssss ssssssssss & sssssssss ssss sssssssss ssssssssssss \\ \hline
    sssss ssssssssssss            & sss       & sss      & sssssssss, ssssssssssss                    & sssssssss sssssss, sssssss  & ssssss     &                                     &                                         \\
    ssssssssss ssssssssssss        & sss       & ss       & sssssssss                                  & ssssss ssssss              & ssssss     &                                     &                                         \\
    ssssssss ssssssss             & ss        & sss      & sssssssss, sssssssss sssssssssss           & ssssssssssss, sssssssss    & ssssss     &                                     &                                         \\
    ssss sssss                    & sss       & sss      & sssss, ssssssssss sssssss, ssssss ssssssss & ssssssssssss               & sssssss    &                                     &                                         \\
    ssss                          & ss        & sss      & sssssss ssssss, sssssssss ssssssss         & sssssssss                  & sssssss    &                                     &                                         \\
    sss                           & ss        & sss      & ssssssss ssssssssss                        & sssss sssssssss            & sssssss    &                                     &                                         \\
    ssssss ssssss                 & ss        & sss      & ssssssss ssssssssss                        & sssssssss ss sssss sssssss & sssssss    &                                     &                                        
    \end{tabular}
    \end{sidewaystable}

\end{document}
Tak
  • 2,346
  • 4
  • 20
  • 33
  • 1
    Don't try to nest a sidewaystable inside a table. Delete the \begin{table} and \end{table} instructions. – Mico May 21 '15 at 00:15
  • @Mico I've updated my question and I already did that but the same error appears. As I originally followed the answer here http://tex.stackexchange.com/questions/25369/how-to-rotate-a-table but still the same problem – Tak May 21 '15 at 00:19
  • @Mico I think there is a problem with the \usepackage{rotating} as when I commented the table the error still appeared, but when I removed the package the file complied without errors. Any thoughts? – Tak May 21 '15 at 00:26
  • Well, if you delete the two offending instructions, you should no longer be getting errors. You'll find that the table is just too wide to fit in the available space; while undesirable, it's not an "error". I suggest you peruse some of the answers to your earlier questions, e.g., regarding the sue of a tabularx environment, to find a way to make the table fit in the available space. – Mico May 21 '15 at 00:27
  • but why when I deleted the package the error no longer exists? – Tak May 21 '15 at 00:28
  • Please post a compilable MWE that actually generates the error(s) you say you're getting. Without an MWE, there's simply no way to tell what's going on. – Mico May 21 '15 at 00:29
  • no worries, I've updated my question, please have a look whenever you have the time to. I appreciate your kind assistance. – Tak May 21 '15 at 00:33

1 Answers1

3

Some suggestions and comments:

  • My TeX distribution doesn't feature the XThesis_TJBLACK and xtocinc packages; I've had to remove the corresponding \usepackage instructions to make your code compilable.

  • It's generally not a good idea to manipulate the low-level TeX macro \baselineskip directly. Better to load the setspace package and to issue the directive \setstretch{1.3}. (Making this change will also avoid excessive spacing in footnotes and tables, where single-spacing should be used anyway.)

  • If you want to use the sidewaystable environment, it's necessary to load the rotating package. (Aside: Since your code does not contain an \end{table} instruction, there is no way -- contrary to your claim -- that LaTeX can generate an error message containing the string l.208 \end{table}.)

  • I don't get any compilation errors after I implement these changes. However, the table still won't fit inside the (rotated) text block, as you don't allow automatic line breaking. Consider using a tabularx environment instead of the basic tabular environment, and using a modified form of the X column type instead of the basic l column type.

  • Don't use the / (forward slash) symbol if you want to allow linebreaks. Use \slash instead.

enter image description here

\documentclass[12pt]{report}
\usepackage{float}
\usepackage[centertags]{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb} %AAB95
\usepackage{amsthm}
\usepackage{tabularx}
\usepackage{comment}
\usepackage{newlfont}
%%\usepackage{XThesis_TJBLACK} 
%%\usepackage{xtocinc} 
\usepackage{graphicx}
\usepackage{changebar}
\usepackage{subfig}
\usepackage{algorithmic}
\usepackage{subfloat}
\usepackage{multirow}
\usepackage{booktabs}
\usepackage{cite}
\usepackage{amsmath}
\usepackage[T1]{fontenc}
\newtheorem{theorem}{Theorem}[section]

\usepackage[active]{srcltx} 

%%\newlength{\defbaselineskip}
%%\setlength{\defbaselineskip}{\baselineskip}
%%\newcommand{\setlinespacing}[1]%
%%{\setlength{\baselineskip}{#1 \defbaselineskip}}
%%\newcommand{\doublespacing}{\setlength{\baselineskip}%
%%{1.5 \defbaselineskip}}
%%\newcommand{\singlespacing}{\setlength{\baselineskip}{\defbaselineskip}}
%%\renewcommand{\baselinestretch}{1.3}

\renewcommand*{\bibname}{References}
\usepackage{tabularx,booktabs,ragged2e}
\newcolumntype{Y}{>{\RaggedRight\hsize=1.35\hsize}X}
\newcolumntype{Z}{>{\Centering\hsize=.95\hsize\arraybackslash}X}

\newcommand{\A}{{\cal A}}
\newcommand{\h}{{\cal H}}
\newcommand{\s}{{\cal S}}
\newcommand{\W}{{\cal W}}
\newcommand{\BH}{\mathbf B(\cal H)}
\newcommand{\KH}{\cal K(\cal H)}
\newcommand{\Real}{\mathbb R}
\newcommand{\Complex}{\mathbb C}
\newcommand{\Field}{\mathbb F}
\newcommand{\RPlus}{[0,\infty)}
\newcommand{\norm}[1]{\left\Vert#1\right\Vert}
\newcommand{\essnorm}[1]{\norm{#1}_{\text{\rm\normalshape ess}}}
\newcommand{\abs}[1]{\left\vert#1\right\vert}
\newcommand{\set}[1]{\left\{#1\right\}}
\newcommand{\seq}[1]{\left<#1\right>}
\newcommand{\eps}{\varepsilon}
\newcommand{\To}{\longrightarrow}
\newcommand{\RE}{\operatorname{Re}}
\newcommand{\IM}{\operatorname{Im}}
\newcommand{\Poly}{{\cal{P}}(E)}
\newcommand{\EssD}{{\cal{D}}}
\theoremstyle{plain}
\newtheorem{thm}{Theorem}[section]
\newtheorem{cor}[thm]{Corollary}
\newtheorem{lem}[thm]{Lemma}
\newtheorem{prop}[thm]{Proposition}
\theoremstyle{definition}
\newtheorem{defn}{Definition}[section]
\theoremstyle{remark}
\newtheorem{rem}{Remark}[section]
\numberwithin{equation}{chapter}
\renewcommand{\theequation}{\thechapter.\arabic{equation}}
\usepackage{mwe,subfig,calc}
\def\trans{^{\mathsf{T}}}
\newlength{\tempheight}
\newlength{\tempwidth}
\newcommand{\rowname}[1]
{\rotatebox{90}{\makebox[\tempheight][c]{#1}}}
\newcommand{\columnname}[1]% #1 = text
{\makebox[\tempwidth][c]{#1}}
\usepackage{courier}

%% new:
\usepackage{setspace}
\setstretch{1.3}
\usepackage{rotating}  % for 'sidewaystable' environment
\usepackage{array}     % for '\newcolumntype' macro
\newcolumntype{x}{>{\raggedright\arraybackslash}X}

\begin{document}
    \begin{sidewaystable}
        \centering
        \caption{Your caption here}
    \begin{tabularx}{\textwidth}{x|*{7}{x}}
    \hline
    sssssssss\slash sssss ss ssssssssss & sssssssss & ssssssss & ssssssss                                   & sssssssssss                 & ssssssssss & sssssssss ssss sssssssss ssssssssss & sssssssss ssss sssssssss ssssssssssss \\ \hline
    sssss ssssssssssss            & sss       & sss      & sssssssss, ssssssssssss                    & sssssssss sssssss, sssssss  & ssssss     &                                     &                                         \\
    ssssssssss ssssssssssss        & sss       & ss       & sssssssss                                  & ssssss ssssss              & ssssss     &                                     &                                         \\
    ssssssss ssssssss             & ss        & sss      & sssssssss, sssssssss sssssssssss           & ssssssssssss, sssssssss    & ssssss     &                                     &                                         \\
    ssss sssss                    & sss       & sss      & sssss, ssssssssss sssssss, ssssss ssssssss & ssssssssssss               & sssssss    &                                     &                                         \\
    ssss                          & ss        & sss      & sssssss ssssss, sssssssss ssssssss         & sssssssss                  & sssssss    &                                     &                                         \\
    sss                           & ss        & sss      & ssssssss ssssssssss                        & sssss sssssssss            & sssssss    &                                     &                                         \\
    ssssss ssssss                 & ss        & sss      & ssssssss ssssssssss                        & sssssssss ss sssss sssssss & sssssss    &                                     &                                        
    \end{tabularx}
    \end{sidewaystable}

\end{document}
Mico
  • 506,678
  • but changing (commenting) the line spacing packages will affect my document right? as in my document I'm using this \setlinespacing{1.3} – Tak May 21 '15 at 01:58
  • shepherd - Try not to use \setlinespacing{1.3}; use \setstretch{1.3} instead. The setspace package provides macros named \singlespacing and \doublespacing, by the way. – Mico May 21 '15 at 02:28
  • I did that and I still get this error \end{table} I don't know why, although there is no \end{table} in this table definition (there are other tables) – Tak May 21 '15 at 02:36
  • @shepherd - The error has nothing to do with line spacing, right? If you keep getting an error about \end{table}, it has to be the case that there's an \end{table} instruction hanging around somewhere. Since you're not showing the code that produces the error, and since you're apparently unwilling to state the contents of the error message, I see no point in continuing this conversation. If you need to fix any remaining errors, by all means post a new query -- with a working Minimum Working Example that actually reproduces the error message(s) you say occur. – Mico May 21 '15 at 02:49
  • I'm happy to post the whole error, but I can't put the whole chapter of my thesis. – Tak May 21 '15 at 02:51
  • @shepherd - As I said, without an MWE that gives rise to the error, it's not promising to speculate as to what may be going on. If I were you, though, I would look for a missing } (right curly brace). – Mico May 21 '15 at 03:00
  • I'm sure that there is no missing } as when I comment the table and the rotating package it compile without any errors. I accepted your answer anyway for your kind assistance, I really appreciate your help. – Tak May 21 '15 at 03:02