5

I'm a beginner trying to do an brace inside a table, that is spanning multiple rows.

I assume the best way to achieve this is to do a two-row tabular environment, with an array environment for the lower line inside a multiple row. My code for doing this would be:

\begin{tabular}{ l c r }
$T=0$ & $T=1$ & $T=2$ \\
$-1$ & \multicolumn{2}{l}{$\left\{ 
\begin{array}{l l}
0 & R\\
1 & 0 \\
\end{array} \right.$} \\
\end{tabular}

Now, the result doesn't quite look like what I want, in the sense that the last column of the array block is not aligned with the last column of the table ( the $T=2$...). I could always push those a little bit left using ~~~, but is there an easier, more elegant way to have a similar result?

5

For this kind of stuff I find it best to use \tikzmark:

enter image description here

I was not sure where you wanted the brace, so the brace below might not be where you want it. But do the table as you normally would and get the text in the correct spot. Include a \tikzmark{<nameA>} and \tikzmark{<nameB>} to mark the location of the two end points of the brace. Then provide the name of those two marks to \DrawVerticalBrace to do the actual drawing.

Notes:

Code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathreplacing}

\newcommand{\tikzmark}[1]{%
  \tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {};}


\newcommand{\DrawVerticalBrace}[3][]{%
    % [<draw options>]{<mark>}{<mark>}
    \begin{tikzpicture}[overlay,remember picture]
        \draw[decorate,decoration={brace,amplitude=1ex}, #1] 
            ($(#3)+(0.0em,-0.5ex)$) to
            ($(#2)+(0.0em,+1.7ex)$);%
    \end{tikzpicture}%
}

\begin{document}
\begin{tabular}{ l c r }
   $T=0$ & $T=1$ & $T=2$ \\
   $-1$ & \multicolumn{2}{l}{$
   \begin{array}{l l}
     \tikzmark{top}0 & R\\
     \tikzmark{bot}1 & 0
   \end{array} $}
\end{tabular}
\DrawVerticalBrace[red, thick]{top}{bot}%
\end{document}

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.