Graphics, Figures & TablesImage next to a table

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Testien
Posts: 2
Joined: Sun Nov 28, 2010 10:51 pm

Image next to a table

Post by Testien »

Code: Select all

\documentclass[10pt,a4paper,oneside]{book}

\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\begin{document}
\subsection{Stars}
\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|c|}{Sun}\\
\hline
A & B\\
Lorem & ipsum\\
Doloret & sit amet\\
\hline
\end{tabular}
\includegraphics[scale=0.2]{sun.png}

\end{document}
I wanted to put an image right next to the table, but whatever I try, it keeps being a little up. I have searched the forum, but nothing I found helped me.
Attachments
main.pdf
(44.75 KiB) Downloaded 260 times
Last edited by Testien on Mon Nov 29, 2010 4:25 pm, edited 1 time 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.

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Image next to a table

Post by meho_r »

One way might be using minipage environment, e.g.:

Code: Select all

\documentclass[10pt,a4paper,oneside]{book}

\usepackage{graphicx}
\DeclareGraphicsExtensions{.pdf,.png,.jpg}

\begin{document}
\subsection{Stars}
\begin{minipage}{.3\textwidth}
\begin{tabular}{|l|l|}
\hline
\multicolumn{2}{|c|}{Sun}\\
\hline
A & B\\
Lorem & ipsum\\
Doloret & sit amet\\
\hline
\end{tabular}
\end{minipage}
\hspace{6pt}
\begin{minipage}{.45\textwidth}
\includegraphics[scale=0.2]{sun.png}
\end{minipage}
\end{document}
Testien
Posts: 2
Joined: Sun Nov 28, 2010 10:51 pm

Re: Image next to a table

Post by Testien »

Great, that works, thank you!
Post Reply