2

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.

3

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}
2
  • 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. Nov 3 '12 at 16:17
1

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

2
  • 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 \\ . Nov 3 '12 at 16:07
  • @DavidCarlisle: Uh!. Remnant of OP's code. Didn't notice at all. Thank you. Corrected now. :-)
    – user11232
    Nov 3 '12 at 16:22

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.