[Tex/LaTex] why does the document fail with sideways from rotating package

rotatingtables

I want to test landscape tables, and started with the sideways environment. However the code does not compile, I get the error:

(./content/landscapetable.tex
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \begin{center}

Here is a minimal example:

\documentclass{scrartcl} 
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{rotating}
\begin{document}
\begin{sideways}
\begin{center}
  \centering 
%  \captionsetup{type=table}
%  \caption{Sehr breite Tabelle.}
\begin{tabularx}{0.8\textheight}{XXX}
\hline
head & head & head \\
\hline
text which is considereably longer than 
the width of the column & 
text which is considereably longer than 
the width of the column & 
text which is considereably longer than 
the width of the column \\
\hline
\end{tabularx}  
\end{center}
\end{sideways}
\end{document}

Remove the sideways environment, and it compiles.

EDIT: when the center env is removed, and centering is left and the caption is introduced again another error with the caption occurs.

\begin{sideways}
  \centering
  \captionsetup{type=table}
  \caption{Sehr breite Tabelle.}
\begin{tabularx}{1.0\textheight}{*{6}{X}}
\hline
head & head & head & head & head & head \\
...
\end{tabularx}  
\end{sideways}

The error is then

! Missing \endgroup inserted.
<inserted text>
\endgroup
l.5 \caption{Sehr breite Tabelle.}

With sidewaystable it works, but that is not what I want.

Best Answer

Why both \centering and the center environment? Remove the latter and the example compiles fine.


(New solution, based on comment.)

If you did not want to rotate the caption, why put the caption in the sideways environment? What you could do is to place the table in a normal table environment, and then put just the tabularx in sideways.

\documentclass{scrartcl} 
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{rotating}
\begin{document}
\begin{table}
  \centering 
  \captionsetup{type=table}
  \caption{Sehr breite Tabelle.}
  \begin{sideways}
  \begin{tabularx}{0.8\textheight}{XXX}
    \hline
    head & head & head \\
    \hline
    text which is considereably longer than 
    the width of the column & 
    text which is considereably longer than 
    the width of the column & 
    text which is considereably longer than 
    the width of the column \\
  \hline
  \end{tabularx}
  \end{sideways}
\end{table}
\end{document}

enter image description here

On the other hand, I think it would be better to use sidewaystable, and have the caption rotated as well. Having to turn the page between reading the caption and reading the table would be awkward and inconvenient.