# Two column table over textwidth is messing up right column (tabular*)

Problem solved: Package ltablex was loaded before tabularx and thus it didn't work. Using tabularx is working now!

So I would like to set up a table over the whole textwidth with two columns. It's almost working, except the right column is shifted to the right and I don't know how to fix this.

I tried to adapt the solution from this question: Setting table-width exactly to linewidth and this is the code

\documentclass[a4paper, 11pt, oneside]{scrbook}
%\usepackage{tabularx}
\begin{document}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}|l|l|}
\hline
left column & right column \\
\hline
left column & right column
\hline
\end{tabular*}
\end{document}


but this is the result:

Why is the right column so much shifted to the right? And the left column has zero space to the right. How can I fix this so that the left column uses as much space as needed and the right column fills the linewidth?

My desired output should look like this:

With the left column only using as much space as needed and the right column filling up the rest of the horizontal space.

I already tried it with tabularx but this isn't working either:

\documentclass[a4paper, 11pt, oneside]{scrbook}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{|X|X|}
\hline
left column & right column \\
\hline
left column & right column \\
\hline
\end{tabularx}
\end{document}


Here is the result:

• Welcome to TeX.SX! Use \noindent before the table. ->\noindent \begin{tabular*}. WIth \usepackage{showframe} you could visualize margins. – Bobyandbob Nov 19 '17 at 21:28
• Why not use the tabularx package and its flexible width X column? – leandriis Nov 19 '17 at 21:30
• Thank you! I didn't see the indent but this isn't my main problem. The right column should be left aligned next to the left column without that huge horizontal space in between. – Robert Nov 19 '17 at 21:30
• Already tried tabularx but with tabularx it isn't working at all. Will update the question with my tabularx example – Robert Nov 19 '17 at 21:33
• @Robert: could you please turn your code fragment into a compilable MWE? With the information you posted, I am not able to recreate the issue you have with tabularx. – leandriis Nov 19 '17 at 21:37

Use this column specification:

\documentclass[a4paper, 11pt, oneside]{scrbook}
\usepackage{tabularx}
\begin{document}
\begin{tabularx}{\linewidth}{|l|X|}
\hline
left column & right column \\
\hline
left column & right column \\
\hline
\end{tabularx}
\end{document}


• Problem solved... I had the package ltablex loaded before tabularx and thus it didn't work. It now works and your solution is the best looking! – Robert Nov 19 '17 at 21:56

It does work with tabularx:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\linewidth}{|X| >{\arraybackslash}X|}
\hline
left column & right column \\
\hline
left column & right column \\
\hline
\end{tabularx}

\end{document}