1

Generally speaking, what I want to do is spanning the content to fill the whole table cell instead of simple alignments. It should look like column3. Is there a way to do this?

This is what I want

I am new to latex and I am not a native English speaker. I hope I have made my points clear.

user217719
  • 11
  • 1
  • 1
    If I understand you correctly you want to stretch the distance between each letter in a word as well as the blank spaces between words. Is that correct? Please also add some background information on the pupose of this. How do you currently set up your tables? How long is "Some Contents" supposed to be? Single words or longer text? – leandriis Jun 07 '20 at 18:44
  • Some useful suggestions can be found in answers to this question: fully stretch text horizontally on page – barbara beeton Jun 08 '20 at 20:27

2 Answers2

1

Try this (I admit that I don't know how it works, but it does for me)

\documentclass{article}
\usepackage{soul}

\begin{document}

\sodef\spaceout{}{0pt plus 1fil}{.4em plus 1fil}{0pt}

\begin{tabular}{|c|c|c|}
\hline
    \spaceout{Column 1} & \spaceout{Column 2} & \spaceout{Column 3} \\\hline
    \spaceout{something} & \spaceout{some content} & \spaceout{some content} \\\hline
    \spaceout{something} & \spaceout{some content} & \spaceout{some content} \\\hline
\end{tabular}

\end{document}

I have adapted the information obtained from fully stretch text horizontally on page.

Carbonard
  • 21
  • 4
1

It is not clear if you want to justify increasing inter-word spacing, or also the letter spacing, with or without hyphenation, and in multiline cells, if the last line must be also justified.

The table shows possible combinations playing with \makebox in cell with single lines and \parfillskip in cells with paragraphs, and \so (of soul package) to increase the space between characters, in already justified column and left aligned columns.

mwe

The bad spacing between words forcing justification could be mitigated in some extent playing with \emergencystretch, or using themicrotype package Not showed in the MWE), but do not expect miracles. And including spaces between characters only gets worse.

So, whatever the true goal is, the conclusion IMHO is the same: Do not do that! Only in very wide columns, with a lot of text, full justification will be not harmful, and I will not suggest you make tables with a lot of text, but the opposite. The MWE code:

\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage{array}
\usepackage{ragged2e} 
\usepackage{booktabs} % good for any table ... except for this MWE ;-)
\extrarowheight2pt
\usepackage{soul}
\begin{document}
\begin{tabular}{|l|l|>{\raggedright}p{6cm}|p{6cm}|}\hline
1 & % reference row (normal text)
Some content. &  
Some content, some content some content. &  
Some content, some content some content.  \\\hline
2 & % interword spacing 
\parfillskip0pt Some content.  &                             % ooopss !!
\parfillskip0pt Some content, some content some content.  &  % ooopss !!
\parfillskip0pt Some content, some content some content.     \\\hline
3 & % interword spacing again
\makebox[4cm][s]{Some content.}  & 
\justifying\parfillskip0pt\noindent Some content, some content some content. & 
\parfillskip0pt Some content, some content some content.  \\\hline
4 & % interletter spacing 
\so{Some content.} & 
\so{Some content, some content some content.}  &
\so{Some content, some content some content.}  \\\hline 
5 & % interword and interletter spacing 
\makebox[4cm][s]{\so{Some content.}} & 
\justifying\parfillskip0pt\noindent \parfillskip0pt \so{Some content, some content some content.}  &
\parfillskip0pt \so{Some content, some content some content.}  \\\hline 
\end{tabular}
\end{document}
Fran
  • 80,769