[Tex/LaTex] Table with a single column using text-wrapping

line-breakingtables

I have a table with 3 columns. The first two just have cells with 1 or 2 short values which I do not want to wrap and I want to be the minimum allowed size. The 3rd column has a lot more text, and needs to wrap.

I am aware of the p column type, but in this context I do not know what value to give it. I simply want that 3rd column to use however much space is left after the first 2 (somewhere around 2/3's of the page width) and wrap any text to fit rather than going off the page.

I want to avoid trail and error, so that it doesn't break every time I modify the first columns.

My table looks something like:

\begin{tabular}{|l|l|l|}
\hline apple & StackOverflow &
 lots of long text. lots of long text. lots of long text. lots of long text. lots of long text. \\
\hline orange & StackExchange &
 lots of long text. lots of long text. lots of long text. lots of long text. lots of long text. \\
\hline pineapple & LaTex Stack Exchange&
 lots of long text. lots of long text. lots of long text. lots of long text. lots of long text. \\
\hline
\end{tabular}

Best Answer

With tabularx package, the X column will fill the remaining table width. Note that a table width must be specified (here, given as `\textwidth}.

\documentclass{article}
\usepackage{tabularx}
\makeatother
\begin{document}
\noindent\begin{tabularx}{\textwidth}{|l|l|X|}
\hline apple & StackOverflow &
 lots of long text. lots of long text. lots of long text. lots of long text. lots of long text. \\
\hline orange & StackExchange &
 lots of long text. lots of long text. lots of long text. lots of long text. lots of long text. \\
\hline pineapple & LaTex Stack Exchange&
 lots of long text. lots of long text. lots of long text. lots of long text. lots of long text. \\
\hline
\end{tabularx}
\end{document}

enter image description here