3
votes
1answer
62 views

How to copy/paste multiple spaces from lstlistings?

This is a continuation of a question that I asked already: How to copy/paste from lstlistings?. The solution presented there does not work if the text within the lstlistings environment contains ...
2
votes
1answer
68 views

Difference between fixed-width and proportional typewriter fonts in listings?

In the MWE below, I wonder why does the pcr (Courier) font align in both escaped and unescaped versions and for whatever column setting of {listing} - while the cmtt (Computer Modern Teletype) aligns ...
5
votes
1answer
60 views

How to use \pretocmd with \verb or \lstinline?

I write my document in other language, then I need to switch to English (switch font) when show code: \newcommand\code[1]{\lstinline{#1}} \pretocmd{\code}{\begin{otherlanguage}{english}}{}{} ...
9
votes
3answers
162 views

Fancy code environment

I'm writing a small tutorial about LaTeX. So I'd like to insert some code and obtain the result on the right. I'm almost there. I got the desired output but I'd like something more clear, that is, ...
2
votes
0answers
31 views

lstlistings messes up spacing before subsequent section headings [duplicate]

I'm typesetting a grammar specification for a programming language, which leads to many short snippets of grammar and example code interleaved in the document text. The issue I observe is that an ...
3
votes
1answer
75 views

Verbatim environment with gray background color and italics

I want a verbatim environment with gray background color and italics(bold fonts may be used also). The \lstlisting can set background but can't set italics. The \mdframed combined with \alltt can ...
5
votes
1answer
65 views

Lstinline macro inside another environment

Why does the MWE below compile with errors only if I use ths \lstnewenvironment line? And how to define the verbatim macro inside an environment? I heard it's possible using plain TeX? ...
4
votes
1answer
55 views

How can I mimic the output of syntax macros (\marg, \oarg, etc.) without using the ltxdoc class?

I have come to realize that the pleasant style (argument in italics, enclosed by angle brackets) of macro descriptions in numerous package documentations is actually produced by a number of special ...
11
votes
2answers
259 views

How can I make lstlisting look exactly like verbatim?

I like the way the verbatim environment looks, and I want to make my lstlistings look like it. I've tried setting the basic style to \ttfamily, but the letter kerning and line spacing seem to be ...
5
votes
0answers
31 views

How can I replicate verbatim's letter spacing in listings? [duplicate]

I was trying to imitate the code listings in the book Mathematical Recipes in C, I understand that it uses the CM TT font. What I am interested is in the proportion between the text and the code, and ...
2
votes
1answer
62 views

Source code customization for specific words?

I'd like to highlight some specific words for HTML5 code manually in LaTeX. In other words, I don't want to define an exact structure for highlighting the language, but do the highlights only for the ...
4
votes
2answers
131 views

Indent content of verbatim / lstlisting environment relative to containing environment

I want the content of \verbatim to be indented relative to the actual indent of \verbatim, not the exact number of spaces. For example, I like to indent at sections to make the LaTeX source more ...
3
votes
1answer
74 views

Description definitions and ntheorem

I want to have inline listings in description items, so I used this very nice answer. Unfortunately this hackery destroys my theorem environments with error something's wrong--perhaps a missing \item ...
4
votes
1answer
78 views

Handling a PDF with user text strings

I am using LaTeX to generate descriptive receipts for an online system. I use special character tags and replace these with content e.g. {{ first_name }}. Now, there are several of these and they ...
7
votes
1answer
97 views

Two block commands in \newenvironment [duplicate]

What is wrong with following document? \documentclass{article} \usepackage{xepersian} \usepackage{verbatim} \newenvironment{code} {\begin{latin}\begin{verbatim}} {\end{verbatim}\end{latin}} ...
8
votes
4answers
260 views

Verbatim, wrappable and Unicode text included from a file

I am trying to output several megabytes of UTF8 text into a printable format. As enscript and friends don't like Unicode, this Unix SE question soon turned to LaTeX. Summary of requirements: ...
2
votes
1answer
154 views

Handle % character in verbatim inside a grey box

I found this snippet on the internet which is used to produce a text area inside a greybox. \newcommand\greybox[1]{% \vskip\baselineskip% \par\noindent\colorbox{lightgray}{% ...
8
votes
2answers
177 views

Allow source code to wrap around a figure

I would like to be able to wrap source code around a figure. Here's a MWE that should make it clear what I have in mind: \documentclass{article} \usepackage{wrapfig} \usepackage{listings} ...
3
votes
1answer
87 views

Using collect to gather content with listings, comments or verbatims

I was looking into a way to set up a project with multiple files, in which several files could declare content to be included in different sections of the main tex document. After this Q&A, I ...
2
votes
0answers
106 views

Deciding whether to end a line with a character or not in lstlisting [closed]

I need to write a document where there are written inputs and outputs of unix command line interface software (through bash). For example I need to show something like: $ git log --pretty=format:"%h ...
4
votes
1answer
253 views

Replace lstlisting with verbatim depending on a boolean

I use latex2rtf to convert latex documents to .rtf and thence to MS-word (see this thread). To do this, I set up a custom class and limit which packages are used as latex2rtf only accepts a limited ...
1
vote
1answer
93 views

Extend keyword list for fancyvrb / listings, based on a given language

I use fancyvrb and listings packages, and I have defined a language scala, which is the default to use. In one occasion, I have an extension of that language, escala, which adds additional keywords. ...
4
votes
1answer
407 views

How to copy/paste from lstlistings? [duplicate]

I'm trying to write code in a LaTeX document that can be copy/pasted from an outputted pdf using Adobe Reader and that also word wraps, rather than breach the right margin. I've found that in ...
6
votes
4answers
485 views

Is it possible to use a non-monospace font in verbatim environments?

I know it runs contrary to a lot of the point, but I'd like to experiment with different fonts to see which I like better. I can't seem to find any reference to a way to do this, if it's at all ...
3
votes
1answer
180 views

How to combine framed and listings packages in new environment

I always use this LaTeX code to display a source code in my article. \begin{listingbox}{VB style} \begin{singlespace} \begin{lstlisting}[style=BASIC] Private Sub Form_Load() Dim tex As String ...
5
votes
1answer
144 views

How to make letter spacing in verbatim/fancyvrb look like listings

I've just noticed that the spacing between letters is different in verbatim vs. lstlisting environments: Given that I add the option columns=flexible to the lstlisting environment, the spacing in ...
6
votes
1answer
646 views

listing package and vbox warning

I have this many (see below) underfull warnings that are caused by using the listing package and creating \begin{lstlisting}\end{} to make code appear presentable. Is there a may to fix the warnings? ...
11
votes
2answers
475 views

Any way to show LaTeX example code *and* execute it? [duplicate]

In (La)TeX documentation and tutorials, it is common to show a snippet of code next to the output it generates. It might be two minipages side by side, or a code listing followed by boxed output, or ...
4
votes
1answer
909 views

lstlisting in a box?

My problem is that I am trying to write a document with coloured sections for examples. Examples can contain code listings. Somehow I can't seem to combine a background colouring with a listing, or ...
0
votes
1answer
140 views

wrap listings package - Problem with verbatim argument

I would like to define a command that wraps a lstlisting environment in some other environments (esp. a minipage). I understand that working with verbatim arguments is a difficult task. I tried the ...
3
votes
1answer
594 views

Using math mode escapes with listings enabled fancyvrb

I am trying to escape math mode within Verbatim, using this answer. This works fine, until I use the listings package with fancyvrb=true \documentclass{article} \usepackage{fancyvrb} ...
1
vote
1answer
172 views

Displaying (source)Code in research article [duplicate]

I have this urgent need to display two pieces of code side by side for comparison in my article. Displaying a code, I've couple of requirement Should indent properly Output should be syntax ...
4
votes
1answer
375 views

How can I create wrapper macro for lstinline?

Using \lstinline I can include inline code snippets in a paragraph. I would like to provide a macro that selects formatting, etc, for lstinline so I can just do, say, \codeinline{snippet}. I had ...
5
votes
1answer
301 views

is it possible to add line numbers to input files read using \verbatiminput?

I know one can use \usepackage{listings} which supports line numbers. And I use that for pdf files. But I also generate HTML using Latex2html, and l2h does not support this package. It only supports ...
11
votes
2answers
855 views

Using \lstinline inside a \item

I know about the fragility of verbatim-like commands, and that they should not be used as an argument of another macro, but a need to write a description environment in which the terms to be defined ...
6
votes
1answer
815 views

lstlisting in a newenvironment

I have a problem with the lstlisting package. I want to define an \newenvironment with one obligatory parameter, which will be the caption name for the lstlisting. I will also have other lstlisting ...
2
votes
2answers
165 views

Unindent code inserted with \lstinputlisting

Is it possible to unindent the code inserted using \lstinputlisting? In particular I'd like to be able to unindent by a fixed amount of whitespace. I have to write a relation on a OS scripting course ...
5
votes
2answers
501 views

Is there a non-verbatim form of lstinline from the listings package?

I'm using the listings package with beamer and I'd like to try to avoid making frames fragile where possible. I know that many of my frames will need to be fragile but there are some where the ...
6
votes
2answers
405 views

verb inside lstlisting caption

I try to do this: \begin{lstlisting}[language=Perl,caption={text {\verb+myverb+} some more text}] ... \end{lstlisting} But it gives me something like: Undefined control sequence ... some more ...
2
votes
1answer
273 views

How to use listings inside pgfplots captions?

I need to add a (general) listings code in a plot caption. For some reason listings (inline) doesn't interact well with \addlegendentry, what can I do to make the same code work outside and inside an ...
8
votes
1answer
972 views

Maple package for Latex

I'm translating the book PHYSICS WITH MAPLE by Wang. It contains some codes and outputs from Maple of course. I was wondering do we have a package such as mcode or matlab-to-tikz ( MATLAB) for Maple ...
22
votes
2answers
2k views

Ensure verbatim code block is copy/paste-able

After rendering a document containing this code block \begin{verbatim} if [ ! -d .git ]; then git init; fi # Initialises a new Git repository, if doesn't already exist. if [ ! -f README.md ]; ...
4
votes
2answers
1k views

How to cross-reference inside of a verbatim (or listings) environment

I would like to reference other parts of my document (e.g. equations, figures) inside of some source code. Is there an escape sequence such that \ref will be parsed instead of printed as a literal ...
3
votes
1answer
857 views

Alternative way to print source code [duplicate]

Possible Duplicate: Syntax Coloring in LaTeX I want to add source code of my program in document but verbatim really bugs me. All that ugly fonts and stuff.
4
votes
1answer
123 views

listing's lst@BeginWrite gobbles '->' and '=>' from input [closed]

I'm trying to write a package that takes verbatim input and appends it to several files. My current approach is based of off an answer by Martin Scharrer to a similar problem. The difficulty arises in ...
3
votes
1answer
1k views

Custom divider between 2 minipage and lstlisting

I am using the following code to have 2 boxes beside each other for code comparison: \documentclass[12pt]{article} \usepackage{listings} \begin{document} \begin{singlespace} ...
10
votes
2answers
1k views

Inline code and short verb with minted

I it possible to use minted for inline code and to add a short verb sing for minted? Like \lstMakeShortInline| in listings.sty? \documentclass{article} \usepackage{minted} \newminted{tex}{} ...
13
votes
1answer
2k views

Manual highlight of TeX code in a verbatim environment

Friends, I'm stuck with a unusual situation: I'm trying to highlight specific words of a TeX code inside a verbatim environment. I know listings can help me by defining a set of keywords, but in this ...
3
votes
2answers
1k views

How do I tell alltt environment to wrap text?

I have an already formatted text (space-wise) that is also being colored etc, so I am using alltt environment to print it. The text is code actually, but I am not using listings because I don't want ...
1
vote
1answer
388 views

Listings settings for command line arguments [closed]

I am typesetting a set of instructions which includes several (Unix) command line arguments. I have been using the listings package to include these arguments, but the colouring is less than ideal. ...