[texhax] figures and text aligned

mr at xosoftware.dk mr at xosoftware.dk
Mon Mar 15 14:35:59 CET 2004


To Steve, thank you very much.
For some of the rest: Please reconsider your arrogant answers. I do use the FAQ,
and I don't mean to waste your time. If you find it appearant and obvious that I
am lazy, stupid, and what not, don't answer!
Sincerely
Martin

Quoting Steve Schwartz <s.j.schwartz at qmul.ac.uk>:

> Martin,
> 
> > I am trying to place a \figure side by side with some text. That is, I want
> the
> > figure to take up only part of the width of the page and then have text
> placed
> > on the rest of the width. It appears that I am not doing my search very
> well, as
> > I don't find anything useful.
> > Thank you
> > Martin
> 
> If what you want is to have some FIXED text next to your figure (as
> opposed to text flowing around it), put the graphic and text inside a
> tabular environment. Use the array package to control the vertical
> alignment within the single row to centre the text vertically next to
> the figure. This will also work inside a floating environment, although
> it will take a guru to tell you how to convince latex to accept the
> \caption inside the tabular environment. But you can put it outside the
> tabular but inside the float. 
> 
> I won't scream at you for not finding your way 'round the TeX Faq. [But
> I found everything I needed by typing a few keywords into google(!)
> though I have a few phrases I turn to when I'm desperate,  like "use
> tabular" or "put it in an hbox" which got me most of the way. ]
> 
> Here's a short sample (use your own figure in place of png):
> 
> -----------------------snip-------------------------
> \documentclass{article}
> \usepackage{graphicx}
> \usepackage{array}
> 
> \begin{document}
> 
> Let's try
> 
> % m{<width>} centres vertically in a col of width <width>
> \begin{tabular}{m{0.3\textwidth}|m{0.7\textwidth}}
> \includegraphics[width=0.3\textwidth]{png} & 
> \parbox{0.5\textwidth}{Here is a
> bunch of text which will get set alongside the figure.}
> \end{tabular}
> 
> And it works in a figure environment as well:
> 
> \begin{figure}
> \begin{tabular}{m{0.5\textwidth}m{0.5\textwidth}}
> \includegraphics[width=0.45\textwidth]{png}
>  & \parbox{0.45\textwidth} {Here is a
> bunch of text which will get set alongside the figure.}
> \end{tabular}
> \caption{What a pretty figure}
> \end{figure}
> 
> \end{document}
> 
> 
> -- 
> +-----------------------------------------------------------------+
> | Steve Schwartz               S.J.Schwartz at qmul.ac.uk            |
> | Astronomy Unit                                                  |
> | Queen Mary, Univ. of London  Tel: +44 (0)20 7882 5449           |
> | Mile End Road                Fax: +44 (0)20 8983 3522           |
> | London E1 4NS, UK            URL: www.space-plasma.qmul.ac.uk/  |
> +-----------------------------------------------------------------+
> 
> 
> 






More information about the texhax mailing list