Graphics, Figures & TablesPlacing Figures and Text Side-by-Side

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
schorsche
Posts: 5
Joined: Tue Dec 07, 2010 4:54 pm

Placing Figures and Text Side-by-Side

Post by schorsche »

Hello everybody,

can please help me out here, didn't find any info on my specific problem.
On the last page of a document I want to place a picture (right-aligned) with some text next to it. I do not want to wrap the text around the picture. Rather, I want the picture to be right-aligned with the (justified) text appearing left to it. The height of the pic should be the same as the text, so I also want to scale the picture to e.g. be the same height as 10 lines of text. How can I do that easily?
Many thanks!

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

Placing Figures and Text Side-by-Side

Post by Stefan Kottwitz »

Hi schorsche,

you could use \parbox (or a minipage environment) for both the text and the picture. \parbox (minipage too) understands options for vertical alignment.
For the picture, you could specify the height, such as

Code: Select all

\includegraphics[height=10\baselineskip]{filename}
Between the text box and the picture use \hfill to achieve right alignment.

Stefan
LaTeX.org admin
schorsche
Posts: 5
Joined: Tue Dec 07, 2010 4:54 pm

Re: Placing Figures and Text Side-by-Side

Post by schorsche »

Hi!

Thanks for your tip, but it didn't work the way I expected it to. If I use the following command, the picture will be beneath the text, although there would be enough space on the right of the text! If I use 0.5\linewidth in both minipages it works properly, however, then there is a huge wide space between either sides of the picture! So I get the impression that the horizontal alignment is not working properly. Are there any alternative commands?

Thanks a lot, here's the code I am using:

\begin{minipage}{0.65\linewidth}
some text
\end{minipage}
\hfill
\begin{minipage}{0.35\linewidth}
\includegraphics[height=8\baselineskip]{grafics}
\end{minipage}
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Placing Figures and Text Side-by-Side

Post by Stefan Kottwitz »

This way the minipages use the complete linewidth, but there's space between them, which causes the line break such that the second one is placed below.

The line breaks are whitespace, and \hfill is stretchable white space. Either comment them out, such as

Code: Select all

...
\end{minipage}%
\begin{minipage}[b]{0.35\linewidth}
...
or make one minipage a bit smaller.

Stefan
LaTeX.org admin
schorsche
Posts: 5
Joined: Tue Dec 07, 2010 4:54 pm

Re: Placing Figures and Text Side-by-Side

Post by schorsche »

Ok all problems resolved, I had to place \centering into the second minipage!
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Placing Figures and Text Side-by-Side

Post by localghost »

Now that the problem is obviously solved, please be so kind and mark the topic accordingly as written in Section 3 of the Board Rules (to be read before posting). Please keep that in mind for the future so that further reminders will not be necessary.


Thorsten
Post Reply