[Tex/LaTex] Aligning vertically centered and horizontally left text of cells in table

alignhorizontal alignmenttablesvertical alignment

My minimum working example :

\documentclass[11pt,a4paper]{article}
\usepackage[francais]{babel}
%\usepackage[latin1]{inputenc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tabularx}
\usepackage{array,multirow,makecell}
\setcellgapes{1pt}
\makegapedcells
\usepackage[table]{xcolor}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash }b{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash }b{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash }b{#1}}


\begin{document}

\begin{tabular}{m{.18\textwidth} m{.18\textwidth} m{.18\textwidth} m{.18\textwidth} m{.18\textwidth}} 
\hline \rowcolor{lightgray} Lipsum Lipsum Lipsum 1 & Lipsum Lipsum Lipsum 2 & Lipsum Lipsum Lipsum 3 & Lipsum Lipsum Lipsum 4 & Lipsum Lipsum Lipsum 5  \\
\hline Lipsum Lipsum Lipsum UNDER 1 & Lipsum Lipsum Lipsum UNDER 2 & Lipsum Lipsum Lipsum UNDER 3 & Lipsum Lipsum Lipsum UNDER 4 & Lipsum Lipsum Lipsum UNDER 5 \\
\hline
\end{tabular}


\end{document}

I am trying to align my table

  1. Centered vertically (this point seems ok)
  2. Left horizontally

However, given my above code the text is not aligned on left horizontally, but justified, which gives some horrible display with tons of word breaks. I simply want to force it aligned to left.

Issue

Thank you in advance for your help.

Best Answer

You defined a raggedright column type but didn't use it?

enter image description here

\documentclass[11pt,a4paper]{article}
\usepackage[francais]{babel}
%\usepackage[latin1]{inputenc}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{tabularx}
\usepackage{array,multirow,makecell}
\setcellgapes{1pt}
\makegapedcells
\usepackage[table]{xcolor}
\newcolumntype{R}[1]{>{\raggedleft\arraybackslash }m{#1}}
\newcolumntype{L}[1]{>{\raggedright\arraybackslash }m{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash }m{#1}}


\begin{document}

\begin{tabular}{L{.18\textwidth} L{.18\textwidth} L{.18\textwidth} L{.18\textwidth} L{.18\textwidth}} 
\hline \rowcolor{lightgray} Lipsum Lipsum 1 & x x x x x x x xLipsum Lipsum Lipsum 2 & Lipsum Lipsum Lipsum 3 & y y y y y y y y y  x x x x x x xLipsum Lipsum Lipsum 4 & Lipsum 5  \\
\hline Lipsum Lipsum UNDER 1 & Lipsum Lipsum UNDER 2 & Lipsum Lipsum Lipsum UNDER 3 & Lipsum Lipsum Lipsum UNDER 4 & Lipsum Lipsum g g g g gg g g Lipsum UNDER 5 \\
\hline
\end{tabular}


\end{document}
Related Question