6

I found this post with an awesome solution to create a SWOT-analysis using a table: SWOT Table - how to convert to an article?

This is the code snippet from the other post I used:

\documentclass[10pt,table]{article}
\usepackage{times}

\usepackage{array}
\usepackage{graphicx}
\usepackage{tikz}

\colorlet{helpful}{lime!70}
\colorlet{harmful}{red!30}
\colorlet{internal}{yellow!20}
\colorlet{external}{cyan!30}
\colorlet{S}{helpful!50!internal}
\colorlet{W}{harmful!50!internal}
\colorlet{O}{helpful!50!external}
\colorlet{T}{harmful!50!external}

\newcommand{\texta}{Helpful\par \tiny (to achieve the objective)}
\newcommand{\textb}{Harmful\par \tiny (to achieve the objective)}
\newcommand{\textcn}{\rotatebox[origin=c]{90}{\parbox[t]{3cm}{\centering Internal origin\\ \tiny (product\slash company attributes)\par}}}
\newcommand{\textdn}{\rotatebox[origin=c]{90}{\parbox[b]{3cm}{\centering External origin\\ \tiny (environment\slash market attributes)\par}}}

\newcommand{\texts}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering strength 1\par strength 2}}}
\newcommand{\textw}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering weakness 1\par weakness 2}}}
\newcommand{\texto}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering opportunity 1\par opportunity 2}}}
\newcommand{\textt}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering threat 1\par threat 2}}}


\newcommand{\back}[1]{\tikz\node[overlay,text=#1!60!black,font=\fontsize{60}{70}\selectfont](char) at (0,-0.1) {#1};}
\newcommand\mycolor[1]{\cellcolor{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
\begin{tabular}{c*{2}{C{0.2\textwidth}}}
                            &\cellcolor{helpful} \texta  & \cellcolor{harmful} \textb \\
\cellcolor{internal}\textcn & \mycolor{S}\back{S} \texts & \mycolor{W}\back{W} \textw \\
\cellcolor{external}\textdn & \mycolor{O}\back{O} \texto & \mycolor{T}\back{T} \textt
\end{tabular}

\end{document}

which results in this table: swot-matrix

Now I tried to adapt the code to show a SWOT-strategy. I would like to shift the inner four cells containing the big letters "S", "W", "O" and "T" including their text to the edge (replace external origin, internal origin, helpful and harmful), to create space to list the strategies as a solution to the previously determined attributes.

The scaffold would look like this...:

strategy

...but I would like to keep the backgroundcolors of the SWOT-matrix.

I tried to adapt the code to archieve this goal, but the cells deflated...

I highly appreciate if someone could show me a way how to get this!

4
  • I do not understand what you want to archive. Please explain in more details. (For me) Mar 3, 2016 at 22:17
  • @PeterEbelsberger I revised my explanation. I hope this is better understandable. Thanks for your feedback!
    – Eric
    Mar 4, 2016 at 8:53
  • ain't nobody can help me with this?
    – Eric
    Mar 6, 2016 at 13:55
  • 1
    I did try it but failed currently. Mar 6, 2016 at 17:19

2 Answers 2

4

Another solution with tcolorbox and raster. Every element is a tcolorbox with it's ability for any kind of content and all elements are arranged within a tcbraster element.

Note: This solution uses blankest style which is defined in tcolorbox 3.90 2016-02-29. Older versions will fail.

\documentclass[border=2mm]{standalone}
\usepackage[most]{tcolorbox}
\usepackage{enumitem}

\colorlet{helpful}{lime!70}
\colorlet{harmful}{red!30}
\colorlet{internal}{yellow!20}
\colorlet{external}{cyan!30}
\colorlet{S}{helpful!50!internal}
\colorlet{W}{harmful!50!internal}
\colorlet{O}{helpful!50!external}
\colorlet{T}{harmful!50!external}
\colorlet{SO}{S!50!O}
\colorlet{WO}{W!50!O}
\colorlet{ST}{S!50!T}
\colorlet{WT}{W!50!T}

\tcbset{
    mybox/.style 2 args={%
        enhanced,
%       blankest,
        sharp corners, notitle,
        before skip=6pt, after skip=6pt,
        watermark text=#1, frame hidden,
        colback=#2,
    },
    mybox/.default={mybox={A}{white}},
}

\newenvironment{myitemize}{%
    \begin{itemize}[leftmargin=0pt]}%
    {\end{itemize}}

\begin{document}
\begin{tcbraster}[raster columns=3, raster equal height, raster column skip=0mm, raster row skip=0mm, 
]
\begin{tcolorbox}[blankest]\end{tcolorbox}
\begin{tcolorbox}[mybox={S}{helpful!50!internal}]
\begin{myitemize}
\item A
\item B
\item C
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={W}{harmful!50!internal}]
\begin{myitemize}
\item A
\item B
\item C
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={O}{helpful!50!external}]
\begin{myitemize}
\item A
\item B
\item C
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={}{SO}]
\begin{myitemize}
\item A
\item B
\item C
\item D
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={}{WO}]
\begin{myitemize}
\item A
\item B
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={T}{harmful!50!external}]
\begin{myitemize}
\item A
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={}{ST}]
\begin{myitemize}
\item A
\item B
\end{myitemize}
\end{tcolorbox}
\begin{tcolorbox}[mybox={}{WT}]
\begin{myitemize}
\item A
\item B
\item CCCCCCCCCC
\end{myitemize}
\end{tcolorbox}
\end{tcbraster}
\end{document}

enter image description here

Update:

Instead of a tcbraster it's possible to use a tcbitemize which is not so much verbose. I've changed colors to made it similar to OP's model.

