TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

\texttt{int main(void)} is rendered tighter than in the listing.
What lstlisting option would need changing?

int main(void)
 printf("Hi world\n");
share|improve this question
I think you want to use \lstinline!int main(void)! instead of \texttt. Have a look at the listings manual. It talks about fixed width text. – TH. Jan 10 '11 at 0:35
@TH I think he wants the listing code to be narrower, actually. But the defaults for inline vs. listings are different anyway. (See my answer.) – Alan Munn Jan 10 '11 at 0:43
up vote 2 down vote accepted

This is controlled by the columns specification (see section 2.10 of the listings manual.) You don't say whether you want the spacing to be wider inline (like the code) or narrower in the listing itself.

To make the inline code match your example listing, use:

\lstinline[language=c,columns=fixed]{int main(void)}

To make the listing match the inline code, use:


If you want both to be the same, use the same column specification for both. The default for inline listing is flexible; the default for listings is fixed.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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