[Tex/LaTex] avoiding indentation in tabularx environment with proportionally defined columns

tabularx

I'm using the tabularx environment (XeTeX, MiKTeX 2.8, TeXnicCenter) with four porportionally defined columns (see below). I cannot figure out how to prevent the resulting table from being slightly indented from the left margin. I also consulted David Carlisle's documentation from 1999.

Thanks to Ulrike Fischer's answer to a question on the matter in 2007 (http://newsgroups.derkeiler.com/Archive/Comp/comp.text.tex/2007-01/msg00322.html), I've manged to do this in other, similar tabularx situations. The tables based on the next two set-ups do not indent (i.e., they do what I want in this respect):

\begin{tabularx}{\hsize}{@{}lX} ...

and

\begin{tabularx}{\linewidth}{@{}l@{\extracolsep{5mm}}X} ...

But I lack enough understanding of what I am doing to transfer this fix (adding @{}) into my current table. How can I prevent the slight indentation of my table in the following case?

\noindent
{\Large \textbf{Week Four -- Homework Sheet One} \normalsize}

\begin{tabularx}{\linewidth}{>{\setlength\hsize{.5\hsize}}X>{\setlength\hsize{.1\hsize}}X>{\RaggedRight\setlength\hsize{1.7\hsize}}X>{\setlength\hsize{1.7\hsize}}X}

\begin{tikzpicture} \draw (0,0) rectangle (0.5,0.5); \draw (1.25,.25) circle (.25cm); \end{tikzpicture}&1.&\multicolumn{2}{l}{First estimate and then add together: \begin{math}97,234 + 20,117 + 8,877\end{math}}\tabularnewline

&&Estimate:&Answer:\tabularnewline

%further rows of data

\end{tabularx}

Thank you!

Best Answer

What you see is not an indent of the table, but an indent of the first column's contents relative to the left border of the table.

A vertical line makes this visible:

\begin{tabularx}{\linewidth}{|>{\setlength\hsize{.5\hsize}}X>{\setlength\hsize{.1\hsize}}X>{\RaggedRight\setlength\hsize{1.7\hsize}}X>{\setlength\hsize{1.7\hsize}}X}

You see how the line is not indented, the column contents are offset from the line.

The @{} command suppresses the default padding, and replaces it with whatever you specify between the parentheses - nothing, in this case.

The @{} must be specified before the >{} (which adds whatever is between the parentheses to the column contents in each row).

I.e., your solution would be (for the first column only):

\begin{tabularx}{\linewidth}{@{}>{\setlength\hsize{.5\hsize}}X>{\setlength\hsize{.1\hsize}}X>{\RaggedRight\setlength\hsize{1.7\hsize}}X>{\setlength\hsize{1.7\hsize}}X}