[Tex/LaTex] Tabbing environment in tabular environment cancels set table width

tabbingtableswidth

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}

Best Answer

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}

enter image description here

\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.