3

I have the problem that I have a table which includes two images next to each other and below in the next line there is the caption of the image. The problem is that the images are not shown next to each other, they are up and down. My code:

\begin{table}[!ht]\label{tab:subsecfeeling}
\begin{tabular}{|p{7cm}|p{7cm}|}
\hline
\centering
\includegraphics[width=0.7\linewidth]{Screenshots/Routing/closed_area_ex1.png}
\label{fig:closed_area_ex1}
& 
\begin{center}
\includegraphics[width=0.7\linewidth]{Screenshots/Routing/closed_area_ex3.png}
%\label{fig:closed_area_ex3}
\end{center}
\\ 
\hline
The shown route in this figure is the shortest path from current position to the destination. In this route there exists no closed area. & The shown route in this figure is avoiding the closed door. Therefore the shortest path is to use the way through the next office. \\
\hline 
\end{tabular} 
\end{table}

The images shows that the images are not next to each other. I want that they are next to each other and not up and down. Besides the text in the next line has to be line braked.

I tried also centering in the second image, but then the result was almost the same as I get now. How can put both images in two columns next to each other? enter image description here

  • Welcome to TeX.SE! Since the assigned column widths are 7cm each, have you tried 6cm for the widths of the images? – Mico Jan 21 '14 at 8:16
  • Changing {|p{7cm}|p{7cm}|} into {|p{6cm}|p{6cm}|} is not changing anything. Also to reduce the size of the image from 0.7 into 0.6 or less. – Irgendw Pointer Jan 21 '14 at 8:22
  • Sorry for not being clear: I was suggesting you change width=0.7\linewidth to width=6cm, for the widths of the images. – Mico Jan 21 '14 at 8:29
5

A quick fix is to use center environment. It seems that center environment and centering command are used.

enter image description here

Code:

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{table}[!ht]\label{tab:subsecfeeling}
\begin{tabular}{|p{7cm}|p{7cm}|}
\hline
\begin{center}
\includegraphics[width=0.7\linewidth]{Screenshots/Routing/closed_area_ex1.png}
\end{center}
\label{fig:closed_area_ex1}
& 
\begin{center}
\includegraphics[width=0.7\linewidth]{Screenshots/Routing/closed_area_ex3.png}
\end{center}
%\label{fig:closed_area_ex3}
\\ 
\hline
The shown route in this figure is the shortest path from current position to the destination. In this route there exists no closed area. & The shown route in this figure is avoiding the closed door. Therefore the shortest path is to use the way through the next office. \\
\hline 
\end{tabular} 
\end{table}
\end{document}

If centering command is preferred, one needs to put a \par (or an empty line) before the closing brace. \centering doesn't leave vertical space before and after it.

enter image description here

Codes

\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{table}[!ht]\label{tab:subsecfeeling}
\begin{tabular}{|p{7cm}|p{7cm}|}
\hline
{\vspace{0.2cm}\centering
\includegraphics[width=0.7\linewidth]{Screenshots/Routing/closed_area_ex1.png}
\par}
\label{fig:closed_area_ex1}
& 
{\vspace{0.2cm}\centering
\includegraphics[width=0.7\linewidth]{Screenshots/Routing/closed_area_ex3.png}

}
\label{fig:closed_area_ex3}
\\ \hline
The shown route in this figure is the shortest path from current position to the destination. In this route there exists no closed area. & The shown route in this figure is avoiding the closed door. Therefore the shortest path is to use the way through the next office. \\
\hline 
\end{tabular} 
\end{table}
\end{document}

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.