# How do I put a table (float) two spaces away from the left margin?

I need to align the left edges of my tables such that they are two spaces off of the left margin (i.e. just like the first letter of an indented paragraph). Any ideas?

-
Thanks for the replies. I'm sure one of them will work. @Gonzalo amazingly informative answer. I can't test them now because I am trying to fix something else. I am writing a tool to convert thousands of documents from some descendant of RUNOFF markup and have them publication ready without humans retouching them. Not simple to do. I only have a little prior experience with LaTeX. Pulling my hair out today :p...Anyway, I will mark an answer as accepted once I fix what I broke and am actually able to try them out. – Huliax May 16 '12 at 20:58

The tabular environment, by default, adds half of the intercolumn space also at the left and the right of the table. Thus you have to remove that space:

\begin{tabular}{@{}lcr@{}}
<table contents>
\end{tabular}


If this is at the start of a paragraph (that is, after an empty line), it will be indented as normal.

-

There are two cases:

1. For the tabular environment used outside the floating table environment you don't need anything special if you use tabular starting a paragraph, since in this case it will be indented.

2. For the tabular environment used inside the floating table environment, you can use an \hspace* before the tabular environment:

\documentclass{article}
\usepackage{booktabs}
\usepackage{lipsum}% just to generate filler text for the example

\begin{document}
\lipsum*[2]

\begin{tabular}{@{}ll@{}}
\toprule
text & text \\
text & text \\
text & text \\
\bottomrule
\end{tabular}

\begin{table}[!ht]
\hspace*{15pt}\begin{tabular}{@{}ll@{}}
\toprule
text & text \\
text & text \\
text & text \\
\bottomrule
\end{tabular}
\end{table}
\lipsum*[2]

\end{document}


The appropriate value to use as the argument of \hspace* is given by \parindent (default: 15.0pt in standard classes with 10pt font size).

To automate this process you can patch the tabular environment (using the etoolbox package, for example) to include the horizontal spacing if inside a floating environment, and use an auxiliary length to keep the document's value for \parindent:

\documentclass{article}
\usepackage{booktabs}
\usepackage{etoolbox}
\usepackage{lipsum}

% We save the value of \parindent
\AtBeginDocument{
\newlength\mylen
\setlength\mylen{\parindent}
}

\makeatletter
\AtBeginEnvironment{tabular}{\ifnum\@floatpenalty<0 \hspace*{\mylen}\fi}
\makeatother

\begin{document}
\lipsum*[2]

\begin{tabular}{@{}ll@{}}
\toprule
text & text \\
text & text \\
text & text \\
\bottomrule
\end{tabular}

\begin{table}[!ht]
\begin{tabular}{@{}ll@{}}
\toprule
text & text \\
text & text \\
text & text \\
\bottomrule
\end{tabular}
\end{table}

\lipsum*[2]

\end{document}

-