2

I am trying to write some sort of scheme using nested left braces, the code compiles however is throwing errors, I guess I am not closing the braces (I do not want them to be closed, only need left braces) so the compiler complaints. How could I fix this issue? Thank you very much in advance.

\documentclass[11pt, tikz]{article}
\usepackage{answers}
\usepackage{setspace}
\usepackage{graphicx}
\usepackage{slashbox}
\usepackage{enumitem}
\usepackage[colorlinks]{hyperref}
\usepackage{multicol}
\usepackage{booktabs}
\usepackage{amsmath}
\usepackage{mathrsfs}
\usepackage[table,x11names]{xcolor}
\usepackage[margin=1in]{geometry}
\usepackage{float}
\usepackage{amsmath,amsthm,amssymb}
\usepackage[utf8]{inputenc}
\usepackage {tikz}
\usepackage{multicol}
\usetikzlibrary{trees}
\usepackage{tikz-timing}[2014/10/29]
\usetikztiminglibrary[rising arrows]{clockarrows}
\usetikzlibrary {positioning}
\usepackage{xcolor}
\definecolor {processblue}{cmyk}{0.96,0,0,0}
\usepackage{caption}
\usepackage{array}
\newcolumntype{?}{!{\vrule width 2pt}}
\usepackage[spanish, es-tabla]{babel}
\makeatletter
\renewcommand{\@seccntformat}[1]{}
\makeatother
\setlength\parindent{24pt}
\usepackage{forest}
\usetikzlibrary{arrows.meta}

\begin{document}
 
\[\text{Temperature}=\left\{
\begin{array}{ll}
\text{Hot}  &
\[\left\{
\begin{array}{ll}
\text{No: 2}  & \\
\text{Yes: 2} & \\
\end{array} \\
\text{Mild} &
\[\left\{
\begin{array}{ll}
\text{No: 2}  & \\
\text{Yes: 4} & \\
\end{array} \\
\text{Cool} & 
\[\left\{
\begin{array}{ll}
\text{No: 1}  & \\
\text{Yes: 3} & \\
\end{array} \\  
\end{array} 
\right. \]

\end{document}
1
  • If the contents could be not only maths : texdoc schemata. An example here.
    – Fran
    May 10, 2021 at 20:37

3 Answers 3

5

In my opinion, it is simpler to nest cases environments. Here is a possible code, with some layout improvements:

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
  \text{Temperature} = \begin{cases}
    \text{Hot} &
     \begin{cases}
        \text{No:} & 2\\
        \text{Yes:} & 2
      \end{cases} \\[2.5ex]
    \text{Mild} &
     \begin{cases}
        \text{No:} & 2 \\
        \text{Yes:} & 4
      \end{cases}\\[2.5ex]
    \text{Cool} &
      \begin{cases}
        \text{No:} & 1\\
        \text{Yes:} & 3
      \end{cases} %\\
  \end{cases}
\]

\end{document}

enter image description here

4

Correct. You have to close every opened \left-brace with an accompanying \right-brace within the same group. Here "brace" includes extensible braces like (, ), [, ], \{ and \} as well as the null delimiter ..

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}
 
\[
  \text{Temperature} = \left\{\begin{array}{ll}
    \text{Hot}  &
      \left\{\begin{array}{ll}
        \text{No: 2}  & \\
        \text{Yes: 2} & \\
      \end{array}\right. \\
    \text{Mild} &
      \left\{\begin{array}{ll}
        \text{No: 2}  & \\
        \text{Yes: 4} & \\
      \end{array}\right. \\
    \text{Cool} & 
      \left\{\begin{array}{ll}
        \text{No: 1}  & \\
        \text{Yes: 3} & \\
      \end{array}\right. \\  
  \end{array}\right.
\]

\end{document}
0
2

You shouldn't start \[ over and over again.

I present here a simpler syntax-wise code, at the expense of a not-so-easy definition.

\documentclass[11pt]{article}
\usepackage{amsmath,booktabs}

\newif\ifbtextinmath
\newenvironment{btext}[1]
 {% the conditional is initially false
  \btextinmathfalse
  % if btext is initiated in math mode, make the conditional true
  % otherwise start math mode
  \ifmmode\btextinmathtrue\else$\fi
  % left brace
  \left\{
  % start a tabular
  \begin{tabular}{#1}%
 }
 {% end the tabular
  \end{tabular}%
  % null delimiter
  \right.%
  % if the conditional is true, do nothing; otherwise end math mode
  \ifbtextinmath\else$\fi
 }

\begin{document}
 
\[
\text{Temperature}=
  \begin{btext}{@{}l@{\ }l@{}}
  Hot  &
    \begin{btext}{@{}l@{\ }l@{}}
      No: & 2 \\
      Yes: & 2
    \end{btext} \\
\addlinespace
  Mild &
    \begin{btext}{@{}l@{\ }l@{}}
      No: & 2 \\
      Yes: & 4
    \end{btext} \\
\addlinespace
  Cool &
    \begin{btext}{@{}l@{\ }l@{}}
      No: & 1 \\
      Yes: & 3
    \end{btext}
  \end{btext}
\]

\end{document}

The columns have been defined with no padding at the left and with a normal space between them. With booktabs facilities I added some vertical space between rows.

enter image description here

You must log in to answer this question.

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