Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

The following LaTex code (credit) features a table within muticols:

\usepackage{multicol}
...
\begin{multicols}{3}
  \subsubsection{Another Subsubsection}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    \begin{tabular}{@{}ll@{}}
      \verb!Lorem!   & Lorem ipsum dolor sit amet\\
      \verb!ipsum!   & consectetur adipisicing elit\\
      \verb!dolor!   & sed do eiusmod tempor incididunt ut labore et dolore magna aliqua\\
      \verb!sit!     & Lorem ipsum dolor sit amet\\
      \verb!amet!    & Lorem ipsum dolor sit amet\\
    \end{tabular}
\end{multicols}

The Lorem ipsum before the table is properly wrapped, but the long line (sed ipsum...) inside the table isn't.

Is there a way to force wrapping on all column contents? If not, which table property should be changed to assure wrapping?

share|improve this question
    
l columns are always single line, use p{5cm} to make a fixed width column in which text wraps. –  David Carlisle Sep 30 '12 at 21:36
    
Where should I put the p in my example? –  Adam Matan Sep 30 '12 at 21:38
1  
change @{}ll@{} to @{}lp{5cm}@{} note this is nothing to do with multicols it is standard latex tabular usage so any latex guide or the questions linked on the right should help. –  David Carlisle Sep 30 '12 at 21:43
add comment

1 Answer

up vote 8 down vote accepted

You might be interested in the tabularx environment that allows for "wrapped contents" within an X column:

enter image description here

\documentclass{article}
\usepackage{multicol}% http://ctan.org/pkg/multicol
\usepackage{tabularx}% http://ctan.org/pkg/tabularx
\begin{document}
\begin{multicols}{3}
\section{Another Subsubsection}
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\begin{tabularx}{\linewidth}{@{}lX@{}}
  \texttt{Lorem}   & Lorem ipsum dolor sit amet \\
  \texttt{ipsum}   & consectetur adipisicing elit \\
  \texttt{dolor}   & sed do eiusmod tempor incididunt ut labore et dolore magna aliqua \\
  \texttt{sit}     & Lorem ipsum dolor sit amet \\
  \texttt{amet}    & Lorem ipsum dolor sit amet
\end{tabularx}
\end{multicols}
\end{document}

You have to specify the width over which the tabularx should span (\linewidth in this case), the X-columns fill to that width in a paragraph style.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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