2

I have a table defined as below:

\begin{tabular}{|c|c|c|}
      \hline
      \textbf{Library} & \textbf{Problem Type} & \textbf{Dependencies}\\
      \hline
      OSI & Abstract class for other libraries & CoinUtils, BuildTools\\
      \hline
      CLP & Linear Programming (LP) & Osi, CoinUtils, BuildTools\\
      \hline
    CBC & Mixed Integer LP & Cgl, Clp, Osi, CoinUtils, BuildTools\\
    \hline
    Symphony & Mixed Integer LP & Cgl, Clp, Osi, CoinUtils, BuildTools\\
    \hline
    Ipopt & Nonlinear programming (NLP) & BuildTools, Lapack, Blas, Mumps\\
    \hline
    Bonmin & Mixed Integer NLP & Ipopt, Cbc, Cgl, Clp, Osi, CoinUtils, BuildTools, Lapack, Blas, Mumps\\
    \hline
    \end{tabular}

The last last column does not fit in the the page for all rows because it is too big. How do alter it so that these cells take up multiple lines?

2 Answers2

4

You can use tabularx to make the table fit line width:

\documentclass{article}
\usepackage{tabularx}
\usepackage{ragged2e}
\usepackage{showframe}
\renewcommand{\ShowFrameLinethickness}{0.3pt}

\begin{document}

\begin{table}
\setlength{\extrarowheight}{2pt}
\begin{tabularx}{\linewidth}{|c|>{\RaggedRight\arraybackslash}X|>{\raggedright\arraybackslash}X|}
      \hline
      \textbf{Library} & \textbf{Problem Type} & \textbf{Dependencies}\\
      \hline
      OSI & Abstract class for other libraries & CoinUtils, BuildTools\\
      \hline
      CLP & Linear Programming (LP) & Osi, CoinUtils, BuildTools\\
      \hline
    CBC & Mixed Integer LP & Cgl, Clp, Osi, CoinUtils, BuildTools\\
    \hline
    Symphony & Mixed Integer LP & Cgl, Clp, Osi, CoinUtils, BuildTools\\
    \hline
    Ipopt & Nonlinear programming (NLP) & BuildTools, Lapack, Blas, Mumps\\
    \hline
    Bonmin & Mixed Integer NLP & Ipopt, Cbc, Cgl, Clp, Osi, CoinUtils, BuildTools, Lapack, Blas, Mumps\\
    \hline
    \end{tabularx}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
1

Here's another tabularx-based solution. Its overall structure is very similar to @Bernard's answer; automatic line-wrapping is enabled for the the third column. The main difference is that it seeks to create a much more open "look", by omitting all vertical lines and most horizontal lines. The three remaining horizontal lines are drawn by macros provided by the booktabs package.

enter image description here

\documentclass{article}
\usepackage{tabularx,booktabs}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}
\noindent
\begin{tabularx}{\linewidth}{@{} l l L @{}}
\toprule
Library & Problem Type & Dependencies \\
\midrule
OSI & Abstract class for other libraries 
   & CoinUtils, BuildTools\\
\addlinespace
CLP & Linear Programming (LP) 
   & Osi, CoinUtils, BuildTools\\
\addlinespace
CBC & Mixed Integer LP 
   & Cgl, Clp, Osi, CoinUtils, BuildTools\\
\addlinespace
Symphony & Mixed Integer LP 
   & Cgl, Clp, Osi, CoinUtils, BuildTools\\
\addlinespace    
Ipopt & Nonlinear programming (NLP) 
   & BuildTools, Lapack, Blas, Mumps\\
\addlinespace   
Bonmin & Mixed Integer NLP 
   & Ipopt, Cbc, Cgl, Clp, Osi, CoinUtils, BuildTools, Lapack, Blas, Mumps\\
\bottomrule
\end{tabularx}
\end{document}
Mico
  • 506,678