[Tex/LaTex] How to make formula in cases environment and a tikz figure side by side

casesfloatstablestikz-pgf

I am trying to put some formulas in cases environment in equation* environment and a tikz figure side by side like this pic:

what I want

However, I used the way in this How to put an algorithm and a tikz drawing (objects of different type) side-by-side in the same float environment?, and I got this:

what I get

How can I adjust this?

Code:

\documentclass{article}

%\usepackage{xeCJK}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgf, tikz}
\usepackage{pgfplots}
\usepackage{caption}
\usepackage{subcaption}

\begin{document}
    Hello, world!
\begin{figure}[!h]
    \begin{subfigure}[b]{.5\linewidth}
    \centering
        \begin{equation*}
        \begin{cases}
        f(\sqrt{-\frac{a}{3}}) &< 0\\
        f(0) &> 0\\
        f(1) &< 0
        \end{cases}
        \end{equation*}
    \end{subfigure}

    \begin{subfigure}[b]{.5\linewidth}
    \centering
        \begin{tikzpicture}[scale = 0.5]
        \begin{axis}
        \addplot {x};
        \end{axis}
        \end{tikzpicture}
    \subcaption*{This plot shows us that ...}
    \end{subfigure}
\end{figure}
\end{document}

Best Answer

You don't need figure at all costs: if this is to be in an equation* environment, use it.

The simplest way I see is using a two column tabular, with m type columns.

\documentclass{article}

\usepackage{array}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{pgf, tikz}
\usepackage{pgfplots}

\usepackage{lipsum}

\begin{document}

\lipsum*[2]
\begin{equation*}
\begin{tabular}{
  @{}
  m{.5\textwidth}
  @{}
  m{.5\textwidth}
  @{}
}
\centering
$\displaystyle
\begin{cases}
  f(\sqrt{-\frac{a}{3}}) &< 0\\
  f(0) &> 0\\
  f(1) &< 0
\end{cases}
$
&
\centering
  \begin{tikzpicture}[scale = 0.5]
  \begin{axis}
  \addplot {x};
  \end{axis}
  \end{tikzpicture}
\tabularnewline
&
This plot shows us that something happens
and we're very happy about it
\end{tabular}
\end{equation*}
\lipsum[3]

\end{document}

enter image description here

Related Question