Tagged Questions
4
votes
1answer
60 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
80 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 ...
2
votes
0answers
54 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
...
2
votes
1answer
57 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 ...
3
votes
1answer
78 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?
...
9
votes
2answers
191 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 ...
3
votes
1answer
88 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
72 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
127 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
127 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 ...
2
votes
1answer
91 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
167 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 ...
7
votes
1answer
183 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 ...
2
votes
1answer
181 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
118 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
255 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 ...
4
votes
2answers
180 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
190 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
473 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 ...
17
votes
2answers
717 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
404 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
444 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
97 views
listing's lst@BeginWrite gobbles '->' and '=>' from input
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
687 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}
...
6
votes
1answer
775 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}{}
...
12
votes
1answer
1k 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
831 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
261 views
Listings settings for command line arguments
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. ...
3
votes
2answers
388 views
How listing and verbatim do to escape special character?
I use one macro to display text using texttt style. For the moment this macro is very basic. For example, if I want to use the character _, its catcode must be changed.
Is there a clever way to ...
9
votes
2answers
1k views
Colored background in inline listings
I would like to make inline code more distinguishable from the text surrounding it, and I thought that using a background might work (like it is done on the stackexchange pages.)
Since I use the ...
4
votes
2answers
197 views
A version of shortvrb for listings?
So, shortvrb is a neat little package that allows you to do \MakeShortVerb{\|} which then has |foo| behave like \verb|foo|.
Now, I like listings. Is there a \MakeShortListings that makes |bar| act ...
3
votes
1answer
635 views
Code listing in subfigure
I am trying to use the subfigure package of LaTeX to display a code listing. Here was my first attempt:
\begin{figure}
\subfigure[Standard approach]{
{\footnotesize
\begin{verbatim}
var caps = new ...
5
votes
1answer
1k views
lstlisting, tt fonts, and alignment.
I (mostly) love the listings package, which I have started migrated to from verbatim for code listings. I prefer to continue to use teletype for code, and so I changed my default listing configuration ...
2
votes
3answers
1k views
Any ideas why this \newcommand{\n}{\lstinline|\n|} macro doesn't work?
So I created a new macro \newcommand{\n}{\lstinline|\n|} but for some reason when I use it, all I get is bold 'n' letter and not a nice \n. Any ideas?
2
votes
2answers
567 views
ignorespace and unskip in verbatim/listings?
I am writing a \bashDemo macro that will (a) execute its argument in a shell, e.g., bash, script, and (b) display the argument in a listings. So,
\bashDemo
ls -ls > myfiles
\END
will both run ls ...
1
vote
1answer
224 views
How to make my unusual environment accept one argument?
I cannot find a good title to express my question. Therefore, please parse the following code first.
Minimal Code
\documentclass[dvips,dvipsnames,cmyk,table]{book}
...
12
votes
1answer
2k views
fancy verbatim - bold letters for the first 4 columns
I am writing a book on Python and IPython. I want to insert in this book code listings of Python and IPython.
For the code itself I have no problem customizing listings for my intents.
Including ...
4
votes
1answer
2k views
Using listings and subfigure together
I am writing a document in which code listings and diagrams appear side-by-side frequently. I am using the listings package for the code and \includegraphics for the diagrams. I want to put them both ...



