1
vote
2answers
61 views

Shrinking the text in verbatim mode [duplicate]

I need to deal with loads of code lines in verbatim mode and append them to the appendix. That is, I may not need to show them in a fancy way but I want them to occupy least amount of space. As you ...
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 ...
4
votes
1answer
111 views

Adding Non-breaking space after single character in text mode

Is it possible in LaTeX (2e) to create macro or other processing command that will add non-breaking space after single character in text mode? Example: A new example here will add a "tilde", after ...
35
votes
2answers
593 views

Viewer-independent copyable spaces at the beginning of a line?

I need to include a couple of Python code listings, where the indentation of the lines (using some number of spaces) is significant. I would like for the code listings to be copyable, so the spaces at ...
6
votes
2answers
153 views

How to add a phantom character to the beginning of a verbatim block

I am trying to understand the commandchars of fancyverb's Verbatim: \documentclass{article} \usepackage{fancyvrb} \begin{document} \phantom{foo} \begin{Verbatim}[commandchars=\\\!\!] \phantom{bar} ...
3
votes
2answers
134 views

Verbatim has different margins than BVerbatim

I am changing some Verbatim blocks to BVerbatim to avoid page breaks in the middle of some short source code examples: \documentclass[a4paper]{book} \usepackage[T1]{fontenc} \usepackage{fancyvrb} ...
4
votes
1answer
134 views

Tikz + Verbatim + Sphinx , output drawn twice with slight offset. Works great Tikz + Verbatim

I'm working on a piece of software that outputs IPython Notebooks as tex documents. One of my requirements is to be able to draw code input output blocks that look like the Notebook's UI. ...
2
votes
1answer
357 views

Putting math inside a verbatim environment without altering the formatting

In a verbatim code listing, I want to use inline math in comments with the same formatting that I get for inline math in body text. I can use a math environment, but the spacing is weird. In this ...
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
2answers
255 views

Custom verbatim that sets all spaces (“ ”) as visible spaces (“␣”) that can line-break

It makes sense to typeset code in a monospaced font. Sometimes such code needs to be embedded in a paragraph context, and then it will be useful to allow it to linebreak. In order to visualize spaces ...
3
votes
1answer
225 views

passing text to alltt embeded in command (extra newline needed)

I wanted to close alltt inside a command (to add some ornaments around the text), but the spaces that were used for putting the monospaced text into columns was not preserved. I found the solution ...
3
votes
1answer
289 views

How to set the Top Margin for a custom Verbatim environment (fancyvrb)

From the fancyvrb documentation, it looks like I can set left and right margins (paragraph 4.1.13) only. How can I set the top margin for my environment? More specifically, given that I have a frame ...
7
votes
1answer
2k views

control vertical space before and after verbatim environment?

How do I control how much vertical space appears before and after a verbatim environment? With the following source (run through pdflatex): \documentclass[varwidth]{standalone} \begin{document} text ...
5
votes
1answer
555 views

Proper spaces with verbatim

there is following code: \begin{verbatim} pc:~$ ls folder1 Documents folder2 New Folder folder3 folder4444 Downloads folder5 Pictures ...
13
votes
4answers
2k views

Hard whitespace

I am using plainTeX and would like to typeset some (python) code examples. Switching to \tt gets me partway there, but I (obviously) need the whitespace respected. Is there a trick for doing this? The ...
9
votes
2answers
1k views

How do I backcolor in verbatim?

I have some code I want to typeset as verbatim (lstlisting would be ok as well) - but I want to highlight some parts of it via a different background color, i.e. something like this: \begin{verbatim} ...