8

My code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[table]{xcolor}
\usepackage{enumitem}
\newlist{tabitem}{itemize}{1}
\setlist[tabitem]{nosep,     
                  topsep     = 0pt,
                  partopsep  = 0pt,
                  leftmargin = *,
                  label      = \textbullet,
                  before = \vspace{-0.5\baselineskip},
                  after = \vspace{-0.5\baselineskip}}


\begin{document}
\begin{table*}[t]
\caption{XYZ}
\centering
\setlength\extrarowheight{2pt}
\setlength\arrayrulewidth{2pt}
\arrayrulecolor{white}

    \begin{tabular}{|p{35mm}| p{35mm} | p{35mm} |}
    \rowcolor{gray!40}
    \hline
    A    &   B    & V   \\

    \hline
    \rowcolor{gray!5}
          Something here very well comes& 
          \begin{tabitem}
          \item Something here verywellcomes
          \item Something here verywellcomes
          \end{tabitem} &
          \begin{tabitem}
          \item Something here very well comes
          \end{tabitem} \\


    \hline
    \rowcolor{gray!5}
          Something here very well comes& 
          \begin{tabitem}
          \item Something here verywellcomes
          \item Something here verywellcomes
          \end{tabitem} &
          \begin{tabitem}
          \item Something here very well comes
          \item Something here very well comes
          \end{tabitem} \\


  \end{tabular}
\end{table*}
\end{document}

This results in this:-

enter image description here

Why is there extra spacing between words in the second column? I want left-aligned text. I don't want them to be expanded automatically to fill the entire line by adding white spaces in between. Can someone suggest a way to make the texts left-aligned rather than justified-aligned?

9

The tabular environment in your document uses 3 columns of type p ("paragraph"), and the columns only 35mm wide. Lines of text in a p-type column are fully justified. As you've discovered, this can lead to unsatisfactory outcomes, such as large gaps between words, if the columns are quite narrow. This issue becomes particularly prominent if the cells contain long words (e.g., "verywellcomes") for which LaTeX can't find any good hyphenation points.

You should probably switch to a ragged-right layout for the three columns, while still permitting hyphenation. This may be achieved by adding the following two lines in the preamble:

\usepackage{array,ragged2e}
\newcolumntype{P}[1]{>{\RaggedRight\arraybackslash}p{#1}}

and changing the line

\begin{tabular}{|p{35mm}| p{35mm} | p{35mm} |}

to

\begin{tabular}{|P{35mm}| P{35mm} | P{35mm} |}

This fix assumes, naturally, that you want to keep 35mm as the usable width of the three columns.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.