I want a table with two columns; the left column should be left-justified, the right right-justified, but with possible manual line breaks in either column. I am using a tabularx environment \begin{tabularx}{\textwidth}{X|X} which I believe should automatically calculate the column size to be exactly half the textwidth value. To right justify the second column, I try the following:
\begin{tabularx}{\textwidth}{| X | >{\raggedleft\arraybackslash}X |}
\hline
Left line 1 (which could be quite long) \newline
Left line 2 \newline
Left line 3
&
Right line 1 (which could also be quite long) \newline
Right line 2 \newline
Right line 3 \newline
Right line 4
\tabularnewline
\hline
\end{tabularx}
Here I end the table after just one row, but in principle I may want more similar such rows.
When I compile, the right column is not right aligned - only the last "Right line 4" is:
If I do not put the \newlines in then the right column is right justified as I expect (but as a single paragraph without manual linebreaks). The \newline seems to clash somewhere with the alignment, and I can't figure out how.
I notice that if I use \linebreak instead of \newline my problem goes away. Is this a correct usage of linebreak though?
Can someone explain why the newlines don't work as I expect? And what is the best solution? Many thanks in advance.


