0

I'm trying to adapt this SWOT table example to my needs. Everything is fine except two issues which I'm unable to solve:

  • Re-centering the header text horizontally and vertically after removing some text from the example. I've played with \tcbset parameters, but I can't find a way to recenter both headers
  • Removing the enumerate indentation. I've tried with [leftmargin=*], but in this case the code doesn't produce the desirable output.

My code at this moment is the following:

\documentclass[10pt]{article}
\usepackage{times}
\usepackage[most]{tcolorbox}
\usepackage{lipsum}

\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}
\newcommand{\textb}{Harmful}
\newcommand{\textcn}{\rotatebox[origin=c]{90}{\parbox[t]{3cm}{\centering Internal origin\\}}}
\newcommand{\textdn}{\rotatebox[origin=c]{90}{\parbox[b]{3cm}{\centering External origin\\}}}

\newcommand{\texts}{strength 1\par strength 2}
\newcommand{\textw}{weakness 1\par weakness 2}
\newcommand{\texto}{opportunity 1\par opportunity 2}
\newcommand{\textt}{threat 1\par threat 2}

\tcbset{swotbox/.style={size=normal, boxrule=0pt,
            colback=#1, watermark text=#1, width=.5\linewidth-5mm},
        header/.style={size=normal, boxrule=0pt, width=.5\linewidth-5mm, colback=#1, valign=center, halign=center},
        firstcol/.style={header=#1, width=1cm}
        }


\begin{document}

\begin{tcbitemize}[raster columns=3, raster rows=3, enhanced, sharp corners, raster equal height=rows, raster force size=false, raster column skip=0pt, raster row skip = 0pt]

%Empty corner and two headers
\tcbitem[blankest, width=1cm]
\tcbitem[header = helpful]
\texta
\tcbitem[header = harmful]
\textb

%First row
\tcbitem[firstcol = internal]
\textcn
\tcbitem[swotbox = S]
\begin{enumerate}
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}
\tcbitem[swotbox = W]
\begin{enumerate}
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}

%Second row
\tcbitem[firstcol = external]
\textcn
\tcbitem[swotbox=O]
\begin{enumerate}
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}
\tcbitem[swotbox=T]
\begin{enumerate}
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}
\end{tcbitemize}

\end{document}

 output example

4
  • Regarding [leftmargin=*]: Did you also add the enumitem package to your preamble?
    – leandriis
    Jan 11, 2020 at 15:57
  • Yes, I add. The produced result is the same with/without enumitem. Jan 11, 2020 at 15:59
  • Could you clarify what you mean with "Removing the enumerate indentation."?
    – leandriis
    Jan 11, 2020 at 16:01
  • I just want to flushleft the items inside the swot box. I'm trying to put an image in the post to illustrate better the request. thanks. Jan 11, 2020 at 16:04

1 Answer 1

1

The problem with the alignment in left column is due to boxsep value. This box is not enough wide to respect the boxep (default=1mm) and the rotated parbox height. If you fix a boxsep=0pt, the effect of halign=center is seen.

The second problem about item list alignment can be solved with enumitem package and applying labelindent=\parindent,leftmargin=* to desired itemize lists.

\documentclass[10pt]{article}
\usepackage{times}
\usepackage[most]{tcolorbox}
\usepackage{enumitem}
\usepackage{lipsum}

\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}
\newcommand{\textb}{Harmful}
\newcommand{\textcn}{\rotatebox{90}{\parbox[c]{3cm}{\centering Internal origin}}}
\newcommand{\textdn}{\rotatebox{90}{\parbox[c]{3cm}{\centering External origin}}}

\newcommand{\texts}{strength 1\par strength 2}
\newcommand{\textw}{weakness 1\par weakness 2}
\newcommand{\texto}{opportunity 1\par opportunity 2}
\newcommand{\textt}{threat 1\par threat 2}

\tcbset{swotbox/.style={size=normal, boxrule=0pt,
            colback=#1, watermark text=#1, width=.5\linewidth-5mm},
        header/.style={size=normal, boxrule=0pt, width=.5\linewidth-5mm, colback=#1, valign=center, halign=center},
        firstcol/.style={header=#1, width=1cm, boxsep=0mm}
        }


\begin{document}

\begin{tcbitemize}[raster columns=3, raster rows=3, enhanced, sharp corners, raster equal height=rows, raster force size=false, raster column skip=0pt, raster row skip = 0pt]

%Empty corner and two headers
\tcbitem[blankest, width=1cm]
\tcbitem[header = helpful]
\texta
\tcbitem[header = harmful]
\textb

%First row
\tcbitem[firstcol = internal]
\textcn
\tcbitem[swotbox = S]
\begin{enumerate}[labelindent=\parindent,leftmargin=*]
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}
\tcbitem[swotbox = W]
\begin{enumerate}[labelindent=\parindent,leftmargin=*]
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}

%Second row
\tcbitem[firstcol = external]
\textdn
\tcbitem[swotbox=O]
\begin{enumerate}[labelindent=\parindent,leftmargin=*]
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}
\tcbitem[swotbox=T]
\begin{enumerate}[labelindent=\parindent,leftmargin=*]
    \item Item 1
    \item Item 2
    \item Item 3
\end{enumerate}
\end{tcbitemize}

\end{document}

enter image description here

1
  • Your solutions are perfect! This is exactly what I was trying to achieve. Regarding the boxsep parameter, I wasn't aware of the default value of 1mm, but it makes perfect sense to reduce it. Thanks a lot for your help. Jan 13, 2020 at 16:03

You must log in to answer this question.

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