3

I am wondering what is the best way to place floats directly across from a array or tabular environment. I want to get the graph to show on the right of the table of values. A picture is shown below along with a MWE.

\documentclass[12pt,letterpaper]{article}
\usepackage[margin=2.0cm]{geometry}
\usepackage{amsmath}

\begin{document}

$
\begin{array}{rr}
  -7.0 & 7.0 \\
  -6.0 & 0.067 \\
  -5.0 & -4.9 \\
  -4.0 & -7.7 \\
  -3.0 & -7.9 \\
  -2.0 & -2.9 \\
  -1.0 & 39. \\
   0 & 87. \\
   1.0 & 50. \\
   2.0 & 21. \\
   3.0 & 28. \\
   4.0 & 40. \\
   5.0 & 55. \\
   6.0 & 72. \\
   7.0 & 91.
\end{array}
$

\begin{figure}[h!]
\centering
\scalebox{0.5}{
\includegraphics{hx.pdf}
              }
\caption{Plot of the function \( h(x) \)}
\end{figure}

\end{document}

picture

3

If you want the caption to encompass only the graph, then something like this could be what you want:

\documentclass[12pt]{article}
\usepackage[margin=2.0cm]{geometry}
\usepackage[demo]{graphicx}
\usepackage{amsmath,caption}

\begin{document}

\begin{figure}
\centering
\hspace*{\fill}$
\begin{array}{rr}
  -7.0 & 7.0 \\
  -6.0 & 0.067 \\
  -5.0 & -4.9 \\
  -4.0 & -7.7 \\
  -3.0 & -7.9 \\
  -2.0 & -2.9 \\
  -1.0 & 39. \\
   0 & 87. \\
   1.0 & 50. \\
   2.0 & 21. \\
   3.0 & 28. \\
   4.0 & 40. \\
   5.0 & 55. \\
   6.0 & 72. \\
   7.0 & 91.
\end{array}
$\hfill
\begin{minipage}{.5\textwidth}
\centering
\includegraphics[width=.45\textwidth]{hx.pdf}
\caption{Plot of the function \( h(x) \)}
\end{minipage}\hspace*{\fill}
\end{figure}

\end{document}

Note the use of graphicx and its extended syntax, that avoids the \scalebox command (the demo option is just to produce the example without needing a file). Adjust to suit.

enter image description here

0

Include your array inside the figure:

\begin{figure}[h!]
\centering
$
\begin{array}{rr}
  -7.0 & 7.0 \\
  -6.0 & 0.067 \\
  -5.0 & -4.9 \\
 ..............
   7.0 & 91.
\end{array}
$
\qquad
\scalebox{0.5}{
\includegraphics{hx.pdf}
              }
\caption{Plot of the function \( h(x) \)}
\end{figure}

While you're at it, maybe you want to change that array into a tabular, and add a couple \hlines, and/or use the package booktabs.

  • This does it, but one thing. I am not looking for the figure caption to be underneath the table of values, just only right under the figure. – night owl Jan 30 '12 at 13:08
  • Then you probably want to have a look at the wrapfig package, and use the wrapfigure environment. – Koji Jan 30 '12 at 13:12

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.