2

How can we create a table as in the following picture?

enter image description here

Here is what I have done.

\documentclass[10pt,notheorems]{beamer}

\usepackage{tikz}
\usetikzlibrary{babel,decorations.markings,positioning,shapes,arrows}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\hypersetup{bookmarksdepth=4,bookmarksnumbered=true,bookmarksopen=true}

\definecolor{mc1}{rgb}{0.368417,0.506779,0.709798}

\usetheme{Warsaw}
\usecolortheme{seahorse}

\setbeamertemplate{theorems}[numbered]
\setbeamertemplate{caption}[numbered]

\begin{document}

\begin{frame}[fragile]{Table of intervals}{}

\begin{table}
  \centering
  \begin{tabular}{ccc}
    Notation & Set description & Picture \\ \hline
    $(a,b)$ & $\{x:\ a<x<b\}$ &
    \begin{tikzpicture}
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1.1:2.9]{0};
        \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} \\
    $[a,b]$ & $\{x:\ a\leq{}x\leq{}b\}$ &
    \begin{tikzpicture}
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1:3]{0};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} \\
    $[a,b)$ & $\{x:\ a\leq{}x<b\}$ &
    \begin{tikzpicture}
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1:2.9]{0};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} \\
    $\vdots$ & $\vdots$ & $\vdots$ \\
    $(-\infty,\infty)$ & $\mathbb{R}$ &
    \begin{tikzpicture}
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[->,very thick,color=mc1,smooth,samples=2,domain=0:4]{0};
      \end{axis}
    \end{tikzpicture}
  \end{tabular}
  \caption{Table of intervals}\label{tbltoi}
\end{table}

\end{frame}

\end{document}

enter image description here

How can I align the pictures properly? I would be very glad to hear suggestions.

Cragfelt
  • 4,005
bkarpuz
  • 2,437
  • 3
    you don't say what you tried, but just make a table with tabular with math mode for the math cells and tikzpicture for the tikz – David Carlisle Sep 01 '17 at 11:58
  • @DavidCarlisle I have now put what I have done. – bkarpuz Sep 01 '17 at 12:30
  • You can take a look at a similar table in this question and get some ideas or inputs. – Cragfelt Sep 01 '17 at 12:34
  • 1
    Suggestion: put this code on open points of intervals\addplot[thick,color=mc1,fill=white,only marks,mark=*]. I'd add left arrow side to axis as well. – Cragfelt Sep 01 '17 at 12:47
  • When I use ’fill=white only’ and have the tikz picture in an example environment, then I would expect a green empty dot instead of white. This is why I prefer ’fill opacity=0’. – bkarpuz Sep 03 '17 at 12:04

2 Answers2

3

You were almost there, just shift the baselines of the tikz a bit:

enter image description here

\documentclass[10pt,notheorems]{beamer}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{babel,decorations.markings,positioning,shapes,arrows}

\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\hypersetup{bookmarksdepth=4,bookmarksnumbered=true,bookmarksopen=true}

\definecolor{mc1}{rgb}{0.368417,0.506779,0.709798}

\usetheme{Warsaw}
\usecolortheme{seahorse}

\setbeamertemplate{theorems}[numbered]
\setbeamertemplate{caption}[numbered]

\begin{document}

\begin{frame}[fragile]{Table of intervals}{}

\begin{table}
  \centering
   \addtolength\extrarowheight{2pt}
  \begin{tabular}{ccc}
    Notation & Set description & Picture \\ \hline
    $(a,b)$ & $\{x:\ a<x<b\}$ &
    \begin{tikzpicture}[baseline=3pt]
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1.1:2.9]{0};
        \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} \\
    $[a,b]$ & $\{x:\ a\leq{}x\leq{}b\}$ &
    \begin{tikzpicture}[baseline=3pt]
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1:3]{0};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} \\
    $[a,b)$ & $\{x:\ a\leq{}x<b\}$ &
    \begin{tikzpicture}[baseline=3pt]
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1:2.9]{0};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,fill opacity=0,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} \\
    $\vdots$ & $\vdots$ & $\vdots$ \\
    $(-\infty,\infty)$ & $\mathbb{R}$ &
    \begin{tikzpicture}[baseline=3pt]
      \begin{axis}[
          %scaled ticks=false,
          axis lines=middle,
          %axis line style={draw=none},
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$a$,$b$},
          y axis line style={draw=none},
          ytick=\empty,
          %yticklabels={}
      ]
        \addplot[->,very thick,color=mc1,smooth,samples=2,domain=0:4]{0};
      \end{axis}
    \end{tikzpicture}
  \end{tabular}
  \caption{Table of intervals}\label{tbltoi}
\end{table}

\end{frame}

\end{document}
David Carlisle
  • 757,742
1

