Using LaTeX, I need to show a piece of code inside a table. Here is an example of what I'm trying to do:
\begin{document}
Par exemple :
\begin{center}
\begin{tabular}{lp{5cm}l}
\hline
Méthode & Description & Exemple d'utilisation\\
\hline
\texttt{isLetter()}& Indique si le caractère est une lettre de l'alphabet. &
\begin{lstlisting}[numbersep=0pt]
QChar MyChar('x');
bool IsLetter = MyChar.isLetter();
\end{lstlisting} \\
\hline
\texttt{toUpper()}& Retourne le même caractère mais en majuscules. & toto \\
\hline
\end{tabular}
\end{center}
\end{document}
Here is the result I get:
.
As you can see, there is a field to the left of the code. I think this is a field for numbering, but I do not need numbering, and I would like to get rid of it. I tried to change some parameters ( numbersep, xleftmargin), but none of them work the way I want.
UPDATE
Here is a complete document demonstrating the problem:
\documentclass[a4paper,11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern,textcomp}
\usepackage[frenchb]{babel}
\usepackage{listings}
\begin{document}
\begin{enumerate}
\item Par exemple :
\begin{center}
\begin{tabular}{lp{5cm}l}
\hline
Méthode & Description & Exemple d'utilisation\\
\hline
\texttt{isLetter()}& Indique si le caractère est une lettre de l'alphabet. &
\begin{lstlisting}[numbersep=0pt]
QChar MyChar('x');
bool IsLetter = MyChar.isLetter();
// IsLetter vaut vrai
QChar MyChar2('&');
IsLetter = MyChar2.isLetter();
// IsLetter vaut faux
\end{lstlisting}\\
\hline
\texttt{toUpper()}& Retourne le même caractère mais en majuscules. & toto \\
\end{tabular}
\end{center}
\end{enumerate}
\end{document}
I can conclude that the problem is that the table is in an enumeration element.
Is there any way to solve this?
source
share