lstlisting

[LaTeX] Change "List of Listings" text

I tried to change the "List of Listings" text with the command \renewcommand*{\lstlistlistingname}{List of XYZ} before my \begin{document}. What's wrong with this? By the way \renewcommand*{\lstlistingname}{NewListing} worked like a charm. Edit: No error occurred, just no change in the text. It's still "List of Listings". By the...

LaTeX lstlisting underlined

Hi, Is there an easy way to have the complete code in a lstlisting environment underlined? My current solution looks like this, but I'm not really happy with it. \begin{lstlisting}[mathescape] $\ul{if(gt(x1, 0)) then} $ ... \end{lstlisting} Thanks for any tips. ...

Latex: vertical line in lstlistings

I want to have a vertical line for indentation in the lstlisting environment, similar to what one can get in algorithm2e. I tried doing something like the code below, but the the |'s are not contiguous and the result is ugly. \lstset{ ... showtabs=true, tabsize=3, tab=\hfill$|$\hfill, ... } ...

LaTeX: remove left margin of listing inside a table

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}[...

Using listings, how do I maintain grouping of listing numbers?

I'm using the listings package for showing code, as well as algorithms in pseudocode. This is what I would like happen: Algorithm 1.1: myFirstAlgorithm() ... content ... Algorithm 1.2: mySecondAlgorithm() ... content ... Code 1.1: My First Code Block ... content ... Algorithm 1.3: myThirdAlgorithm() ... content ... Wh...

Latex: Showing only few lines in lstlisting

For displaying only few lines of source code lstlisting has a linerange key which prints only those ranges. \documentclass[slidestop]{beamer} \usepackage{listings} \begin{document} \begin{frame}[fragile] \begin{lstlisting}[language=C,linerange={1-2,5-6}] #include<stdio.h> int void main(int argc, char **argv) { pri...

Colorize numbers in lstlisting (latex)

Hi everyone. I want to know if it is possible to colorize the numbers in lstlisting package from latex. For example i want all numbers be in red, even 0x0F (hex) and 0b00001111 (bin): void SetaPWM2(unsigned char porcento) { //100 * 256 = 25.600 unsigned int val = porcento * PR2; val /= 25; //garante que tem apenas 10 bits val...

Character spacing in LaTeX with lstlisting package

Hi, I'm trying to get my code snippets to look as good as possible and so far I'm having troubles with the character spacing. Here is an example of the output: While the text in small is perfect, all the keywords that are in capital letters look terrible. Here are the settings I use \lstset{basicstyle=\footnotesize, basewidth=0.5e...

Environment 'Preformatted' in Latex

I know two environments, lstlisting and verbatim but both behave difficult in my case. Is there a Latex environment which allows pre-formatted text, conserving my white space characters (most important the indentation)? I do not want to use verbatim or lstlisting for two reasons: I try to use lstlisting in a macro: \newcommand*{\fdesc...