2

I want to make a table with two columns:

  • on the left side, I want to put 2 aligned equations
  • on the right side, I want to put a graph.

In the following MCVE, the 2 equations are on the left side but with a huge unused space between them. I want to place those 2 equation just next to the graph

image

\documentclass[a4paper, 12pt]{book}
\usepackage{pgfplots, tikz}
\begin{document}
\begin{tabular}{cc}
    $
    \frac{u_{i+1,j} - u_{i,j}}{\Delta t} = \kappa \frac{u_{i,j-1} - 2u_{i,j} + u_{i,j+1}}{(\Delta x)^2}$ \\
    $u_{i+1,j} = u_{i,j} + \frac{\kappa \Delta t}{(\Delta x)^2}(u_{i,j-1} - 2u_{i,j} + u_{i,j+1})
    $
    &
    \begin{tikzpicture}
    [scale = 0.7]
    %[scale = 0.7, every node/.style={scale = 0.7}]
    % Draw axes
    \draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
    |- (5,0) node (xaxis) [right] {$x$};

    \coordinate (c) at (2,2);
    \fill[red] (c) circle (3pt);
    \draw[dashed] (yaxis |- c) node[left] {$\scriptstyle{i}$}
    -| (xaxis -| c) node[below] {$\scriptstyle{j-1}$};

    \coordinate (d) at (3,2);
    \fill[red] (d) circle (3pt);
    \draw[dashed] (yaxis |- d) node[left] {$\scriptstyle{i}$}
    -| (xaxis -| d) node[below] {$\scriptstyle{j}$};

    \coordinate (d) at (3,3);
    \fill[red] (d) circle (3pt);
    \draw[dashed] (yaxis |- d) node[left] {$\scriptstyle{i+1}$}
    -| (xaxis -| d) node[below] {$\scriptstyle{j}$};

    \coordinate (d) at (4,2);
    \fill[red] (d) circle (3pt);
    \draw[dashed] (yaxis |- d) node[left] {$\scriptstyle{i}$}
    -| (xaxis -| d) node[below] {$\scriptstyle{j+1}$};

    \draw [thin, gray] (0,0) grid (5,5);
    \end{tikzpicture}\\
\end{tabular}
\end{document}
3

I propose this somution with the equations inserted in a gathered environment,, and a \raisebox for the graph:

\documentclass[a4paper, 12pt]{book}
\usepackage{pgfplots, tikz}
\usepackage{mathtools }

\begin{document}

\begin{tabular}{cc}
  \leavevmode $ \begin{gathered}
    \frac{u_{i+1,j} - u_{i,j}}{\Delta t} = \kappa \frac{u_{i,j-1} - 2u_{i,j} + u_{i,j+1}}{(\Delta x)^2} \\
    u_{i+1,j} = u_{i,j} + \frac{\kappa \Delta t}{(\Delta x)^2}(u_{i,j-1} - 2u_{i,j} + u_{i,j+1})
  \end{gathered} $
    &
    \raisebox{-0.5\height}{\begin{tikzpicture}
    [scale = 0.7]
    %[scale = 0.7, every node/.style={scale = 0.7}]
    % Draw axes
    \draw [<->,thick] (0,5) node (yaxis) [above] {$y$}
    |- (5,0) node (xaxis) [right] {$x$};

    \coordinate (c) at (2,2);
    \fill[red] (c) circle (3pt);
    \draw[dashed] (yaxis |- c) node[left] {$\scriptstyle{i}$}
    -| (xaxis -| c) node[below] {$\scriptstyle{j-1}$};

    \coordinate (d) at (3,2);
    \fill[red] (d) circle (3pt);
    \draw[dashed] (yaxis |- d) node[left] {$\scriptstyle{i}$}
    -| (xaxis -| d) node[below] {$\scriptstyle{j}$};

    \coordinate (d) at (3,3);
    \fill[red] (d) circle (3pt);
    \draw[dashed] (yaxis |- d) node[left] {$\scriptstyle{i+1}$}
    -| (xaxis -| d) node[below] {$\scriptstyle{j}$};

    \coordinate (d) at (4,2);
    \fill[red] (d) circle (3pt);
    \draw[dashed] (yaxis |- d) node[left] {$\scriptstyle{i}$}
    -| (xaxis -| d) node[below] {$\scriptstyle{j+1}$};

    \draw [thin, gray] (0,0) grid (5,5);
    \end{tikzpicture}}\\
\end{tabular}

\end{document} 

enter image description here

| improve this answer | |
  • Many thanks @Bernard. Is it possible to alignt the 2 equations? – ecjb Jan 1 '19 at 16:54
  • Yes: replace gathered with aligned and add the ampersands for the alignment points. Personally I find it better-looking with gathered. Or maybe aligned on the left? – Bernard Jan 1 '19 at 17:00

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.