1

Consider this example:

\documentclass{report}
\usepackage{lipsum}
\begin{document}
\begin{tabular}{lll}
  A & B & \lipsum[1][1-3]
\end{tabular}
\end{document}

In the output: enter image description here

the last column goes out of the bounds of the page. I could constrain the last column by using\begin{tabular}{llp{3cm}}. However, it would be more convenient to make the table span textwidth automatically. How to do it?

3
  • tabularx is probably what you are looking for.
    – moewe
    Jan 19 '19 at 19:30
  • you should use table with prescribed width. for example tabular* with p column type or tabularx.
    – Zarko
    Jan 19 '19 at 19:30
  • @Zarko, could you please provide an elaborate answer?
    – Viesturs
    Jan 19 '19 at 19:33
1

with tabularx package is simple:

\documentclass{report}
\usepackage{tabularx}             % <---
\usepackage{lipsum}

\noindent
\begin{document}
\begin{tabularx}{\linewidth}{llX}  % table width is determined with \linewidth
                                   % at least one column had to be `X` type
  A & B & \lipsum[66]
\end{tabularx}

\noindent
\begin{tabularx}{\linewidth}{@{} llX @{}} % border \tabcolsep is suppressed
  A & B & \lipsum[66]
\end{tabularx}

\begin{table}[htb]                      % table is in float environment
\begin{tabularx}{\linewidth}{@{}llX@{}} % border \tabcolsep is suppressed
  A & B & \lipsum[66]
\end{tabularx}
\end{table}

\end{document}

enter image description here

0

Not the answer you're looking for? Browse other questions tagged or ask your own question.