Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm doing the following:

\begin{tabular}{
    p{0.20\textwidth}
    p{0.20\textwidth}
    p{0.20\textwidth}
    p{0.20\textwidth}
}

  2009 &
  2010 &
  2011 &
  2012 \\

  \hline

  Menores custos &
  Menores custos &
  Liberdade de comercialização &
  Liberdade de comercialização \\

\end{tabular}

And getting the following:

enter image description here

How can I get rid of these big spaces and turn them into into 'normal' spaces, giving a better perspective of left alignment putting the words "Liberdade" and "de" together?

enter image description here

I need to keep these 0.2\textwidth column widths.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Narrow columns are hard to handle; in these cases, one possible alternative is to use use \raggedright columns:

\documentclass{article}
\usepackage{array}

\begin{document}

\begin{tabular}{
    >{\raggedright\arraybackslash}p{0.20\textwidth}
    >{\raggedright\arraybackslash}p{0.20\textwidth}
    >{\raggedright\arraybackslash}p{0.20\textwidth}
    >{\raggedright\arraybackslash}p{0.20\textwidth}
}

  2009 &
  2010 &
  2011 &
  2012 \\

  \hline

  Menores custos &
  Menores custos &
  Liberdade de comercialização &
  Liberdade de comercialização \\
\end{tabular}

\end{document}

enter image description here

As egreg mentions in his comment, using \RaggedRight from the ragged2e package can be a better option, since now hyphenation is allowed and it outputs less ragged columns:

\documentclass{article}
\usepackage{ragged2e}
\usepackage{array}

\begin{document}

\begin{tabular}{
    >{\RaggedRight\arraybackslash}p{0.20\textwidth}
    >{\RaggedRight\arraybackslash}p{0.20\textwidth}
    >{\RaggedRight\arraybackslash}p{0.20\textwidth}
    >{\RaggedRight\arraybackslash}p{0.20\textwidth}
}

  2009 &
  2010 &
  2011 &
  2012 \\

  \hline

  Menores custos &
  Menores custos &
  Liberdade de comercialização &
  Liberdade de comercialização \\
\end{tabular}

\end{document}
share|improve this answer
    
Also \RaggedRight from ragged2e that allows hyphenation and outputs less ragged columns. –  egreg Nov 3 '12 at 16:08
    
@egreg: yes; I've added this option to my answer. –  Gonzalo Medina Nov 3 '12 at 16:17

You can use raggedright inside p columns.

\documentclass{standalone}
\begin{document}
\begin{tabular}{
    p{0.20\textwidth}
    p{0.20\textwidth}
    p{0.20\textwidth}
    p{0.20\textwidth}
}

  2009 &
  2010 &
  2011 &
  2012 \\

  \hline

  Menores custos &
  Menores custos &
  \raggedright Liberdade de comercialização &
  \raggedright Liberdade de comercialização 

\end{tabular}

\end{document}

enter image description here

share|improve this answer
1  
beware the \\ there is a forced raggedright line break, not an end of table row. As it's the end of the table anyway, safest is simply not to use \\ . –  David Carlisle Nov 3 '12 at 16:07
    
@DavidCarlisle: Uh!. Remnant of OP's code. Didn't notice at all. Thank you. Corrected now. :-) –  Harish Kumar Nov 3 '12 at 16:22

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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