# Make a column of a table take up all remaining width without other columns wrapping to the next line

I want to make a table with 3 columns.

The table will fit the width of the container.

The left column will be right aligned and take up as little width space as possible.

The center column will be left aligned and take up as little width space as possible.

The right column will be left aligned and take up as much width space as possible.

So far I have this:

% unrelated setup stuff
\documentclass[letter]{report}
\usepackage[top=2cm, bottom=2cm, left=1cm, right=1cm]{geometry}
\usepackage[sfdefault]{cabin}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{lipsum}
\newenvironment{absolutelynopagebreak}
{\par\nobreak\vfil\penalty0\vfilneg
\vtop\bgroup}
{\par\xdef\tpd{\the\prevdepth}\egroup
\prevdepth=\tpd}
\fontfamily{pcr}\selectfont
\setlength{\parindent}{0ex}
\setlength{\parskip}{1em}
% /unrelated setup stuff

\begin{document}{
\begin{tabular}{rll}
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabular}
}
\end{document}


But I'm not sure how to assign percentage-based widths to the three columns.

Ideally, it'd just be something like:

\begin{tabular}{r{1 percent}l{1 percent}l{99 percent}}


What I'm trying to do can be shown using HTML/CSS:

JS Fiddle - http://jsfiddle.net/3w61tt78/

<table>
<tr>
<td class="small r">(S) 10</td>
<td class="small l">&#37; (w/v)</td>
<td class="large l">1,4-butanediol</td>
</tr>
</table>

<style type="text/css">
table, td
{
border:1px solid #000;
border-spacing:1px;
}
table
{
width:100%;
}
td
{
}
.small
{
white-space:nowrap;
width:1%;
}
.large
{
width:99%;
}
.r
{
text-align:right;
}
.l
{
text-align:left;
}
</style>

• Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Please complete your code so that it is a complete, small document people can copy-paste-compile. This makes it easier to understand your situation and more likely people will be willing to find the time to help you. – cfr Nov 19 '14 at 2:28
• Note that a lot of us don't speak terribly good HTML... – cfr Nov 19 '14 at 2:28
• A minimal example shouldn't contain a bunch of things irrelevant to the question. If you aren't using TiKZ to draw the table, you don't need it, for example. – cfr Nov 19 '14 at 2:42
• Sorry about that. I wasn't sure what to include as far as the setup stuff goes. I inherited this project from someone fluent in LaTeX, and all I know is what I've read online the past couple days. Would the "begin document" / "end document" parts be enough? Basically remove all the stuff between the comments. – peaceoutside Nov 19 '14 at 16:23
• Yes, the idea can take some getting used to ;). – cfr Nov 19 '14 at 16:30

Like this may be...

\documentclass{article}
\usepackage{array}
\usepackage{tabularx}
\usepackage{showframe}
\begin{document}
\noindent
\begin{tabular*}{\textwidth}{rl@{\extracolsep{\fill}}l}    %% @{\extracolsep{\fill}} is redundant IMO
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabular*}

\bigskip
\noindent
\begin{tabular}{>{\raggedleft}p{0.1\textwidth}p{0.15\textwidth}
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabular}

\bigskip
\noindent
\begin{tabularx}{\textwidth}{rlX}
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabularx}
\end{document}


• Example 3 is obviously what the OP wants (or should want...). I'd put it first, not last. – Mico Nov 19 '14 at 5:56
• @Mico: :) You are right possibly. – user11232 Nov 19 '14 at 5:57

Here's a minimised example:

\documentclass{article}
\usepackage{array,tabularx}

\begin{document}

\begin{tabularx}{\linewidth}{>{\hsize=.01\hsize\raggedleft\arraybackslash}X>{\hsize=.01\hsize}X>{\hsize=2.98\hsize}X}
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabularx}

\end{document}


This does what you asked but it looks horrible:

If the first two columns contain relatively little, I'd just use r and l for those:

  \begin{tabularx}{\linewidth}{lrX}
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabularx}


If they will contain longer text, you might need something more like:

  \begin{tabularx}{\linewidth}{>{\hsize=.5\hsize\raggedleft\arraybackslash}X>{\hsize=.5\hsize}X>{\hsize=2\hsize}X}
(S) 10 & \% (w/v) & 1,4-butanediol \\
\end{tabularx}