[Tex/LaTex] Change column size to fit text

tablestabularxwidth

Can someone help me? I am trying to wrap the text in each column so the last column has the largest width.

\documentclass{article}

\usepackage{makecell, tabularx}
\renewcommand\theadfont{\bfseries}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}

\begin{table}
\footnotesize
\setlength\tabcolsep{3pt}
\begin{tabularx}{\textwidth}           {|*{6}{ L| } } 
    \hline
    \thead[b]{Risk}  
    &   \thead[b]{Likelihood}                        
    &   \thead[b]{Impact}                        
    &   \thead[b]{Overall}
    &   \thead[b]{Response}                                               
    \\ \hline
    Going over budget      
    &   M                          
    &   L
    &   M
    &   \textbf{Preventative:} Keep track of all spending and have clearance of all potential spending by all project team members as well as the sponsor.
    \\ \hline
    Not having staff ambassadors
    &   M    
    &   L                           
    &   M
    &   \textbf{Preventative:} Ask as many staff members as possible to maximise the chances of having staff agreeing to represent their school. 
    \\ \hline
    Small turnout for event                
    &   M                         
    &   M
    &   M
    &   \textbf{Preventative:} Raise awareness for the event for at least a month in advance and continue to raise awareness.\newline \textbf{Opportunity:} Allows for a more intimate event and gain detailed attendee feedback                                                    
    \\ \hline
    Not meeting project event deadline                
    &    L
    &    H
    &    M
    &   \textbf{Preventive:} Ensure that all project team members meet their individual task deadlines and allow for some float time by constructing a critical path analysis
    \\ \hline
    Reaching venue capacity               
    &    M
    &    H
    &    M
    &   \textbf{Preventive:} Have attendees RSVP to the event to give an indication of numbers for the event which will allow the project team \newline 
    \textbf{Opportunity:} Allows for a bigger audience for the team to deliver the presentation to and create greater awareness of the collaboration tool.
    \\ \hline
    Technical issues during showcase              
    &    H
    &    H
    &    H
    &   \textbf{Preventive:} test all technical equipment before event begins\newline
    \textbf{Corrective:} have back-up devices ready \newline
    Connect to mobile phone internet 
    \\ \hline
    Catering for event does not deliver              
    &    M
    &    L
    &    M
    &   \textbf{Preventive:} Confirm with catering providers that food and drink will be delivered on time\newline 
    \textbf{Corrective:  }
    \\ \hline
    Sponsor does not agree with event plans             
    &    L
    &    H
    &    M
    &   \textbf{Preventive:} have continuous communication with the sponsor and have them sign everything off
    \\ \hline   
\end{tabularx}
\end{table}

\end{document}

Best Answer

The following uses a fixed-width column for the first column - p{<len>}, followed by three centred columns and a final X-like column (that uses a \raggedright alignment:

enter image description here

\documentclass{article}

\usepackage{makecell, tabularx}
\renewcommand\theadfont{\bfseries}
\newcolumntype{L}{>{\raggedright\arraybackslash}X}

\begin{document}

\noindent
\begingroup
\footnotesize
\setlength\tabcolsep{3pt}%
\begin{tabularx}{\linewidth}{ | >{\raggedright}p{5em} | *{3}{ c| } L| } 
    \hline
    \thead[b]{Risk}  
    &   \thead[b]{Likelihood}                        
    &   \thead[b]{Impact}                        
    &   \thead[b]{Overall}
    &   \thead[b]{Response}                                               
    \\ \hline
    Going over budget      
    &   M                          
    &   L
    &   M
    &   \textbf{Preventative:} Keep track of all spending and have clearance of all potential spending by all project team members as well as the sponsor.
    \\ \hline
    Not having staff ambassadors
    &   M    
    &   L                           
    &   M
    &   \textbf{Preventative:} Ask as many staff members as possible to maximise the chances of having staff agreeing to represent their school. 
    \\ \hline
    Small turnout for event                
    &   M                         
    &   M
    &   M
    &   \textbf{Preventative:} Raise awareness for the event for at least a month in advance and continue to raise awareness.\newline \textbf{Opportunity:} Allows for a more intimate event and gain detailed attendee feedback                                                    
    \\ \hline
    Not meeting project event deadline                
    &    L
    &    H
    &    M
    &   \textbf{Preventive:} Ensure that all project team members meet their individual task deadlines and allow for some float time by constructing a critical path analysis
    \\ \hline
    Reaching venue capacity               
    &    M
    &    H
    &    M
    &   \textbf{Preventive:} Have attendees RSVP to the event to give an indication of numbers for the event which will allow the project team \newline 
    \textbf{Opportunity:} Allows for a bigger audience for the team to deliver the presentation to and create greater awareness of the collaboration tool.
    \\ \hline
    Technical issues during showcase              
    &    H
    &    H
    &    H
    &   \textbf{Preventive:} test all technical equipment before event begins\newline
    \textbf{Corrective:} have back-up devices ready \newline
    Connect to mobile phone internet 
    \\ \hline
    Catering for event does not deliver              
    &    M
    &    L
    &    M
    &   \textbf{Preventive:} Confirm with catering providers that food and drink will be delivered on time\newline 
    \textbf{Corrective:  }
    \\ \hline
    Sponsor does not agree with event plans             
    &    L
    &    H
    &    M
    &   \textbf{Preventive:} have continuous communication with the sponsor and have them sign everything off
    \\ \hline   
\end{tabularx}
\endgroup

\end{document}

You can fiddle with the length <len> to suit your needs.

Note that your table only has five columns (you've set *{6}{..}). Also, I've used a % after \setlength{\tabcolsep}{3pt} as it introduces a spurious space that you want to avoid.

Related Question