Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
Welcome to TeX.sx! –  Kurt Mar 29 '13 at 20:23

1 Answer 1

up vote 2 down vote accepted

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}
share|improve this answer
    
That's more than I expected, thank you. –  Mathieu B. Mar 31 '13 at 2:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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