# Horizontal Filling with LaTeX Tabular

So, this is a case of "It's LaTeX, surely there's a better way of doing this."

I've tried using tabular*, tabularx, and a few other things, but I don't quite get what I'm doing wrong with any of them. My current (working) code looks like

\usepackage{array}
...
\newcolumntype{R}{>{\flushright\arraybackslash}m{.75\columnwidth}}
\newcolumntype{L}{>{\flushleft\arraybackslash}m{.25\columnwidth}}
\begin{tabular*}{\columnwidth}{R|L}
lots of cool text that is long and needs wrapping
&
a very small fixed-width object,
in my case a graphic made with the igo package
\end{tabular*}


My trouble is with my column definitions. I had to choose the columnwidths by hand. I just want the whole tabular to span the current columnwidth, with one column as shrunk as possible (the second) and the other as wide as possible. This made me think of using tabular*, but the examples I found with \fill did not work with line wrapping.

Is there a better way of doing this?

-

## migrated from stackoverflow.comApr 8 '12 at 20:40

This question came from our site for professional and enthusiast programmers.

I think you want tabularx package and

\begin{tabularx}{\textwidth}{>{\raggedleft}X|l}
lots of text & \includegraphics{...}
\end{tabularx}


Or as pointed out in the comments, you were using vertical centred column so

\renewcommand{\tabularxcolumn}[1]{>{\raggedleft}m{#1}}

\begin{tabularx}{\textwidth}{X|l}
lots of text & \includegraphics{...}
\end{tabularx}

-
Or if you want the X column to be like an m column, add \renewcommand{\tabularxcolumn}[1]{>{\raggedleft}m{#1}} – Alan Munn Apr 8 '12 at 20:57
@AlanMunn, thanks yes I extended my answer – David Carlisle Apr 8 '12 at 21:03
This is definitely fixing bits of what I was doing wrong with tabularx! Thanks! I'm still working out some silly behaviors, but I think it's stuff I can figure out with how graphics work. – user1320684 Apr 8 '12 at 21:27
Awesome! I managed to find another thread solving the graphics issues with \vcenter, and now it all works very prettily! – user1320684 Apr 8 '12 at 21:54