I am trying to draw a SWOT matrix using TikZ. Clearly the procedure that I present in the MWE is not optimized. Also the text (namely on the left side) is not correctly aligned.
\documentclass[10pt]{standalone}
\usepackage{times}
\usepackage{tikz}
\usetikzlibrary{fit}
\usetikzlibrary{calc}
\usetikzlibrary{intersections}
\usetikzlibrary{backgrounds}
\tikzset{desc/.style={outer sep=0pt,inner sep=0pt,text centered,font=\scriptsize,fill=black!10}}
\newcommand{\texta}{Helpful\\ \tiny (to achieve the objective)}
\newcommand{\textb}{Harmful\\ \tiny (to achieve the objective)}
\newcommand{\textc}{\rotatebox[origin=r]{90}{\shortstack{Internal origin\\ \tiny (product\slash company attributes)}}}
\newcommand{\textd}{\rotatebox[origin=r]{90}{\shortstack{External origin\\ \tiny (environment\slash market attributes)}}}
\begin{document}
\begin{tikzpicture}[x=3cm,y=3cm]
\coordinate (c1) at (0,0);
\coordinate (c2) at (2,0);
\coordinate (c3) at (2,2);
\coordinate (c4) at (0,2);
\coordinate (c5) at ($(c1)!0.5!(c2)$);
\coordinate (c6) at ($(c2)!0.5!(c3)$);
\coordinate (c7) at ($(c3)!0.5!(c4)$);
\coordinate (c8) at ($(c4)!0.5!(c1)$);
\coordinate (c8) at ($(c4)!0.5!(c1)$);
\draw (c1) --+ (c2) --+ (c3) --+ (c4) -- cycle;
\path [name path=c5--c7,draw] (c5) -- (c7);
\path [name path=c6--c8,draw] (c6) -- (c8);
\coordinate [name intersections={of=c5--c7 and c6--c8,by=c9}];
\node [outer sep=0pt,inner sep=0pt,fit={(c8) (c9) (c7) (c4)}] (S){Strengths};
\node [outer sep=0pt,inner sep=0pt,fit={(c9) (c6) (c3) (c7)}] (W){Weaknesses};
\node [outer sep=0pt,inner sep=0pt,fit={(c1) (c5) (c9) (c8)}] (O){Opportunities};
\node [outer sep=0pt,inner sep=0pt,fit={(c5) (c2) (c6) (c9)}] (T){Threats};
%%%%
\coordinate[yshift=1cm] (u4) at (S.north west);
\coordinate[yshift=1cm] (u3) at (W.north east);
\coordinate[yshift=1cm] (u7) at (W.north west);
\draw (c4) -- (u4) -- (u3) -- (c3);
\draw (c7) -- (u7);
\begin{pgfonlayer}{background}
\node [desc,fit={(c4) (u4) (u7) (c7)}] {\texta};
\node [desc,fit={(c7) (u7) (u3) (c3)}] {\textb};
\end{pgfonlayer}{background}
%%%%
\coordinate[xshift=-1cm] (l4) at (S.north west);
\coordinate[xshift=-1cm] (l8) at (S.south west);
\coordinate[xshift=-1cm] (l1) at (O.south west);
\draw (c4) -- (l4) -- (l1) -- (c1);
\draw (c8) -- (l8);
\begin{pgfonlayer}{background}
\node [desc,fit={(c4) (l4) (l8) (c8)}] {\textc};
\node [desc,fit={(c8) (l8) (l1) (c1)}] {\textd};
\end{pgfonlayer}
\end{tikzpicture}
\end{document}
TikZ
because I wanted to have full control of all cells in terms of width and height. In tabular environment I can usep{}
column type to have a fixed width, but for the height I would probably need to use a minipage for each cell of that table, which I am not quite sure if it is desirable.