2

Consider this example

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\noindent\lipsum[1][1-2]

\noindent
\begin{tabular}{ll}
  A & B
\end{tabular}

{
\setlength{\tabcolsep}{0pt}
\noindent
\begin{tabular}{ll}
  C & D
\end{tabular}
}

\end{document}

It has the output:

enter image description here

I would like to align the start of the text in table with the beginning of main text.

in the second table I try to use \setlength{\tabcolsep}{0pt} which achieves this effect with the undesired result of disappearance of separation between table columns.

What would be a better solution?

1
  • 2
    \begin{tabular}{@{}ll} will remove the \tabcolsep from the beginning of the first column only. Apr 4, 2019 at 18:53

2 Answers 2

1

To keep the \tabcolsep untouched everywhere else but remove it you can use the @{...} notation. From section 2.11.6 of the The Not So Short Introduction to LaTeX2ε (texdoc lshort):

The column separator can be specified with the <code>@{...}</code> construct. This command kills the inter-column space and replaces it with whatever is between the curly braces. One common use for this command is explained below in the decimal alignment problem. Another possible application is to suppress leading space in a table with <code>@{}</code>.

In your document:

\documentclass{article}
\usepackage{lipsum}
\begin{document}
\noindent\lipsum[1][1-2]

\noindent
\begin{tabular}{ll}
  A & B
\end{tabular}

{
\setlength{\tabcolsep}{0pt}
\noindent
\begin{tabular}{ll}
  C & D
\end{tabular}
}

\noindent
\begin{tabular}{@{}ll}
  A & B
\end{tabular}

\end{document}

enter image description here

2

Depending on the particulars of the tabular, a tabular stack might be ideal. There are never any leading or trailing gaps on the stack; yet, the intercolumn gap is fully settable.

\documentclass{article}
\usepackage{lipsum,tabstackengine}
\strutlongstacks{T}
\begin{document}
\noindent\lipsum[1]

\noindent
\tabularLongunderstack{ll}{ Aa & B\\C & Dd}

\noindent
\setstacktabulargap{2em}%
\tabularLongunderstack{ll}{ Aa & B\\C & Dd}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .