Graphics, Figures & TablesUsing figures in an equation?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Spacecookies
Posts: 4
Joined: Thu Jul 15, 2010 10:41 pm

Using figures in an equation?

Post by Spacecookies »

Hi all,

LaTeX newbie here. For a paper I'm writing, I'd like to make a figure that combines images and math. I haven't been able to find an example of this, so I've tried to roll my own:

Code: Select all

\begin{figure}[htb]
  \centering
  \[
  Min\left(
  \includegraphics[width=.25\linewidth]{figures/fig_inputX}
  ,
  \includegraphics[width=.25\linewidth]{figures/fig_inputY}
  \right) = 
  \includegraphics[width=.25\linewidth]{figures/fig_output}
  \]
  \caption{\label{fig:fig_image_equation}
  This figure shows a function that takes 2 images as arguments, and returns an image.}
\end{figure}
To my surprise, it almost works (see attached), but the formatting needs some help. How can I get rid of that unnecessary whitespace below the images, and center everything vertically?

Thanks for any help!
Attachments
min.jpg
min.jpg (30.11 KiB) Viewed 10239 times
Last edited by Spacecookies on Fri Jul 16, 2010 8:30 pm, edited 2 times in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Using figures in an equation?

Post by Stefan Kottwitz »

Hi,

you could use \raisebox, like

Code: Select all

\begin{figure}[htb]
  \centering
  \[
  Min\left(
  \raisebox{-50pt}{\includegraphics[width=.25\linewidth]{figures/fig_inputX}}
  ,
  \raisebox{-50pt}{\includegraphics[width=.25\linewidth]{figures/fig_inputY}}
  \right) =
  \raisebox{-50pt}{\includegraphics[width=.25\linewidth]{figures/fig_output}}
  \]
  \caption{\label{fig:fig_image_equation}
  This figure shows a function that takes 2 images as arguments, and returns an image.}
\end{figure}
Stefan
LaTeX.org admin
Spacecookies
Posts: 4
Joined: Thu Jul 15, 2010 10:41 pm

Using figures in an equation?

Post by Spacecookies »

Okay, interesting suggestion. I'll try that one.

I came up with this, which is almost what I want:

Code: Select all

\begin{figure}[htb]
  \centering
  \[
  Min\left(
  \begin{minipage}[h]{0.25\linewidth}
	\vspace{0pt}
	\includegraphics[width=\linewidth]{figures/fig_inputX}
   \end{minipage}
   , 
  \begin{minipage}[h]{0.25\linewidth}
	\vspace{0pt}
	\includegraphics[width=\linewidth]{figures/fig_inputY}
   \end{minipage}
  \right) = 
  \begin{minipage}[h]{0.25\linewidth}
	\vspace{0pt}
	\includegraphics[width=\linewidth]{figures/fig_output}
   \end{minipage}
  \]
  \caption{\label{fig:fig_image_equation}
  This figure shows a function that takes 2 images as arguments, and returns an image.}
\end{figure}
I'd like the brackets to be a little bigger than the images though. They sort of blend together currently I think (see attached).

Thanks
Attachments
Untitled-1.jpg
Untitled-1.jpg (22.79 KiB) Viewed 10230 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Using figures in an equation?

Post by Stefan Kottwitz »

Further you could use \parbox to put the images into a bigger box.

Stefan
LaTeX.org admin
Spacecookies
Posts: 4
Joined: Thu Jul 15, 2010 10:41 pm

Using figures in an equation?

Post by Spacecookies »

Awesome. Thanks for you help! Parbox is exactly what I wanted.

This is what I've settled on, for anyone else who's interested:

Code: Select all

\begin{figure}[htb]
  \centering
  \[
  Min\left(
  \parbox[h][0.30\linewidth][c]{0.25\linewidth}{
	\includegraphics[width=\linewidth]{figures/fig_inputX}
   }
   \;,\;
  \parbox[h][0.30\linewidth][c]{0.25\linewidth}{
	\includegraphics[width=\linewidth]{figures/fig_inputY}
   }
  \right) = 
  \parbox[h][0.30\linewidth][c]{0.25\linewidth}{
	\includegraphics[width=\linewidth]{figures/fig_output}
   }
  \]
  \caption{\label{fig:fig_image_equation}
  This figure shows a function that takes 2 images as arguments, and returns an image.}
\end{figure}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
Joined: Mon Mar 10, 2008 9:44 pm

Re: Using figures in an equation?

Post by Stefan Kottwitz »

Fine!

By the way, in general if a problem is solved it would be nice to mark the topic as "solved". This can be done by editing the first post and choosing the checkmark as topic icon.

Stefan
LaTeX.org admin
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Using figures in an equation?

Post by localghost »

Just a remark. The \parbox command doesn't accept the parameter »h« as alignment option.


Best regards and welcome to the board
Thorsten
Spacecookies
Posts: 4
Joined: Thu Jul 15, 2010 10:41 pm

Using figures in an equation?

Post by Spacecookies »

localghost wrote:The \parbox command doesn't accept the parameter »h« as alignment option.
Ah, good to know. I'll change that.

Thanks!
Post Reply