1

How can a tabular environment with a top line be aligned with the surrounding text, so that no space is inserted above the top line of the tabular?

\documentclass{standalone}

\begin{document}

LEFT
\begin{tabular}[t]{ll}
  First
  &
    \begin{tabular}[t]{|l|l|} \hline
      Line & 1 \\ \hline
      Line & 2 \\ \hline
    \end{tabular}

\end{tabular}
RIGHT

\end{document}

I want the top line of the tabular to be upper than what LaTeX is giving me. How can I get it aligned to the top of the surrounding text?

enter image description here

2

The first \hline command is causing the trouble. If you remove it, the table is aligned. If you want a horizontal line on top, use the array-package and the \firsthline command.

MWE:

\documentclass{standalone}

\usepackage{array}

\begin{document}

LEFT
\begin{tabular}[t]{ll}
First
&
    \begin{tabular}[t]{|l|l|} \firsthline
    Line & 1 \\ \hline
    Line & 2 \\ \hline
    \end{tabular}

\end{tabular}
RIGHT

\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.