Generaltable and figure in one figure

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
zxo
Posts: 3
Joined: Fri Sep 19, 2008 10:14 pm

table and figure in one figure

Post by zxo »

Hello everybody,

I'm trying to use two figures and one table as subfloats in one figure. But the problem ist that they are not aligned correctly (see image). I have the following.

Code: Select all

\begin{figure}[ht]
\begin{center}%
	\subfloat[First figure]{
			\begin{tabular}{c|c|c|c}
				$A$ & $B$ & $C$ & $A \vee B \vee C = Q$ \\
				\hline
				0 & 0 & 0 & 0 \\
				0 & 0 & 1 & 1 \\
				0 & 1 & 0 & 1 \\
				0 & 1 & 1 & 1 \\
				1 & 0 & 0 & 1 \\
				1 & 0 & 1 & 1 \\
				1 & 1 & 0 & 1 \\
				1 & 1 & 1 & 1
			\end{tabular}
			\label{lhzg}
	}%
	\subfloat[Second]{
		\label{test}\includegraphics{images/venn_or.pdf}
	}%
	\subfloat[Third]{
		\label{test2}\includegraphics{symbols/fta_or.pdf}
	}%
\end{center}	
\caption{Presentation forms of the logical OR}
\label{}
\end{figure}
Besides the subfig package I also tried subfigure and a plain table. It's always the same.

Can anybody help me?



Greetings
Attachments
subfigure_problem.PNG
subfigure_problem.PNG (29.56 KiB) Viewed 3928 times

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: 10345
Joined: Mon Mar 10, 2008 9:44 pm

table and figure in one figure

Post by Stefan Kottwitz »

Hi zxo,

welcome to the board!
Use the optional parameter b of tabular to get it aligned at the bottom:

Code: Select all

\begin{tabular}[b]{c|c|c|c}
Stefan
LaTeX.org admin
zxo
Posts: 3
Joined: Fri Sep 19, 2008 10:14 pm

Re: table and figure in one figure

Post by zxo »

Hi,

thank you for your fast answer. Although it's far better than before, the captions are not on the same height. Please see the second image. I painted some red lines into it. I'd like to have them on the same line. Looks better :)

By the way, I also searched for a way to center both figures vertically. Maybe there is a command like \center (which i didn't found) which not changes the position of the caption (once it's in its correct place ;) )

Regards
Attachments
subfigure_problem2.PNG
subfigure_problem2.PNG (27.63 KiB) Viewed 3912 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

table and figure in one figure

Post by Stefan Kottwitz »

Hi zxo,

it should work if you raise the table by \depth:

Code: Select all

\raisebox{\depth}{\begin{tabular}[b]{c|c|c|c}
...
\end{tabular}}
Concerning vertical centering I'm sure that's described in the subfig package documentation. If not, or if you have problems with it, tell me.

Stefan
LaTeX.org admin
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

table and figure in one figure

Post by sommerfee »

Stefan_K wrote: it should work if you raise the table by \depth:
I'm sorry for praising my own package, but by using the subcaption package instead of the subfigure/subfig package the alignment should be correct without such tricks:

Code: Select all

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption,subcaption}

\begin{document}

\begin{figure}[ht]
\centering
   \subfloat[First figure\label{lhzg}]{
         \begin{tabular}{c|c|c|c}
            $A$ & $B$ & $C$ & $A \vee B \vee C = Q$ \\
            \hline
            0 & 0 & 0 & 0 \\
            0 & 0 & 1 & 1 \\
            0 & 1 & 0 & 1 \\
            0 & 1 & 1 & 1 \\
            1 & 0 & 0 & 1 \\
            1 & 0 & 1 & 1 \\
            1 & 1 & 0 & 1 \\
            1 & 1 & 1 & 1
         \end{tabular}
   }%
   \subfloat[Second\label{test}]{
      \includegraphics{images/venn_or.pdf}
   }%
   \subfloat[Third\label{test2}]{
      \includegraphics{symbols/fta_or.pdf}
   }%
\caption{Presentation forms of the logical OR}
\label{}
\end{figure}

\end{document}
Axel
zxo
Posts: 3
Joined: Fri Sep 19, 2008 10:14 pm

table and figure in one figure

Post by zxo »

Hi,

thanks for the answers.

@Axel: Works great :)
@Stefan: Your right, there is really an example in the documentation to set a smaller figure vertically centered. But I don't really understand the example. I never saw \savebox or anything else. Nevertheless, I tried to adopt it, but it didn't work for me. Here is my code and what it looks like. The third figure is gone and the others are to far away. Besides, figure b is not really centered at all (vertically)

Code: Select all

\newsavebox{\tempbox}
\begin{figure}
	\centering
	\sbox{\tempbox}{
			\begin{tabular}{c|c|c|c}
				$A$ & $B$ & $C$ & $A \vee B \vee C = Q$ \\
				\hline
				0 & 0 & 0 & 0 \\
				0 & 0 & 1 & 1 \\
				0 & 1 & 0 & 1 \\
				0 & 1 & 1 & 1 \\
				1 & 0 & 0 & 1 \\
				1 & 0 & 1 & 1 \\
				1 & 1 & 0 & 1 \\
				1 & 1 & 1 & 1
			\end{tabular}
	}
	\subfloat[First figure]{\usebox{\tempbox}}%
	\subfloat[Second]{
		\vbox to \ht\tempbox{\vfil \includegraphics{symbols/fta_or.pdf} \vfil}
		%\label{test}\makebox[3cm][c]{\includegraphics{symbols/fta_or.pdf}}
	}%
	\subfloat[Third]{
		\vbox to \ht\tempbox{\vfil \includegraphics{symbols/fta_or.pdf} \vfil}
		%\label{test2}\raisebox{2cm}{\framebox[3cm][c]{\includegraphics{symbols/fta_or.pdf}}}
	}%
\caption{Presentation forms of the logical OR}
\label{}
\end{figure}
I hope you have any ideas ;)

Regards
Attachments
subfigure_problem3.PNG
subfigure_problem3.PNG (17.59 KiB) Viewed 3870 times
Post Reply