[Tex/LaTex] Autosizing two-column layouts

two-column

In preparing a solutions manual for a textbook, I quite often wanted to place some text and an associated figure side-by-side as part of the solution. What I ended up doing was either using multicolumn mode or else (more often) a two-column table. The problem with the latter solution is that it required tuning to get the widths of the columns correct so that the entire thing looked right. What I'd like is a more automatic way to accomplish this. Specifically, I want two columns, with text in one and a figure in the other; I'd like the column containing the figure to be sized so that the figure just fits in the column, and the column containing the text to be left- and right-justified.

There was a somewhat related conversation in comp.text.tex recently ("spring margin", Jun 8) in which someone suggested the memoir class with \leftspringright, but at a quick read that didn't seem to actually do what I'd like.

Any suggestions?

Here is an example. The following tex:

$\,$\newline  
\begin{tabular}{m{2.8in}m{3.2in}}  
The point on the unit circle associated with $-13\pi/3$ is  
$(1/2,-\sqrt{3}/2)$, so  
\[  
  \cot (-13\pi/3) = -1/\sqrt{3}=-\sqrt{3}/3.  
\]  
&  
\begin{center}  
\includegraphics[scale=0.75]{1_3_13.pdf}  
\end{center}  
\end{tabular}  

generates the following pdf snippet:
alt text
The document has several hundred such images, and different spacing is required in general depending on the size of the image so as not to exceed the right margin.

My preamble looks like this:

\documentclass[twoside]{book} 
\usepackage[margin=1in,twoside]{geometry}
\usepackage{fancyhdr} 
\usepackage{amstext}
\usepackage{amsthm}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{array}
\usepackage{multicol}

so I'm not using anything particularly unusual.

Best Answer

I suspect that tabularx (also available within memoir) might be able to handle this.

Something like this might be the basis for a solution:

\begin{tabularx}{\textwidth}{Xc}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
Maecenas in felis sapien. 
& \fbox{\parbox[t]{2cm}{Simulated Figure}}
\end{tabularx}

\begin{tabularx}{\textwidth}{Xc}
Phasellus consectetur, sapien nec mollis euismod, 
sapien sapien posuere justo, nec elementum sapien nisl vitae metus. 
Ut nisl lacus, tincidunt eget fringilla eget, eleifend sit amet ipsum. 
& \fbox{\parbox[t]{4cm}{Simulated Figure}}
\end{tabularx}

The segment \fbox{\parbox[t]{4cm}{Simulated Figure}} stands in place of your figures.

There may be problems with this, depending on the exact nature of your figure. If you'd like to post an example, we may be able to help you better.

Related Question