[Tex/LaTex] First line of ltxtable/longtable indented

indentationlongtableltxtable

I am using the ltxtable package to be able to set the longtable to \textwidth

I have \setlength{\parindent}{0pt}' in the preamble.

The first line of each longtable is indented, how do I get rid of that?

Example

\subsubsection*{Test}
\label{test}

\begin{filecontents}{longtab.tex}
    \begin{longtable}{p{0.5\textwidth}p{0.1\textwidth}X}
    \addtocounter{table}{-1}
     one &   & two \\
     three &   & four \\
    \end{longtable}%
\end{filecontents}
\LTXtable{\textwidth}{longtab} 

Best Answer

LaTeX tries to ignore spaces at the begin of a table cell by using \ignorespaces. But the space after \addtocounter{table}{-1} caused by the line end is not seen and therefore not ignored by the automatically added \ignorespaces. This line end can be commented out:

\documentclass[a5paper]{article}

\usepackage{ltxtable}
\usepackage{filecontents}

\begin{document}

\subsubsection*{Test}
\label{test}

\begin{filecontents}{longtab.tex}
    \begin{longtable}{p{0.5\textwidth}p{0.1\textwidth}X}
    \addtocounter{table}{-1}%
     one &   & two \\
     three &   & four \\
    \end{longtable}%
\end{filecontents}
\LTXtable{\textwidth}{longtab}

\end{document}

Result

If you do not want to have the remaining "indentation" by the horizontal space automatically added around table cells, then this can be suppressed by @{} in the table column specification. This makes sense, if there are not horizontal lines in the table:

\begin{longtable}{@{}p{0.5\textwidth}p{0.1\textwidth}X@{}}

Result

Related Question