2

I have a table and a figure, I want to align them one next to the other (not one under the other):

\documentclass{llncs}
\usepackage{capt-of}
\usepackage[demo]{graphicx}
\begin{document}


\begin{table}[t]
\begin{minipage}[t]{.5\textwidth }
\footnotesize
\begin{tabular}{ | c || c | c | c | c | } \hline
\textbf{ABC} & \textbf{KO} & \textbf{Ro} & \textbf{Ov} & \textbf{Params} \\ \hline
\multicolumn{5}{|c|}{\textbf{Well this is a text here}} \\ \hline
\textit{A1} & 123 & 123 & 123 & 123 \\ \hline
\textit{Z2} & 123 & 123 & 123 & 123 \\ \hline
\multicolumn{5}{|c|}{\textbf{Well this is another text here)}} \\ \hline
\textit{O1} & 123 & 123 & 123 & 123 \\ \hline
\textit{U9} & 123 & 123 & 123 & 123 \\ \hline
\end{tabular}
\caption{results in this table}
\label{validation}
\end{minipage}%
\begin{minipage}[t]{.5\textwidth}
\includegraphics[width=0.45\textwidth]{plot.pdf}
\caption{This is a figure not a table}
\label{plot}
\end{minipage}
\end{table}

\end{document}
lockstep
  • 250,273
  • Possible duplicate of http://tex.stackexchange.com/questions/6850/table-and-figure-side-by-side-with-independent-captions?rq=1 – bloodworks Jul 05 '12 at 12:41
  • In beamer there is the columns environment which allows you to do this. I'm not sure if this environment is available outside of beamer. – Leeser Jul 05 '12 at 12:48
  • @Leeser nope. But there´s something more reliable. See my answer below. – bloodworks Jul 05 '12 at 12:52
  • @bloodworks The figure and its caption are overlapping with the table, with your solution – user995434 Jul 05 '12 at 13:22
  • @bloodworks "nope" as in there isn't a comparable environment outside of beamer? – Leeser Jul 05 '12 at 13:28
  • @Leeser i dont get the sense of your last comment. When you need to divide a page into several smaler pages the default way to do that would be to use minimage (as shown below) unless you need your content to spread over many pages (then you may use multicol or some other two or more column layout facilities) – bloodworks Jul 05 '12 at 13:49
  • @bloodworks I didn't understand what you meant by "nope". What were you saying nope to? "Nope" that there isn't a columns environment in beamer (which there is) or "nope" that the columns environment isn't available outside of beamer, which is quite possible. Or "Nope" that I'm completely wrong on all accounts! Just a clarification on what the answer "nope" was referring to. I'm not arguing that your solution is wrong. A solution in beamer where there is a picture in one column and table is given in http://tex.stackexchange.com/questions/50506/setbeameruncovered-problem-bug – Leeser Jul 05 '12 at 14:50
  • @Leeser ok i´m sorry we ran into a communication clash right here. I just intended to say that there is no beamerlike columns environment outside beamer. Nothing personal. – bloodworks Jul 05 '12 at 15:00
  • 1
    @bloodworks. No worries, I didn't take anything personal, so no need to apologise. It is hard to convey tone and meaning in a few short characters and it can come across quite different to what was meant. I hope you didn't think I was getting worked up ...as it appears ...now that I re-read my 2nd reply...! – Leeser Jul 05 '12 at 15:14

1 Answers1

5

Assuming a MWE you could do the following:

\documentclass{book}
\usepackage{capt-of}
\usepackage[demo]{graphicx}
\begin{document}


\begin{table}[t]
    \begin{minipage}[t]{.5\textwidth }
        \footnotesize
        \begin{tabular}{ | c || c | c | c | c | } \hline
            &\\
        \end{tabular}
        \caption{the caption of table}
        \label{thelabeltab}
    \end{minipage}%
    \begin{minipage}[t]{.5\textwidth}
        \includegraphics[width=0.45\textwidth]{myimage.pdf}
        \captionof{figure}{my caption goes here}
        \label{thelab}
    \end{minipage}
\end{table}

\end{document}

enter image description here

When using a KOMAScript Class capt-ofis not needed. If the Example doesn´t help you i suggest that you provide a MWE.

Update: Here comes a extended example with some (debuging) frames to show you the placement of the two objects. (When you compare this example with the one above you`ll easily figure out which commands to strip to get rid of those lines.)

\documentclass{book}
\usepackage{capt-of, showframe, blindtext}
\usepackage[demo]{graphicx}
\begin{document}
\blindtext

\begin{table}[t]\fbox{
\begin{minipage}[b]{.50\textwidth }%
\footnotesize
\begin{tabular}{ | c || c | c | c | c | } \hline
\textbf{ABC} & \textbf{KO} & \textbf{Ro} & \textbf{Ov} & \textbf{Params} \\ \hline
\multicolumn{5}{|c|}{\textbf{Well this is a text here}} \\ \hline
\textit{A1} & 123 & 123 & 123 & 123 \\ \hline
\textit{Z2} & 123 & 123 & 123 & 123 \\ \hline
\multicolumn{5}{|c|}{\textbf{Well this is another text here)}} \\ \hline
\textit{O1} & 123 & 123 & 123 & 123 \\ \hline
\textit{U9} & 123 & 123 & 123 & 123 \\ \hline
\end{tabular}%
\caption{results in this table}\label{validation}%
\end{minipage}}%
\fbox{\begin{minipage}[b]{.45\textwidth}%
\hspace*{0pt}\includegraphics[width=0.45\textwidth]{plot.pdf}%
\captionof{figure}{This is a figure not a table\label{x}}%
\end{minipage}}
\end{table}

\end{document}

enter image description here

David Carlisle
  • 757,742
bloodworks
  • 10,178
  • With this, I get that the figure and its caption is overlapping with the table ! – user995434 Jul 05 '12 at 13:22
  • @user995434 absolutely not: see the edit. Remember this is all you gave us. Thats why i asked you for a MWE. – bloodworks Jul 05 '12 at 13:46
  • I have edited my first post to put a code with a table and figure as you said, but they are not aligned perfectly ! and the figure is called Table 2 instead of Fig 1 ... – user995434 Jul 05 '12 at 13:58
  • @user995434: You didn't use the \captionof{figure}, and your tabular is simply to large and so sticks out of the minipage. – Ulrike Fischer Jul 05 '12 at 14:06
  • using the "llncs" class instead of "book" will not make the captions aligned together ! – user995434 Jul 05 '12 at 15:03
  • Well there is no such class on ctan. What i found using google seems to be a class redefining minipage which is crude in my eyes. Maybe you could address the maintainer of this class. BTW that piece of code i found says, that it is experimental. Using something which calls itself experimental is not always a good idea. – bloodworks Jul 05 '12 at 15:07
  • I'm not allowed to modify the llncs style which is required for the paper that I'm writing. – user995434 Jul 05 '12 at 15:08
  • @user995434 are you allowed to load new packages? – bloodworks Jul 05 '12 at 15:11
  • @bloodworks I think yes, if this does not change the style (margin etc) – user995434 Jul 05 '12 at 15:42