I have taken the code from David Carlisle and made some changes to get the best alignment of the rows (included a phantom row and accomodated the rows and columns with some vertical and horizontal alignment specifications). Also I added some details on the TikZ pictures involved (void points, two-headed arrows in axis, Region instead of Picture, aligning the nodes a and b). And finally, made the animation on every row.

\documentclass[10pt,notheorems]{beamer}
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{fit,babel,decorations.markings,positioning,shapes,arrows,arrows.meta} % <-- Added arrows.meta
\usepackage{pgfplots}
\pgfplotsset{compat=newest,myaxis/.style={axis line style={<->, {latex'-latex'} }} }  % <-- Added the left arrow head

\hypersetup{bookmarksdepth=4,bookmarksnumbered=true,bookmarksopen=true}
\definecolor{mc1}{rgb}{0.368417,0.506779,0.709798}

\usetheme{Warsaw}
\usecolortheme{seahorse}
\setbeamertemplate{theorems}[numbered]
\setbeamertemplate{caption}[numbered]

\newcolumntype{M}[1]{>{\centering\arraybackslash}m{#1}} % <-- Added
\newcolumntype{N}{@{}m{0pt}@{}} % <-- Added


\begin{document}

\begin{frame}[fragile]{Table of intervals}{}

\begin{table}[hb]
\renewcommand{\arraystretch}{1.5} % <-- Added
\addtolength\extrarowheight{2pt}
  \centering
  \begin{tabular}{M{1.5cm}M{3cm}M{4cm}N} % <-- Changed
    \bf Notation & \bf Set description & \bf Region & \\ \hline \noalign{\pause} % <-- Changed
    & & & \\[-2em]              % <-- Added
    $(\,a,b\,)$ & $\{x:\ a<x<b\}$ &
    \begin{tikzpicture}[baseline=5pt]
      \begin{axis}[
          axis lines=middle,
          myaxis,               % <-- Added
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$\mathstrut a$,$\mathstrut b$},  % <-- Changed
          y axis line style={draw=none},
          ytick=\empty,
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1.1:2.9]{0};
        \addplot[thick,color=mc1,fill=white,only marks,mark=*] coordinates{(1,0)}; % <-- Changed
        \addplot[thick,color=mc1,fill=white,only marks,mark=*] coordinates{(3,0)}; % <-- Changed
      \end{axis}
    \end{tikzpicture} & \\ \noalign{\pause}
    $[\,a,b\,]$ & $\{x:\ a\leq{}x\leq{}b\}$ &
    \begin{tikzpicture}[baseline=5pt]
      \begin{axis}[
          axis lines=middle,
          myaxis,               % <-- Added
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$\mathstrut a$,$\mathstrut b$}, % <-- Changed
          y axis line style={draw=none},
          ytick=\empty,
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1:3]{0};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(3,0)};
      \end{axis}
    \end{tikzpicture} & \\ \noalign{\pause}
    $[\,a,b\,)$ & $\{x:\ a\leq{}x<b\}$ &
    \begin{tikzpicture}[baseline=5pt]
      \begin{axis}[
          axis lines=middle,
          myaxis,               % <-- Added
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$\mathstrut a$,$\mathstrut b$}, % <-- Changed
          y axis line style={draw=none},
          ytick=\empty,
      ]
        \addplot[very thick,color=mc1,smooth,samples=2,domain=1:2.9]{0};
        \addplot[thick,color=mc1,only marks,mark=*] coordinates{(1,0)};
        \addplot[thick,color=mc1,fill=white,only marks,mark=*] coordinates{(3,0)}; % <-- Changed
      \end{axis}
    \end{tikzpicture} & \\ \noalign{\pause}
    $\vdots$ & $\vdots$ & $\vdots$ \\ \noalign{\pause}
    $(\,-\infty,\infty\,)$ & $\mathbb{R}$ &
    \begin{tikzpicture}[baseline=5pt]
      \begin{axis}[
          axis lines=middle,
          width=50mm,
          height=20mm,
          xmin=0,xmax=4,
          ymin=-1,ymax=1,
          xtick={1,3},
          xticklabels={$\mathstrut a$,$\mathstrut b$}, % <-- Changed
          y axis line style={draw=none},
          ytick=\empty,
      ]
        \addplot[<->,very thick,color=mc1,smooth,samples=2,domain=0:4]{0};
      \end{axis}
        \end{tikzpicture}
      \end{tabular}
      \caption{Table of intervals}\label{tbltoi}
    \end{table}
\end{frame}

\end{document}

(By the way, I converted the PDF into GIF with an online tool exposed in my recent answer on this question)

enter image description here

Cragfelt
  • 4,005
  • I decided to take the graphics in the table from a pdf file of a book. I believe, in this case, your code may help me more. I will go through it now in details. – bkarpuz Sep 03 '17 at 19:36
  • Oh, I see. Well I'm glad it can help you. Do not hesitate to ask me later for any detail if necessary. Good luck! – Cragfelt Sep 03 '17 at 19:44