[Tex/LaTex] Auto-linebreak in table – tabular/longtable

longtabletables

I have the following longtable where i want the third column to do an auto-linebreak, instead of me having to do it forced. Is there any way to do this?

This is a image of how the long table looks, where i did forced linebreaks
http://imgur.com/uNL7OcC "how the long table looks"

This is how the table in the code below looks like:
http://imgur.com/Izv44ie "from code example"

\begin{center}
\renewcommand{\tabcolsep}{3pt}
\begin{longtable}{|c|c|c|c|c|c|}
\caption{\textbf{Veterinarian and pet shop interview analysis}}\\
\hline
\textbf{Theme} & \textbf{Sub theme} & \textbf{Raw data} & \textbf{Code} & \textbf{Findings} & \textbf{+/-} \\
\hline
\endfirsthead
\multicolumn{6}{c}%
{\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
\hline
\textbf{Theme} & \textbf{Sub theme} & \textbf{Raw data} & \textbf{Code} & \textbf{Findings} & \textbf{+/-} \\
\hline
\endhead
\hline \multicolumn{6}{r}{\textit{Continued on next page}} \\
\endfoot
\hline
\endlastfoot
\begin{tabular}[c]{@{}l@{}}1. Increase\\ of overwe-\\ ight dogs \\ in Denmark\end{tabular} & \begin{tabular}[c]{@{}l@{}}Measurement\\ method\end{tabular} & \textit{\begin{tabular}[c]{@{}l@{}}Vet: Many sources tell that it is increasing and this is somewhat based on the veterinarian's experiences and impressions.\\ PS: We often see in the shop that many of the dogs who enter are overweight. Actually it is so big a problem that the shop i am in have chosen to put up a dog weight in the shop, so that the customers can weight their dog when they come in here.\end{tabular}} & VP1.1 & \begin{tabular}[c]{@{}l@{}}1. Increase \\ of overweight \\ dogs in \\ Denmark is \\ based on \\ estimates\end{tabular} & \begin{tabular}[c]{@{}l@{}}+\\ +\end{tabular} \\ \hline
\end{longtable}
\end{center}

Best Answer

As already hinted in the very first comment, using p columns with an appropriate width is the solution to prevent manual line breaking.

I don't know why you are nesting tabulars. You might be looking for m columns. I changed the table in its implementation quite a bit and adjusted the width by trial and error.

kennethLongtable

\documentclass{article}
\usepackage[english]{babel}
\usepackage{longtable}
\usepackage{array}
\usepackage{geometry}
\geometry{a4paper,showframe,textheight=10cm}
\newcolumntype{K}{>{\raggedright\arraybackslash\hspace{0pt}}m}
\newcommand{\tabhead}[2]{\multicolumn{1}{#1}{\bfseries#2}}
\newcommand{\positive}{$+$ }
\usepackage{amssymb}
%\renewcommand{\positive}{\checkmark\space}
\newcommand{\negative}{$-$ }
%\renewcommand{\negative}{$\times$ }
\begin{document}
\begin{longtable}{|K{.12\linewidth}|K{.13\linewidth}|>{\itshape}K{.34\linewidth}|K{.07\linewidth}|K{.11\linewidth}|>{\centering\arraybackslash}m{.03\linewidth}|}
        \caption{\textbf{Veterinarian and pet shop interview analysis}}\\
        \hline
        \tabhead{|c|}{Theme} & \tabhead{c|}{Sub theme} & \tabhead{c|}{Raw data} &
        \tabhead{c|}{Code} & \tabhead{c|}{Findings} & \tabhead{c|}{+/-} \\
        \hline
        \endfirsthead
        \multicolumn{6}{c}%
        {\tablename\ \thetable\ -- \textit{Continued from previous page}} \\
        \hline
        \tabhead{|c|}{Theme} & \tabhead{c|}{Sub theme} & \tabhead{c|}{Raw data} &
        \tabhead{c|}{Code} & \tabhead{c|}{Findings} & \tabhead{c|}{+/-} \\
        \hline
        \endhead
        \hline \multicolumn{6}{r}{\textit{Continued on next page}} \\
        \endfoot
        \hline
        \endlastfoot
        1. Increase of overweight dogs  in Denmark & Measurement method &
        Vet: Many sources tell that it is increasing and this is somewhat
        based on the veterinarian's experiences and impressions. \par PS: We
        often see in the shop that many of the dogs who enter are
        overweight. Actually it is so big a problem that the shop i am in
        have chosen to put up a dog weight in the shop, so that the
        customers can weight their dog when they come in here. &
        VP1.1 & 1.~Increase  of overweight  dogs in  Denmark is  based on
        estimates & \positive \positive \\ \hline
        1. Increase of overweight dogs  in Denmark & Measurement method &
        Vet: Many sources tell that it is increasing and this is somewhat
        based on the veterinarian's experiences and impressions. \par PS: We
        often see in the shop that many of the dogs who enter are
        overweight. Actually it is so big a problem that the shop i am in
        have chosen to put up a dog weight in the shop, so that the
        customers can weight their dog when they come in here. &
        VP1.1 & 1.~Increase  of overweight  dogs in  Denmark is  based on
        estimates & \positive \negative  \\ \hline
    \end{longtable}
\end{document}
Related Question