[Tex/LaTex] How to make left justify in table

tables

How to make left justify in table?

\begin{document}
\begin{table}
    0               && 0 \\
    3x + y                          && 7\\
    3x                          && -675+867i\\
    x                 && \\
    \end{table}
\end{document}

I do not know why does not work?

Best Answer

In LaTeX terminology, a table is a "floating environment", meaning that it may get typeset not exactly where it's encountered in the input file but somewhere else (usually not too far away though) in order to obtain a decent page layout. The main content of a table environment -- other content being, for instance, the table's caption, legend, and table-related footnotes -- is usually placed inside a tabular environment (if the tabular material is mostly text) or an array environment (if the material is mostly math).

Left-alignment of the contents of a column is achieved by using the l column type, specified as an argument to \begin{tabular} or \begin{array}. To change the distance between columns, modify either \tabcolsep (for tabular environments) or \arraycolsep (for array environments).

In the case of your example, I would suggest you use an array environment, as it contains all mathy stuff.

enter image description here

\documentclass{article}
\begin{document}

\begin{table}
%\centering %% uncomment this if the "array" should be centered
\setlength\arraycolsep{10pt} % default value: 5pt
$\begin{array}{ll}           % "ll" sets up two left-aligned columns
    0               & 0 \\
    3x + y          & 7 \\
    3x              & -675+867i\\
    x               & \\
\end{array}$
\end{table}

\end{document}
Related Question