# Tabbing environment in tabular environment cancels set table width

I have a table with a tabbing environment in it. I don't want the table to exceed a certain width, but the tabbing environment seems to ignore this. So while inserting a lot of 'blas' in row 5 results in the blas being distributed over several lines (which is what I want), the blas in the tabbing environment in row 2 make the table wider (which I want to avoid).

How can I use a tabbing environment in a tabular environment while preserving the set width of my table?

Thanks in advance for any replies!

My code:

\documentclass{article}
\usepackage{graphicx}
\begin{document}

\begin{tabular}{|l|p{7cm}|}
\hline
1 & xxx \\ \hline
2  &

\begin{tabbing}
xxx:\hspace{6mm} \= \textbullet  \hspace{0.01mm} bla bla bla bla bla bla bla bla bla bla bla bla \\
\> \textbullet  \hspace{0.01mm} xxx\\
\> \textbullet  \hspace{0.01mm} xxx\\
xxx: \> \textbullet  \hspace{0.01mm} xxx\\
\> \textbullet  \hspace{0.01mm} xxx\\
xxx: \> \textbullet  \hspace{0.01mm} xxx\\
\> \textbullet  \hspace{0.01mm} xxx\\
xxx: \> \textbullet  \hspace{0.01mm} xxx\\
\> \textbullet  \hspace{0.01mm} xxx\\
\end{tabbing}

\\ \hline
3 & xxx \\ \hline
4 & xxx\\ \hline
5 & bla blabla blabla bla bla bla bla bla bla bla bla bla\\ \hline
6 & xxx\\ \hline
7 & xxx\\
\hline
\end{tabular}

\end{document}

• tabbing cells are always one line, so what do you want to happen if the tabbing is wider than the specified 7cm ? – David Carlisle Jul 31 '14 at 23:34
• I would want the text to spread across multiple lines, but you make a good point: perhaps I should look for an alternative to the tabbing environment. – Thomas Jul 31 '14 at 23:37
• it looks more like a list to me (list items wrap naturally in table cells) – David Carlisle Jul 31 '14 at 23:53

You can use a tabular instead of tabbing.

\documentclass{article}
\usepackage{graphicx}
%\usepackage{array}
\usepackage{calc}
\newlength{\mylen}
\setlength{\mylen}{\widthof{\textbullet}}
\begin{document}

\begin{tabular}{|l|p{7cm}|}
\hline
1 & xxx \\ \hline
2  &

\begin{tabular}[t]{@{}p{1cm}p{\mylen}p{\dimexpr6cm-\mylen-5\tabcolsep\relax}}
xxx   & \textbullet  & bla bla bla bla bla bla bla bla bla bla bla bla \\
& \textbullet  & xxx\\
& \textbullet  & xxx\\
xxx:  & \textbullet  & xxx\\
& \textbullet  & xxx\\
xxx:  & \textbullet  & xxx\\
& \textbullet  & xxx\\
xxx:  & \textbullet  & xxx\\
& \textbullet  & xxx\\
\end{tabular}
\\ \hline
3 & xxx \\ \hline
4 & xxx\\ \hline
5 & bla blabla blabla bla bla bla bla bla bla bla bla bla\\ \hline
6 & xxx\\ \hline
7 & xxx\\
\hline
\end{tabular}

\end{document}


\begin{tabular}[t]{@{}p{1cm}p{\mylen}p{\dimexpr6cm-\mylen-5\tabcolsep\relax}} means

The tabular has three columns with first column 1cm, second one with \mylen and the third one with \dimexpr6cm-\mylen-5\tabcolsep\relax wide respectively. \mylen is eaual to the width of \textbullet and \dimexpr6cm-\mylen-5\tabcolsep\relax is 7cm -1cm-\mylen-5\tabcolsep (the remaining available width for the third column). As there are three columns we have 6 \tabcolseps of which the first one is made zero using @{}. \tabcolsep is the separation between column content and its border.

Hope it is clear.

• This is a great solution, thank you! Could you briefly explain what this line says? : \begin{tabular}[t]{@{}p{1cm}p{\mylen}p{\dimexpr6cm-\mylen-5\tabcolsep\relax}} – Thomas Aug 1 '14 at 10:12
• @Thomas I have added some explanations. Hope it is useful. – user11232 Aug 1 '14 at 10:26
• Thank you very much for the explanation! I'm still learning, so it's useful to try to understand the code rather than blindly copying and pasting it from the web. – Thomas Aug 1 '14 at 11:14
• OP should know that tabular environments cant be broken across pages. Its an issue im trying to solve now. – dopatraman Sep 3 '15 at 0:48
• @dopatraman Use a longtable or ltablex (if you need text wide tables) .... – user11232 Sep 3 '15 at 1:02