# Need to wrap the text in a column

some texts inside a column should be wrapped to the next line, however as I see from the following code, the text length is too large that interfere with the rightmost columns.

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{array}
\usepackage{ragged2e}
\usepackage{multirow}

\begin{document}
The table \ref{label1}

\begin{table}
\centering
\caption{my table}
\label{label1}
\begin{tabular}{ |l|p{4cm}|p{1cm}| }
\hline
A & B & C \\
\hline
\multirow{3}{*}{Gromacs}   &  \texttt{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}    &    62\%   \\
&  \texttt{bbbbbb}     &    15 \%   \\
&  \texttt{cccccccccccccccccccccccccccccc}   &   10\%   \\
\hline
\end{tabular}
\end{table}

\end{document}


The output is shown below

• It should wrap to the next line, except LaTeX doesn't know where to hyphenate, due to the choice of a long unknownn ‘word’. – Bernard Feb 7 at 9:23
• So, how can I fix that? Or even using smaller font size for that column?! – mahmood Feb 7 at 10:04
• With normal sentences, it will wrap. Maybe you can load the ragged2e and array packages and replace p{4cm} with >{\RaggedRight}p{4cm}.. Also setting \tabcolsep to a lower value (default is 6pt) and making the last column as c can help. Last suggestion: use tabularx, this way: \begin{tabularx}{\columnwidth}{l>{\RaggedRight}Xc} ... \end{tabularx}. – Bernard Feb 7 at 10:15
• \begin{tabular}{ |l|>{\RaggedRight}p{4cm}|>{\RaggedRight}p{2cm}| } has no effect – mahmood Feb 7 at 10:21
• For introducing hyphenation in non-standard words, you can add \- in the middle of the word at the hyphenation point. If it needs to break there, the hyphen will be added...if not, the hyphen won't show. Also, as others have noted, ragged right justification helps the appearance in narrow columns. – Steven B. Segletes Feb 7 at 12:24

Here is a solution, with tabularx and xurl. I added a variant, which automates word wrapping in the whole column, in case all cells in the second column (except the column head) should be typed in this way, with the collcell package.

\documentclass[conference]{IEEEtran}
\IEEEoverridecommandlockouts
\usepackage{tabularx}
\usepackage{seqsplit}
\usepackage{xurl, collcell}
\newcolumntype{U}{>{\collectcell\url}X <{\endcollectcell}}

\usepackage{multirow}
\AtBeginDocument{\def\UrlFont{\tt}}

\begin{document}

\noindent Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.

The table \ref{label1}
\begin{table}[!h]
\centering%
\setlength{\extrarowheight}{2pt}
\caption{my table}
\label{label1}
\begin{tabularx}{\columnwidth}{ |l|U|l| }
\hline
A & \multicolumn{1}{l}{B }& C \\
\hline
\multirow{3}{*}{Gromacs} & aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa & 62\% \\
& non_bonded_Elec_uiF_pos_non_bonded_Elec_uiF_pos & 15 \% \\
& cccccccccccccccccccccccccccccc & 10\% \\
\hline
\end{tabularx}
\end{table}

\noindent Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.
\begin{table}[!h]
\centering%
\setlength{\extrarowheight}{2pt}
\caption{my table}
\label{label1a}
\begin{tabularx}{\columnwidth}{ |l|X|l| }
\hline
A & B & C \\
\hline
\multirow{3}{*}{Gromacs} & \url{aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa}& 62\% \\
& \url{non_bonded_Elec_uiF_pos_non_bonded_Elec_uiF_pos} & 15 \% \\
& \url{cccccccccccccccccccccccccccccc} & 10\% \\
\hline
\end{tabularx}
\end{table}
noindent Some text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text. Some more text.

\end{document}


• Thanks for the solution. I found that \url will do the whole job! You can try \usepackage{xurl} and \AtBeginDocument{\def\UrlFont{\tt}} and \begin{tabular}{ |l|p{4cm}|p{2cm}| } and \url{cccccccccccccccccccccccccccccc}. – mahmood Feb 7 at 13:23
• xurl loads url, but can split ‘urls’ at more points. – Bernard Feb 7 at 13:45
• Yeah... That is interesting. Because instead of courier, I can use url and it will better handle the hyphenation. – mahmood Feb 7 at 13:47