[Tex/LaTex] My table is too wide for the page, how can I make text wrap on specific columns

tables

Below is the code for my table (generated using http://www.tablesgenerator.com/), unfortunately changing the tabular argument to use p with a set width doesn't seem to be working.

\documentclass[11pt,a4paper]{report}
\begin{document}
% Please add the following required packages to your document preamble:
% \usepackage{booktabs}
\begin{table}[]
\centering
\caption{My caption}
\label{my-label}
\begin{tabular}{@{}|ll|l|l|l|l|@{}}
\toprule
\multicolumn{1}{|r}{\textbf{Browser:}}     & Chrome        &                                 & \multicolumn{3}{c|}{\textit{\textbf{All T2 tests are ran following T1-02}}}                                                                                                                                                              \\ \midrule
\multicolumn{1}{|l|}{\textbf{Test number}} & \textbf{Page} & \textbf{Test description}       & \textbf{Steps}                                                                                       & \textbf{Expected outcome}                                                                                  & \textbf{Pass? (Y/N)} \\ \midrule
\multicolumn{1}{|l|}{T2-01}                & Itinerary     & Rename itinerary                & Click edit icon, to the right of the itinerary name, type 'mytinerary' and click the edit icon again & The name 'mytinerary' is now the displayed name for the itinerary                                          & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-02}                & Itinerary     & Rename itinerary                & Click edit icon, to the right of the itinerary name, type 'mytinerary' and press enter               & The name 'mytinerary' is now the displayed name for the itinerary                                          & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-03}                & Itinerary     & Reset itinerary name            & Repeat T2-02. Click the edit icon, delete all text in the field and press enter                      & The original location 'London, United Kingdom' is the displayed name for the itinerary                     & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-04}                & Itinerary     & Reset itinerary                 & Click the 'Restart' button                                                                           & Redirected to the landing page, there is an additional button with text "Revisit 'London, United Kingdom'" & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-05}                & Itinerary     & Reset and rejoin itinerary      & Click the 'Restart' button, then click the 'Revisit' button                                          & Redirected to the landing page and then brought back to the itinerary page                                 & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-06}                & Itinerary     & Access venue information        & Click the name of the first itinerary item                                                           & Pop-up menu activates and displays information for the venue.                                              & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-07}                & Itinerary     & Close venue information         & Repeat T2-06 and then click the 'x' icon                                                             & Pop-up menu closes and you are left on the itinerary page                                                  & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-08}                & Itinerary     & Close venue information         & Repeat T2-06 and press the escape key                                                                & Pop-up menu closes and you are left on the itinerary page                                                  & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-09}                & Itinerary     & Next venue                      & Click the right arrow for an itinerary item                                                          & Venue name should change                                                                                   & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-10}                & Itinerary     & Previous venue                  & Repeat T2-09 and then click the left arrow of the same itinerary item                                & Venue name should be unchanged                                                                             & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-11}                & Itinerary     & Open genre menu                 & Click the genre menu                                                                                 & Genre menu is displayed                                                                                    & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-12}                & Itinerary     & Close genre menu                & Repeat T2-12 and click close button                                                                  & Genre menu is not displayed                                                                                & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-13}                & Itinerary     & Close genre menu                & Repeat T2-12 and click the genre menu                                                                & Genre menu is not displayed                                                                                & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-14}                & Itinerary     & Add genre venue options         & Repeat T2-12 and click a glyph                                                                       & Genre menu displayed, clicked glyph has been highlighted and the venue has changed                         & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-15}                & Itinerary     & Pin item                        & Click the pin button for an itinerary item                                                           & Pin button is filled                                                                                       & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-16}                & Itinerary     & Unpin Item                      & Repeat T2-15 and then click the pin button again                                                     & Pin button is hollow                                                                                       & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-17}                & Itinerary     & Next venue for pinned item      & Repeat T2-15 and click an arrow button                                                               & No change in the itinerary item                                                                            & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-18}                & Itinerary     & Open genre menu for pinned item & Repeat T2-15 and click the genre menu                                                                & No change in the itinerary item                                                                            & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-19}                & Itinerary     & Drag itinerary item             & Drag the first itinerary item over the last itinerary item                                           & An orange bar should appear between the last two itinerary items                                           & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-20}                & Itinerary     & Drag and drop itinerary item    & Drag the last itinerary item over the first itinerary item and drop it                               & The itinerary item that was dragged should now be at the top of the itinerary                              & Y                    \\ \midrule
\multicolumn{1}{|l|}{T2-21}                & Itinerary     & Expose travel elements          & Pin all 5 itinerary items                                                                            & The travel elements should now be displayed underneath all but the last itinerary item                     & Y                    \\ \bottomrule
\end{tabular}
\end{table}
\end{document}

