# Tables in Latex with diagonal first row

I'm trying to create a table with a diagonal first row, like in how-to-draw-diagonal-table-borders-in-latex-like-in-excel

I've looked through the documentation for PGF-TiKZ, but am still unsure as to how to do the above.

From how-combine-make-diagonal-column-heads-in-table-with-multicolumn-headers I've managed to make diagonal entries on the top row, but what I would like is to add in the option of having it enclosed by cell borders like in excel, with an option to specify the length of each line of text within the top row. An option capability to close the top of the row with a border would be nice too. Is there any way to do this, preferably through the tabularx package?

-
It seems to me that the question on StackOverflow you link to, that question should be moved here, and one of these then closed as a duplicate. –  yo' Oct 24 '12 at 16:21
Welcome to TeX.SE. It would be helpful if you showed us what you have done so far by providing a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. While solving problems is fun, setting them up is not. Then those trying to help can simply cut and paste your MWE and get started on solving problem. This will also serve as a test case and ensure that the solution actually works for you. –  Peter Grill Oct 25 '12 at 2:50
Is having vertical lines a requirement? If not and you want a typographically pleasing result just use the horizontal lines provided by the booktabs package (toprule, middlerule, bottomrule). –  Jörg Oct 25 '12 at 13:42

This is a conceptual and kind of a manual solution. We first inject \tikzmarks into the column seperators and then use them to draw over the table which sits in a TikZ node.

\documentclass{article}
\usepackage{tikz,array}
\usetikzlibrary{calc}
\newcommand{\tikzmark}[1]{\tikz[remember picture,overlay]\coordinate (#1);}

\newcolumntype{T}[1]{@{\hspace{\tabcolsep}}c@{\hspace{\tabcolsep}\tikzmark{#1}}}

\begin{document}
\begin{tikzpicture}[remember picture]
\node[inner xsep=-\pgflinewidth,inner ysep=-\pgflinewidth] at (0,0) (mytable){%
\begin{tabular}{|T{a}|T{b}|c|}
\hline A&B&C\\
$\alpha$ & $\beta$ & $\theta$\\
foo &bar &Hello world \\\hline
\end{tabular}
};
\draw (mytable.north east) --++ (60:3cm);
\draw (mytable.north west) --++ (60:3cm);
\draw (mytable.north-|a) --++ (60:3cm);
\draw (mytable.north-|b) --++ (60:3cm);
\draw (mytable.north east) ++ (60:3cm) --([shift={(60:3cm)}]mytable.north west);

\node[rotate=60,anchor=west] at ($(mytable.north-|a)!0.5!(mytable.north west)$) {First Column};
\node[rotate=60,anchor=west] at ($(mytable.north-|a)!0.5!(mytable.north-|b)$) {Second Column};
\node[rotate=60,anchor=west] at ($(mytable.north-|b)!0.5!(mytable.north east)$) {Third Column};
\end{tikzpicture}
\end{document}


-