\documentclass[crop=true,tikz=true,convert={density=600},png=true]{standalone}[2016/06/02]

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\def\pgfsysdriver{pgfsys-tex4ht.def} % for svg output for html
%% → src: http://tex.stackexchange.com/questions/35145/maintaining-layout-of-tikz-diagrams-with-tex4ht-converting-as-single-pictures

\usetikzlibrary{calc}	%compute positions

\definecolor{outcolor}{HTML}{6600CC}
\definecolor{incolor}{HTML}{009933}

\newcommand{\inC}[1]{\textcolor{incolor}{#1}}
\newcommand{\outC}[1]{\textcolor{outcolor}{#1}}


\tikzstyle{nit}=[inner sep=2pt]	%'nit' for Node In Text
\tikzstyle{cell}=[nit,minimum width=5em,minimum height=4ex,shape=rectangle,yshift=2pt]
\tikzstyle{celll}=[nit,minimum width=5em,minimum height=5ex,shape=rectangle,yshift=-4pt]
\tikzstyle{c1}=[text width=7em,minimum height=2.5em,font=\bfseries]
\tikzstyle{l1}=[text width=5em,minimum height=2.5em,font=\bfseries]

\newcommand*\nit[3][nit]{%
  \tikz[baseline]{\node[anchor=base,#1](#3){#2};}%
}

\begin{document}
\begin{tikzpicture}[remember picture]
\begin{scope}
	\node[fill=white,outer sep=0pt,inner sep=0pt] (table) {
			\begin{tabular}{|c|c|c|c|c|}
				\hline
				\nit[l1]{transducer}{trans} 			& \nit[l1]{one-way}{1w}	& \nit[l1]{rotating}{rot}	& \nit[l1]{sweeping}{sw}& \nit[l1]{two-way}{2w}	\\\hline
				\nit[l1]{}{ftransp}						& \nit[l1]{}{f1wp}		& \nit[l1]{}{frotp}			& \nit[l1]{}{fswp}		& \nit[l1]{}{f2wp}		\\\hline\hline
				\nit[c1]{general}{gen}					& \nit[cell]{}{g1}		& \nit[cell]{}{gr}			& \nit[cell]{}{gs}		& \nit[cell]{}{g2}		\\\hline
				\nit[c1]{\inC{input} unary}{uin}		& \nit[cell]{}{u1}		& \nit[cell]{}{ur}			& \nit[cell]{}{us}		& \nit[cell]{}{u2}		\\\hline
				\nit[c1]{\outC{output} unary}{uout}	& \nit[cell]{}{1u}		& \nit[cell]{}{ru}			& \nit[cell]{}{su}		& \nit[cell]{}{2u}		\\\hline
				\nit[c1]{\inC{input} and\linebreak\outC{ouptut} unary}{uinout}
																& \nit[celll]{}{u1u}		& \nit[celll]{}{uru}			& \nit[celll]{}{usu}		& \nit[celll]{}{u2u} 	\\\hline
			\end{tabular}
		}
;
\end{scope}

%% Two-wayness in table…
\begin{scope}
	\path
		(ftransp)	node (ftrans)	{\includegraphics[page=2,width=5em]{../slides/2016-phd_defense/fig/transitransd.pdf}}
		(f1wp)		node (f1w)		{\includegraphics[page=1,width=5em]{../slides/2016-phd_defense/fig/two-wayness.pdf}}
		(frotp)		node (frot)		{\includegraphics[page=2,width=5em]{../slides/2016-phd_defense/fig/two-wayness.pdf}}
		(fswp)		node (fsw)		{\includegraphics[page=3,width=5em]{../slides/2016-phd_defense/fig/two-wayness.pdf}}
		(f2wp)		node (f2w)		{\includegraphics[page=4,width=5em]{../slides/2016-phd_defense/fig/two-wayness.pdf}}
		;
\end{scope}

%% General (nondeterministic) case
\begin{scope}
	\filldraw[thick,draw=black,fill=red!10,rounded corners]
		(gr.north)	-|
		(gr.east)	|-
		(us.north)	-|
		(us.east)	--	(su.east)	|-
		(u2u.north)	-|
		(u2u.east)	|-
		(u2u.south)	--	(uru.south)	-|
		(uru.west)	--	(gr.west)	|-
		(gr.north)
		;
	\filldraw[thick,draw=black,fill=yellow!40,rounded corners]
		(g1.north)	-|
		(g1.east)	--	(u1u.east)	|-
		(u1u.south)	-|
		(u1u.west)	--	(g1.west)	|-
		(g1.north)
		;
	\filldraw[thick,draw=black,fill=red!20,rounded corners]
		(gs.north)	-|
		(gs.east)	|-
		(gs.south)	-|
		(gs.west)	|-
		(gs.north)
		;
	\filldraw[thick,draw=black,fill,gray!30,rounded corners]
		(g2.north)	-|
		(g2.east)	--	(2u.east)	|-
		(2u.south)	-|
		(2u.west)	-- (g2.west)	|-
		(g2.north)
		;
	\path
		($(u1)!.5!(1u)$)	node[fill=none,draw=none]	(rat)		{\large\textsc{Rat}}
		($(ru)!.5!(su)$)	node[fill=none,draw=none]	(had)		{\large\textsc{Had}}
		(gs)					node[fill=none,draw=none]	(mhad)	{\large\textsc{MHad}}
		(u2)					node[fill=none,draw=none]	(nmhad)	{\large\textsc{MHad}}
		(nmhad.north west) edge (nmhad.south east)
		(nmhad.north east) edge (nmhad.south west)
		;
\end{scope}
\end{tikzpicture}
\end{document}
