Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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!

share|improve this question
    
Plese compose a compilable MWE that illustrates the problem including the \documentclass and the appropriate packages. –  Peter Grill Nov 22 '11 at 10:18

1 Answer 1

up vote 2 down vote accepted

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}
share|improve this answer
    
Thanks for the help, and thanks for the helpful explanation! Along with \noindent right before the tabular environment, removing the "padding" in the first column did the trick. –  Daniel Balestrini Nov 22 '11 at 20:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.