Graphics, Figures & Tablesalign enumeration with top row of tabular (\hline)

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Linguist
Posts: 43
Joined: Mon Nov 07, 2011 12:07 pm

align enumeration with top row of tabular (\hline)

Post by Linguist »

Hello,

This seems to be a pretty common problem, but I haven't found a satisfactory solution.

I want to have a tabular with an \hline at the top in which the contents of the top row are aligned with an enumeration. So far I've managed to get the following unsatisfactory results:
  • the enumeration is aligned with the centre of the tabular
  • the enumeration is aligned with the top row of the tabular, but no \hline is included
  • the enumeration is aligned with the \hline of the tabular
I also tried the first solution for a similar problem found here but found that the number was not properly aligned with the top row of my table; it is a little lower than the contents of the top row. (The second solution involves manually adding space, and thus is highly undesirable. My document doesn't compile with the third solution.)

Code: Select all

Code, edit and compile here:
\documentclass[a4paper,12pt]{article}
\usepackage{pifont}
\usepackage[table]{xcolor}
\usepackage{gb4e}
\begin{document}
Here is a MWE with the three (unsatisfactory) results:
\begin{exe}
\ex{\begin{tabular}{|rrl||c|c|} \hline %enumeration aligned centrally
%\ex{\begin{tabular}[t]{|rrl||c|c|} \hline %enumeration aligned with \hline
%\ex{\begin{tabular}[t]{|rrl||c|c|} %enumeration aligned with top row (but no \hline)
\multicolumn{3}{|c||}{Input:~/xxx/} & xxx & xxx \\[0.5ex]
\hline \hline a. & \ding{43} & xxx & & \cellcolor{lightgray}{$\ast$} \\
\hline b. & & xxx & {$\ast$}! & \cellcolor{lightgray} \\ \hline
\end{tabular}}
\end{exe}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

kaiserkarl13
Posts: 707
Joined: Tue Mar 25, 2008 5:02 pm

align enumeration with top row of tabular (\hline)

Post by kaiserkarl13 »

Here's my hack:

Code: Select all

Code, edit and compile here:
\documentclass[a4paper,12pt]{article}
\usepackage{pifont}
\usepackage[table]{xcolor}
\usepackage{gb4e}
\begin{document}
Here is a MWE with the three (unsatisfactory) results:
\begin{exe}
\ex{%
\rule{0pt}{0pt}{} \\[-2.5ex]%
\begin{tabular}{|rrl||c|c|} \hline %enumeration aligned centrally
%\ex{\begin{tabular}[t]{|rrl||c|c|} \hline %enumeration aligned with \hline
%\ex{\begin{tabular}[t]{|rrl||c|c|} %enumeration aligned with top row (but no \hline)
\multicolumn{3}{|c||}{Input:~/xxx/} & xxx & xxx \\[0.5ex]
\hline \hline a. & \ding{43} & xxx & & \cellcolor{lightgray}{$\ast$} \\
\hline b. & & xxx & {$\ast$}! & \cellcolor{lightgray} \\ \hline
\end{tabular}}
\end{exe}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Post Reply