Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 898969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T15:08:16+00:00 2026-05-15T15:08:16+00:00

Using LaTeX , I need to show some code snippet inside a table. Here

  • 0

Using LaTeX, I need to show some code snippet 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 margin on the left of the code. I guess this margin is there for numbering, but I don’t need numbering and would like to get rid of it. I’ve tried changing some options (numbersep, xleftmargin) but none is working as I wish.

UPDATE

Here is the full 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 deduce that the problem is because the table is in a item of an enumeration.

Is there a way to solve this ?

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T15:08:17+00:00Added an answer on May 15, 2026 at 3:08 pm

    Yes, the margin is indeed coming from the enumeration. But luckily, the package documentation of the listing package notes:

    resetmargins= true|false (default: false)

    If true, indention from list environments like enumerate or itemize
    is reset, i.e. not used.

    Therefore, the following should help:

    \begin{lstlisting}[numbersep=0pt,resetmargins=true]
    

    Regards,
    Christoph

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When editing an Sweave document in LaTeX (using the Noweb mode), Emacs knows to
I'm using this to move a div inside a slide show. The problem is
I'm trying to find the sum of specific values within a table, using SQL.
I am using Latex letter class, and would like the address to be right
I am using LaTeX and I have a problem concerning string manipulation. I want
I'm using LaTeX and BibTeX for an article, and I want to able to
I want to create something like a leaflet/magazine using Latex. Is it possible to
Hello I am having a problem with the numbering of figures using Latex, I
I just wondering, how can write web applications or web pages using LaTeX-styled math?
I am using the Vim-Latex now. But I have a question, when everytime I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.