\documentclass[border=2mm]{standalone}
\usepackage[most]{tcolorbox}
\usepackage{enumitem}

\tcbset{
    mybox/.style 2 args={%
        enhanced,
        sharp corners, notitle,
        before skip=6pt, after skip=6pt,
        watermark text=#1, colframe=blue!70!black,
        colback=#2,
    },
    Sbox/.style={mybox={S}{blue!20}},
    Wbox/.style={mybox={W}{blue!20}},
    Tbox/.style={mybox={T}{blue!20}},
    Obox/.style={mybox={O}{blue!20}},
    Xbox/.style={mybox={}{white}},
}

\newenvironment{myitemize}{%
    \begin{itemize}[leftmargin=0pt]}%
    {\end{itemize}}

\begin{document}
\begin{tcbitemize}[raster columns=3, raster equal height, raster column skip=-.5mm, raster row skip=-.5mm, Xbox
]
\tcbitem[blankest]
\tcbitem[Sbox]
\begin{myitemize}
\item First item
\item Another item
\item One more item
\end{myitemize}
\tcbitem[Wbox]
\begin{myitemize}
\item A very long item which uses more than one line
\end{myitemize}
\tcbitem[Obox]
\begin{myitemize}
\item First item
\item Another item
\end{myitemize}
\tcbitem
\begin{myitemize}
\item Even if a row only contains a line, all boxes
have similar size
\end{myitemize}
\tcbitem
\begin{myitemize}
\item Only one item
\end{myitemize}
\tcbitem[Tbox]
\begin{myitemize}
\item One item
\end{myitemize}
\tcbitem
\begin{myitemize}
\item One item
\end{myitemize}
\tcbitem
\begin{myitemize}
\item One item
\end{myitemize}
\end{tcbitemize}
\end{document}

enter image description here

6
  • This example is not working for me. Are you sure that this is working? Mar 8, 2016 at 21:07
  • System respons to I do not know the key '/tcb/blankest' and I am going to ignore it. Mar 8, 2016 at 21:18
  • Do you use a recent version of tcolorbox?
    – Ignasi
    Mar 8, 2016 at 21:20
  • 2015/08/12 version 3.72 text color boxes used \listfiles and commented out all pieces between begin and end document. Mar 8, 2016 at 21:24
  • Last one is 3.90, but i think 3.80 could be enough
    – Ignasi
    Mar 8, 2016 at 21:37
2
+50

There are two issues:

  1. the table preamble needs to be changed to

     \begin{tabular}{*{3}{C{0.2\textwidth}}}
    

    giving you three columns of type C

  2. you need to add some appropriate vertical spacing, e.g. via an invisible rule

    \vrule height 35pt depth 35pt width 0pt
    

    In the code below I have packaged that in to a command \mystrut. You may need to adjust the dimensions if the new cells are big.

Here is a sample with your original code and then code for a second table.

Sample output

\documentclass[10pt,table]{article}
\usepackage{times}

\usepackage{array}
\usepackage{graphicx}
\usepackage{tikz}

\colorlet{helpful}{lime!70}
\colorlet{harmful}{red!30}
\colorlet{internal}{yellow!20}
\colorlet{external}{cyan!30}
\colorlet{S}{helpful!50!internal}
\colorlet{W}{harmful!50!internal}
\colorlet{O}{helpful!50!external}
\colorlet{T}{harmful!50!external}

\newcommand{\texta}{Helpful\par \tiny (to achieve the objective)}
\newcommand{\textb}{Harmful\par \tiny (to achieve the objective)}
\newcommand{\textcn}{\rotatebox[origin=c]{90}{\parbox[t]{3cm}{\centering Internal origin\\ \tiny (product\slash company attributes)\par}}}
\newcommand{\textdn}{\rotatebox[origin=c]{90}{\parbox[b]{3cm}{\centering External origin\\ \tiny (environment\slash market attributes)\par}}}

\newcommand{\texts}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering strength 1\par strength 2}}}
\newcommand{\textw}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering weakness 1\par weakness 2}}}
\newcommand{\texto}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering opportunity 1\par opportunity 2}}}
\newcommand{\textt}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering threat 1\par threat 2}}}


\newcommand{\back}[1]{\tikz\node[overlay,text=#1!60!black,font=\fontsize{60}{70}\selectfont](char) at (0,-0.1) {#1};}
\newcommand\mycolor[1]{\cellcolor{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}

\begin{document}
\begin{tabular}{c*{2}{C{0.2\textwidth}}}
                            &\cellcolor{helpful} \texta  & \cellcolor{harmful} \textb \\
\cellcolor{internal}\textcn & \mycolor{S}\back{S} \texts & \mycolor{W}\back{W} \textw \\
\cellcolor{external}\textdn & \mycolor{O}\back{O} \texto & \mycolor{T}\back{T} \textt
\end{tabular}

\newcommand{\mystrut}{\vrule height 35pt depth 35pt width 0pt}
\newcommand{\textos}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering
text os 1\par text os 2}}}
\newcommand{\textow}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering
text ow 1\par text ow 2}}}
\newcommand{\textts}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering
text ts 1\par text ts 2}}}
\newcommand{\texttw}{\makebox[0pt][c]{\parbox[t]{0.2\textwidth}{\centering
text tw 1\par text tw 2}}}

\begin{tabular}{*{3}{C{0.2\textwidth}}}
  \mystrut
  & \mycolor{S}\back{S} \texts & \mycolor{W}\back{W} \textw \\
  \mystrut  \mycolor{O}\back{O} \texto & \textos & \textow \\
  \mystrut  \mycolor{T}\back{T} \textt & \textts & \texttw
\end{tabular}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .