In LaTeX, I'm using the listings
package to display some code snippet inside a table. But it seems that when using this package, the vertical alignement of the cells is changing.
Here is some code :
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,textcomp}
\usepackage[frenchb]{babel}
\usepackage{listings}
\begin{document}
\begin{tabular}{ll}
\hline Méthode & Exemple d'utilisation\\
\hline isLetter()&
\begin{lstlisting}
QChar MyChar('x');
bool IsLetter = MyChar.isLetter();
// IsLetter vaut vrai
// bla bla bla
\end{lstlisting}\\
\hline
\end{tabular}
\end{document}
and here is what I get (notice the centered vertical alignement of the first column) :
.
If I avoid using the listings
package inside the table, the vertical alignement is different (centered) :
\begin{tabular}{lp{5cm}}
\hline Méthode & Exemple d'utilisation\\
\hline isLetter()&
QChar MyChar('x');
bool IsLetter = MyChar.isLetter();
// IsLetter vaut vrai
// bla bla bla
\\
\hline
\end{tabular}
.
What I would like is to put some code inside the table but keep the vertical alignement to top for the cells.