The table in my document looks like this:

Table as in my document

I'm using my university's dissertation template found here on Overleaf.

How can I make the 3rd to 5th columns wrap text in cells?

Best Answer

Like this?

enter image description here I suggest to use tabularx environment. Since you didn't provide any information about page layout, I select margin=25mm in use of package geometry. Since table is huge, I also suggest to use smaller font size (\small`). In MWE below I consider only first ten rows:

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, makecell, tabularx}
\renewcommand\theadfont{\bfseries\small}
\newcolumntype{R}{>{\RaggedRight}X}

  \begin{document}
\begin{table}[ht]
    \small
    \setlength\tabcolsep{3pt}
\centering
\caption{My caption}
\label{my-label}
\begin{tabularx}{\linewidth}{@{} ll >{\hsize=0.6\hsize}R 
                                    >{\hsize=1.2\hsize}R 
                                    >{\hsize=1.2\hsize}R 
                                 c @{}}
\toprule
\multicolumn{2}{l}{\textbf{Browser:}    Chrome}         &                                 
        & \multicolumn{3}{c}{\textit{\textbf{All T2 tests are ran following T1-02}}}   \\
    \midrule
\thead[b]{Test\\ num.}  
    &   \thead[b]{Page}
        &   \thead[b]{Test\\ description}
            &   \thead[b]{Steps}
                &   \thead[b]{Expected\\ outcome}
                    &   \thead[b]{Pass?\\ (Y/N)}                \\
    \midrule
T2-01   &   Itinerary   &   Rename itinerary
                            &   Click edit icon, to the right of the itinerary name,
                                type 'mytinerary' and click the edit icon again
                                &   The name 'mytinerary' is now the displayed name for the itinerary
                                    &   Y                   \\
    \addlinespace
T2-02   &   Itinerary   & Rename itinerary
                            &   Click edit icon, to the right of the itinerary name,
                                type 'mytinerary' and press enter
                                &   The name 'mytinerary' is now the displayed name for the itinerary
                                    &   Y                   \\
    \addlinespace
T2-03   & Itinerary & Reset itinerary name
                        &   Repeat T2-02. Click the edit icon,
                            delete all text in the field and press enter
                            &   The original location 'London, United Kingdom'
                                is the displayed name for the itinerary
                                &   Y                       \\
    \addlinespace
T2-04   &   Itinerary   &   Reset itinerary
                            &   Click the 'Restart' button
                                &   Redirected to the landing page,
                                    there is an additional button with text
                                    "Revisit 'London, United Kingdom'"
                                    &   Y                   \\
    \addlinespace
T2-05   &   Itinerary   &   Reset and rejoin itinerary
                            &   Click the 'Restart' button,
                                then click the 'Revisit' button
                                &   Redirected to the landing page and
                                    then brought back to the itinerary page
                                    &   Y                   \\
    \addlinespace
T2-06   &   Itinerary   &   Access venue information
                            &   Click the name of the first itinerary item
                                &   Pop-up menu activates and displays information for the venue
                                    &   Y                   \\
    \addlinespace
