1

I'm new to using latex and I tried to look at some related questions here, but unfortunately I didn't understand how to apply suggested solutions to my problem yet.

So I got this .tex code

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{amsmath}
\usepackage{abraces}
\usepackage{array} % for "\extrarowheight" macro \usepackage[skip=0.333\baselineskip]{caption}

\begin{document}

\newcommand\red{\colorbox{red!80}{\color{red!80}\textbf{1}}} 
\newcommand\yellow{\colorbox{yellow!80}{\color{yellow!80}\textbf{1}}} 
\newcommand\green{\colorbox{green!80}{\color{green!80}\textbf{1}}} 
\newcommand\blue{\colorbox{blue!80}{\color{blue!80}\textbf{1}}} 
\newcommand\magenta{\colorbox{magenta!80}{\color{magenta!80}\textbf{1}}}

Zerlegung von: Elementfixierung mit fester Position\label{Tab1}

\begin{equation}\label{eq:appendrow} 
\begin{array}{ccccccccccc}
\multicolumn{6}{c}{\overbrace{}^{6* \binom{1}{1} red}}& \multicolumn{3}{c}{\overbrace{}^{ 3* \binom{1}{1} yellow}}& \multicolumn{1}{c}{\overbrace{}^{1* \binom{1}{1} green}} \\
\red & \red & \red & \red & \red & \red & \yellow & \yellow & \yellow & \green \\
\yellow & \yellow & \yellow & \green & \green & \blue & \green & \green & \blue & \blue \\ 
\green & \blue & \magenta & \blue & \magenta & \magenta & \blue & \magenta & \magenta & \magenta \\
\multicolumn{6}{c}{\underbrace{}{\binom{4}{2}}}& \multicolumn{3}{c}{\underbrace{}{\binom{3}{2}}}& \multicolumn{1}{c}{\underbrace{}_{\binom{3}{3}}}
\end{array}
\end{equation}

\end{document}

Rendering of my code Here I am using a colorboxed array with entries "1" of the same color (sorry for the dirty hack the boxes were too small if the cells were empty) to create towers of colored blocks. I would like to show how you can divide and conquer the problem of strategyrecognition by breaking down the problem using the binomialcoefficient property (n over k) = (n-1 over k-1) + (n-1 over k).

I would like the first under- and overbraces to span over the first 6 columns, then second braces to span over the next 3 columns and the last braces to span only over the last column.

So far if I tried to use \multicolumn with several of my color-commands, I always got a huge wall of compile errors. Could you tell me how to do what I intend to do please?

1

Add suitable phantoms. With expl3 we can achieve it with a less painful syntax.

\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{amsmath}
\usepackage{abraces}
\usepackage{array} % for "\extrarowheight" macro 
\usepackage[skip=0.333\baselineskip]{caption}

\usepackage{xparse}

\ExplSyntaxOn
\NewExpandableDocumentCommand{\arrayoverbrace}{mm}
 {
  \multicolumn{#1}{c}
   {
    \overbrace
     {
      \hphantom
       {
        \begin{array}{*{#1}{c}}
        \red\prg_replicate:nn{#1-1}{& \red}
        \end{array}
       }
     }\sp{#2}
   }
 }
\NewExpandableDocumentCommand{\arrayunderbrace}{mm}
 {
  \multicolumn{#1}{c}
   {
    \underbrace
     {
      \hphantom
       {
        \begin{array}{*{#1}{c}}
        \red\prg_replicate:nn{#1-1}{& \red}
        \end{array}
       }
     }\sb{#2}
   }
 }
\ExplSyntaxOff

\newcommand\red{\colorbox{red!80}{\color{red!80}\textbf{1}}} 
\newcommand\yellow{\colorbox{yellow!80}{\color{yellow!80}\textbf{1}}} 
\newcommand\green{\colorbox{green!80}{\color{green!80}\textbf{1}}} 
\newcommand\blue{\colorbox{blue!80}{\color{blue!80}\textbf{1}}} 
\newcommand\magenta{\colorbox{magenta!80}{\color{magenta!80}\textbf{1}}}

\begin{document}

Zerlegung von: Elementfixierung mit fester Position\label{Tab1}

\begin{equation}\label{eq:appendrow} 
\begin{array}{ccccccccccc}
\arrayoverbrace{6}{6* \binom{1}{1} \text{ red}}&
\arrayoverbrace{3}{3* \binom{1}{1} \text{ yellow}}&
\arrayoverbrace{1}{1* \binom{1}{1} \text{ green}} \\
\red & \red & \red & \red & \red & \red & \yellow & \yellow & \yellow & \green \\
\yellow & \yellow & \yellow & \green & \green & \blue & \green & \green & \blue & \blue \\ 
\green & \blue & \magenta & \blue & \magenta & \magenta & \blue & \magenta & \magenta & \magenta \\[-1ex]
\arrayunderbrace{6}{\binom{4}{2}}&
\arrayunderbrace{3}{\binom{3}{2}}&
\arrayunderbrace{1}{\binom{3}{3}}
\end{array}
\end{equation}

\end{document}

enter image description here

  • Thank you, this is wonderful. Any idea why the last tower in the group of 6 and 3 each is more apart from the others? While this wouldn't matter for my thesis, it's still a bit displeasing visually. – KainMorgen Mar 31 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.