Graphics, Figures & TablesTabular in \newenvironment should use landscape

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
zer0nimo
Posts: 12
Joined: Wed Jul 29, 2009 3:20 am

Tabular in \newenvironment should use landscape

Post by zer0nimo »

Hi there!

I once again have a problem creating a table in a self-defined table. :(

So this post is somehow related to this one.

Here a little example:

Code: Select all

%----------------
\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{rotating}

%----------------

\newenvironment{MyTable}{

%	\begin{sideways}

	\tabularx{\textwidth}
	{@{\hspace{.2mm}}p{1.7cm}@{\hspace{.8mm}}
	*{3}{@{\hspace{1.8mm}}X}@{\hspace{.8mm}}
	p{1.7cm}@{\hspace{.2mm}}
	}%%

		\toprule
			\textbf{Project} & 
			\textbf{Stuff}&
			\textbf{Strategic}&
			\textbf{Other}&
			\textbf{Total}\\
		\midrule	
}{%
	\endtabularx
%	\end{sideways}
}%% End new environment

%----------------

\begin{document}

\begin{MyTable}
  1 & 2 & 3 & l &5 \\
  1 & 2 & 3 & l &5 \\
\end{MyTable}

\end{document}

%----------------
Now my problem is, that a table like this should be rotated by 90°.

I've tried landscape and rotate in different variations but failed to find a solution. The problems are, that in a new environment you can't span a \rotate, e.g.

Code: Select all

\newenvironment{sth.}{
  \rotate{90}{
    \tabularx ....
  
}
{
    \endtabularx
  }
}
nor use environments (Error: File ended while scanning use of \TX@get@body. <inserted text> \par)

Code: Select all

\newenvironment{sth.}{
  \begin{rotate}{90}
    \tabularx ....
  
}
{
    \endtabularx
  \end{rotate}
}
Has somebody an idea how to come along with this issue?

Thanks for any clues ;)

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Tabular in \newenvironment should use landscape

Post by gmedina »

Hi,

you could try something like the following:

Code: Select all

\documentclass{article}
\usepackage{tabularx}
\usepackage{booktabs}
\usepackage{rotating}

%----------------

\newenvironment{MyTable}{%
  \sideways%
  \tabularx{\textwidth}
     {@{\hspace{.2mm}}p{1.7cm}@{\hspace{.8mm}}
       *{3}{@{\hspace{1.8mm}}X}@{\hspace{.8mm}}
       p{1.7cm}@{\hspace{.2mm}}
     }%%
      \toprule
         \textbf{Project} & 
         \textbf{Stuff}&
         \textbf{Strategic}&
         \textbf{Other}&
         \textbf{Total}\\
      \midrule   
  }
  {\endsideways\endtabularx}
%% End new environment

%----------------

\begin{document}

\begin{MyTable}
  1 & 2 & 3 & l &5 \\
  1 & 2 & 3 & l &5 \\
\end{MyTable}

\end{document}

%----------------
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply