I am trying to generate tables like the one above I found in a textbook in LaTeX.

In particular I am trying to find a way to make that $\$ slash symbol in the left upper corner. It would also be great if there was a way to make the words read from the side. But i do not want to read 180 degrees.

One possibility using TikZ:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,draw=black,text width=3em,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells
},
row 1/.style={nodes={fill=green!10}},
column 1/.style={nodes={fill=green!10}}
}

\begin{tikzpicture}

\matrix (mat) [table]
{
& 20  & 30 & 40 & 50 & 60 & 70 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
};
\draw (mat-1-1.north west) -- (mat-1-1.south east);
\node at ([xshift=-7pt,yshift=-4.5pt]mat-1-1) {$T$};
\node at ([xshift=7pt,yshift=4.5pt]mat-1-1) {$h$};
\node[rotate=90,anchor=south,font=\bfseries] at (mat.west) {Actual temperature ($^{\circ}$F)};
\node[anchor=south,font=\bfseries] at (mat.north) {Relative humidity (\%)};
\end{tikzpicture}

\end{document}


Or, with the text "Actual temperature (F)", placed horizontally:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\tikzset{
table/.style={
matrix of nodes,
row sep=-\pgflinewidth,
column sep=-\pgflinewidth,
nodes={rectangle,draw=black,text width=3em,align=center},
text depth=1.25ex,
text height=2.5ex,
nodes in empty cells
},
row 1/.style={nodes={fill=green!10}},
column 1/.style={nodes={fill=green!10}}
}

\begin{tikzpicture}

\matrix (mat) [table]
{
& 20  & 30 & 40 & 50 & 60 & 70 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
};
\draw (mat-1-1.north west) -- (mat-1-1.south east);
\node at ([xshift=-7pt,yshift=-4.5pt]mat-1-1) {$T$};
\node at ([xshift=7pt,yshift=4.5pt]mat-1-1) {$h$};
\node[anchor=east,font=\bfseries,align=center] at (mat.west) {Actual \\ temperature \\ ($^{\circ}$F)};
\node[anchor=south,font=\bfseries] at (mat.north) {Relative humidity (\%)};
\end{tikzpicture}

\end{document}


And here's a possibility using slashbox (personally, I find the results produced by slashbox to be of poor quality):

\documentclass{article}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage{slashbox}

\begin{document}

\noindent\parbox{2.2cm}{\bfseries\centering Actual \\ temperature \\ ($^{\circ}$F)}
{
\renewcommand\arraystretch{2}
\begin{tabular}{|>{\columncolor{green!10}}c*{6}{|c}|}
\multicolumn{7}{c}{\bfseries Relative hunidity (\%)} \\
\hline
\rowcolor{green!10}\backslashbox{$T$}{$h$} & 20  & 30 & 40 & 50 & 60 & 70 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
\end{tabular}
}

\end{document}


If you want to center the table, you can use a table environment (if you want to treat the object as a floating object), or a minipage (if no flotation is desired), and \centering:

\begin{table}
\centering
\parbox{2.2cm}{\bfseries\centering Actual \\ temperature \\ ($^{\circ}$F)}
{
\renewcommand\arraystretch{2}
\begin{tabular}{|>{\columncolor{green!10}}c*{6}{|c}|}
\multicolumn{7}{c}{\bfseries Relative hunidity (\%)} \\
\hline
\rowcolor{green!10}\backslashbox{$T$}{$h$} & 20  & 30 & 40 & 50 & 60 & 70 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
\end{tabular}
}
\end{table}

\noindent\begin{minipage}{\linewidth}
\centering
\parbox{2.2cm}{\bfseries\centering Actual \\ temperature \\ ($^{\circ}$F)}
{
\renewcommand\arraystretch{2}
\begin{tabular}{|>{\columncolor{green!10}}c*{6}{|c}|}
\multicolumn{7}{c}{\bfseries Relative hunidity (\%)} \\
\hline
\rowcolor{green!10}\backslashbox{$T$}{$h$} & 20  & 30 & 40 & 50 & 60 & 70 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
80 & 78 & 79 & 80 & 81 & 82 & 83 \\
\hline
\end{tabular}
}
\end{minipage}

• I am not very familiar with Tikz. I use MacTeX – Hawk Apr 25 '13 at 2:21
• @jak TikZ is part of every major LaTeX distribution; in particular, TikZ is available in an updated MacTeX installation. – Gonzalo Medina Apr 25 '13 at 2:23
• I am not very familiar with Tikz, but I changed the rotation to 180 and my text gets overlapped. How do I fix this – Hawk Apr 25 '13 at 2:33
• @jak How exactly do you want the text to appear? Did you see the second code of my answer? – Gonzalo Medina Apr 25 '13 at 2:41
• Yes I saw your second code. You mirroed the words. I want to be able to see the words horizontally – Hawk Apr 25 '13 at 2:42