# How do I stop tables from messing with alignment?

I'm new to TeX and I'm having a hard time understanding how paragraphs, alignment, indentation, and all that works.

Some text here.

\begin{tabular}{ l l }
a & b \\
c & d \\
\end{tabular}

Some more text here.


The text at the bottom gets shifted to the right to line up with the table. I want to stop this. It should be a new paragraph and appear exactly as the one at the top. Additionally, I've been using \hfill to add some space between the text and the table. Is that the "correct" way to do it?

-
Yeah, but the formatting of the last paragraph is affected by the presence of the table, which made me think that maybe it was somehow not being recognized as a separate paragraph. I want to "reset" the formatting. –  Zifre Feb 24 '12 at 20:40
@Zifre the tabular is the same as a big letter, in a paragraph on its own. Perhaps your real code has \hfill rather than a blank line, which would make the following text the same para as the tabular, so naturally affected by its width. –  David Carlisle Feb 24 '12 at 20:46
\hfill has no visible effect except for adding some space between the table and the text. Even when I remove it, the last paragraph is still affected by the table. –  Zifre Feb 24 '12 at 20:49

The first paragraph after a sectional unit (like \section or \subsection) are usually treated differently and not indented. Subsequent paragraphs, including your tabular which is set on its own line with a blank line between the items will be indented by a length \parindent. If you don't want this indent, use \noindent at the start the paragraph. If you don't want any indent at all, use \setlength{\parindent}{0pt} in your document preamble.

-

Besides the indentation issue that @Werner described, the other placement issues can be understood with thinking in boxes as that is how TeX works.

Consider the following, where the TeX code is on the left and the output on the right.

Note that the first two cases produce identical output as the new line is taken to be a separation between a word, and each word is considered as a box. In the third case, the blank line in between indicates a new paragraph so each word (box) is placed on a new line.

Now consider your case with text and tables, and think of the table as being placed in a box. So Some text here. is treated similar to the AA in the above example, the table is treated as BB, and the subsequent text Some more text here. is treated as CC.

So, the output of the first example below is similar to the output of the first two examples above where each box is placed next to each other, and the second example below is comparable to the last case above where each box is treated as a new paragraph and placed on its own line.

\documentclass{article}
\usepackage{xcolor}
\usepackage{showexpl}

\lstdefinestyle{demoLatexStyle}{
basicstyle=\small\ttfamily,
numbers=left, numberstyle=\tiny, stepnumber=2, numbersep=5pt,
frame=none,
backgroundcolor=\color{yellow},
pos=r
}

\begin{document}
\begin{LTXexample}[style=demoLatexStyle]
AA
BB
CC
\end{LTXexample}

\begin{LTXexample}[style=demoLatexStyle]
AA BB CC
\end{LTXexample}

\begin{LTXexample}[style=demoLatexStyle]
AA

BB

CC
\end{LTXexample}

\begin{LTXexample}[style=demoLatexStyle]
Some text here.
\begin{tabular}{ l l }
a & b \\
c & d \\
\end{tabular}
Some more text here.
\end{LTXexample}

\begin{LTXexample}[style=demoLatexStyle]
Some text here.

\begin{tabular}{ l l }
a & b \\
c & d \\
\end{tabular}

Some more text here.
\end{LTXexample}
\end{document}

-