T2-07   &   Itinerary   &   Close venue information
                            &   Repeat T2-06 and then click the 'x' icon
                                &   Pop-up menu closes and you are left on the itinerary page
                                    &   Y                   \\
    \addlinespace
T2-08   &   Itinerary   &   Close venue information
                            &   Repeat T2-06 and press the escape key
                                &   Pop-up menu closes and you are left on the itinerary page
                                    &   Y                   \\
    \addlinespace
T2-09   &   Itinerary   &   Next venue
                            &   Click the right arrow for an itinerary item
                                &   Venue name should change
                                    &   Y                   \\
    \addlinespace
T2-10   &   Itinerary   &   Previous venue
                            &   Repeat T2-09 and then click the left arrow of the same itinerary item                                & Venue name should be unchanged                                                                             & Y                             \\
    \bottomrule
\end{tabularx}
\end{table}
     \end{document}

Addendum: In case of that table is longer than one page, you can use tablex package. It provide combination of tabularx and longtable environments:

\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{ragged2e}
\usepackage{booktabs, ltablex, makecell, tabularx}
\renewcommand\theadfont{\bfseries\small}
\newcolumntype{R}{>{\RaggedRight}X}

  \begin{document}
{
    \small
    \setlength\tabcolsep{3pt}
\begin{tabularx}{\linewidth}{@{} ll >{\hsize=0.6\hsize}R 
                                    >{\hsize=1.2\hsize}R 
                                    >{\hsize=1.2\hsize}R 
                                 c @{}}
    \caption{My caption}
\label{my-label}    \\
\toprule
\multicolumn{2}{l}{\textbf{Browser:}    Chrome}         &                                 
        & \multicolumn{3}{c}{\textit{\textbf{All T2 tests are ran following T1-02}}}   \\
    \midrule
\thead[b]{Test\\ num.}  
    &   \thead[b]{Page}
        &   \thead[b]{Test\\ description}
            &   \thead[b]{Steps}
                &   \thead[b]{Expected\\ outcome}
                    &   \thead[b]{Pass?\\ (Y/N)}                \\
    \midrule
\endfirsthead
    \caption{My caption (cont.)}                                \\
    \toprule
\multicolumn{2}{l}{\textbf{Browser:}    Chrome}         &
        & \multicolumn{3}{c}{\textit{\textbf{All T2 tests are ran following T1-02}}}   \\
    \midrule
\thead[b]{Test\\ num.}
    &   \thead[b]{Page}
        &   \thead[b]{Test\\ description}
            &   \thead[b]{Steps}
                &   \thead[b]{Expected\\ outcome}
                    &   \thead[b]{Pass?\\ (Y/N)}                \\
    \midrule
\endhead
    \midrule[0.8pt]
\multicolumn{6}{r}{continue on the next page}\\
\endfoot
    \bottomrule
\endlastfoot
T2-01   &   Itinerary   &   Rename itinerary
                            &   Click edit icon, to the right of the itinerary name,
                                type 'mytinerary' and click the edit icon again
                                &   The name 'mytinerary' is now the displayed name for the itinerary
                                    &   Y                   \\
    \addlinespace
T2-02   &   Itinerary   & Rename itinerary
                            &   Click edit icon, to the right of the itinerary name,
                                type 'mytinerary' and press enter
                                &   The name 'mytinerary' is now the displayed name for the itinerary
                                    &   Y                   \\
    \addlinespace
T2-03   & Itinerary & Reset itinerary name
                        &   Repeat T2-02. Click the edit icon,
                            delete all text in the field and press enter
                            &   The original location 'London, United Kingdom'
                                is the displayed name for the itinerary
                                &   Y                       \\
    \addlinespace
T2-04   &   Itinerary   &   Reset itinerary
                            &   Click the 'Restart' button
                                &   Redirected to the landing page,
                                    there is an additional button with text
                                    "Revisit 'London, United Kingdom'"
                                    &   Y                   \\
    \addlinespace
T2-05   &   Itinerary   &   Reset and rejoin itinerary
                            &   Click the 'Restart' button,
                                then click the 'Revisit' button
                                &   Redirected to the landing page and
                                    then brought back to the itinerary page
                                    &   Y                   \\
    \addlinespace
T2-06   &   Itinerary   &   Access venue information
                            &   Click the name of the first itinerary item
                                &   Pop-up menu activates and displays information for the venue
                                    &   Y                   \\
    \addlinespace
T2-07   &   Itinerary   &   Close venue information
                            &   Repeat T2-06 and then click the 'x' icon
                                &   Pop-up menu closes and you are left on the itinerary page
                                    &   Y                   \\
    \addlinespace
T2-08   &   Itinerary   &   Close venue information
                            &   Repeat T2-06 and press the escape key
                                &   Pop-up menu closes and you are left on the itinerary page
                                    &   Y                   \\
    \addlinespace
T2-09   &   Itinerary   &   Next venue
                            &   Click the right arrow for an itinerary item
                                &   Venue name should change
                                    &   Y                   \\
    \addlinespace
T2-10   &   Itinerary   &   Previous venue
                            &   Repeat T2-09 and then click the left arrow of the same itinerary item 
                                & Venue name should be unchanged
                                    &   Y                   \\
    \addlinespace
T2-11  &    Itinerary   &   Open genre menu                 
                            &   Click the genre menu
                                &   Genre menu is displayed 
                                    &   Y                   \\
    \addlinespace
T2-12  &    Itinerary   &    Close genre menu                
                            &   Repeat T2-12 and click close button
                                &   Genre menu is not displayed
                                    &   Y                   \\
    \addlinespace
T2-13  &    Itinerary   &   Close genre menu                
                            &   Repeat T2-12 and click the genre menu 
                                &   Genre menu is not displayed
                                    &   Y                   \\
    \addlinespace
T2-14  &    Itinerary   &   Add genre venue options
                            &   Repeat T2-12 and click a glyph
                                &   Genre menu displayed, 
                                    clicked glyph has been highlighted and the venue has changed
                                    &   Y                   \\
    \addlinespace
T2-15  &    Itinerary   &   Pin item                        
                            &   Click the pin button for an itinerary item 
                                &   Pin button is filled                                    clicked glyph has been highlighted and the venue has changed
                                    &   Y                   \\
    \addlinespace                                
T2-16  &    Itinerary   &   Unpin Item 
                            &   Repeat T2-15 and then click the pin button again
                                &   Pin button is hollow
                                    &   Y                   \\
    \addlinespace
T2-17  &    Itinerary   &   Next venue for pinned item 
                            &   Repeat T2-15 and click an arrow button
                                &   No change in the itinerary item
                                    &   Y                   \\
    \addlinespace
T2-18  &    Itinerary   &   Open genre menu for pinned item 
                            &   Repeat T2-15 and click the genre menu
                                &   No change in the itinerary item
                                    &   Y                   \\
    \addlinespace
T2-19  &    Itinerary   &   Drag itinerary item             
                            &   Drag the first itinerary item over the last itinerary item
                                &   An orange bar should appear between the last two itinerary items
                                    &   Y                   \\
    \addlinespace
T2-20  &    Itinerary   &   Drag and drop itinerary item    
                            &   Drag the last itinerary item over the first itinerary item and drop it
                                &   The itinerary item that was dragged should now be at the top of the itinerary
                                    &   Y                   \\
    \addlinespace
T2-21  &    Itinerary   &   Expose travel elements          
                            &   Pin all 5 itinerary items
                                &   The travel elements should now be displayed 
                                    underneath all but the last itinerary item
                                    &   Y                   \\
\end{tabularx}
}
     \end{document}

enter image description here