Tagged Questions

{verbatim} is about macros and environments like “\verb” and “verbatim” which implement some form of verbatim mode, i.e. change the {catcodes}. A popular package is {fancyvrb}. For questions about the {listings} or the {minted} package, use the respective tag instead.

learn more… | top users | synonyms

4
votes
2answers
132 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
90 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}}{}{} ...
3
votes
1answer
45 views

whitespaces in alltt environment get merged

\begin{frame}{Beispiel Mergesort} \begin{alltt} mergesort :: (Ord a, Trans a) => [a] -> [a] mergesort [] = [] mergesort [x] = [x] ...
1
vote
2answers
68 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
2answers
218 views

The correct way to type tilde?

So, I know there are a lot of posts about this already, with answers like \textasciitilde, \texttildelow and $\sim$ and they all seam to work in their own way. But what I've found is that they look ...
0
votes
1answer
119 views

LaTeX: C++ source code can be included with verbatim, but not with lstlisting [closed]

When trying to compile my .tex files, I can only include some of my C++ source code as "lstlisting"s, while other source code breaks compilation. The error I get is: Extra }, or forgotten \endgroup. ...
6
votes
1answer
486 views

How can I make bash-code look good both in LaTeX and HTML?

As I am new to Latex and this kind of typing in general, I find myself in need of some basic guidelines when it comes to how to make things look good in text. I have a document that looks good when ...
16
votes
3answers
229 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
1answer
66 views

How to combine simultaneously the fragile- and the label-command for a frame?

I am currently facing the following problem in the beamer-class for LaTeX: I would like to label a frame and simultaneously use a verbatim-environment. Most likely the solution is very easy but I do ...
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 ...
5
votes
1answer
102 views

Redefine verbatim environment

I have a text with source code, which I would like to display. I am using pandoc, so I have to use either verbatim or listings enviroment. Unfortunately, I can't use listings package (due to ...
3
votes
1answer
106 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 ...
3
votes
1answer
45 views

Creating command: FanceVerb Error, Paragraph ended before

Hi and sorry if that question might be already asked. I try to create a command like this: \documentclass{scrbook} \newcommand{\code}[1]{\texttt{#1}} \newcommand{\smallx}[1]{ \begin{center} ...
0
votes
1answer
214 views

How to properly format pseudocode (algorithm) in LNCS (Lecture Notes in Computer Science)?

I know that when I need to paste the source code, I should use \verb or \verbatim. But how about pseudocode\algorithms? Should I use \verb or \verbatim as well? Can't really find any official Springer ...
4
votes
2answers
53 views

unmatched curly brace in \PVerb argument

I do realize that a verbatim { can be obtained by \verb|{|. However, I need \PVerb which is robust to work in \item command. Obviously, a \PVerb{{} won't work. So is there a solution for unmatched { ...
3
votes
0answers
63 views

Show whitespace characters in monospace environments

I need to render an ASCII file for printing in a way that removes ambiguity if (very unlikely) one decides to type it in and validate the signatures. Essentially, I need a monospace typesetter that ...
4
votes
2answers
132 views

Define a special verbatim commmand

To learn more about Plain TeX, I try to define a special verbatim command \verb{code}, which puts code inside braces. When there is no braces in code, It's easy. But when there are some balanced ...
2
votes
2answers
109 views

How to specify non-standard font in fancyvrb Verbatim?

I am using Inconsolata for code in paragraphs, and would like to use it for code in verbatim environments as well. I have tried using fancyvrb's Verbatim environment to do this, but cannot get any ...
5
votes
2answers
232 views

How do I center a boxed 'Verbatim'?

Here's a MWE: \documentclass[12pt]{article} \usepackage{fancyvrb} %=== \begin{document} \begin{Verbatim}[fontsize=\small, frame=single, xrightmargin=5cm] Text. \end{Verbatim} \end{document} ...
3
votes
2answers
50 views

How to avoid the empty lines before and after a verbatim environment in a tabular cell

I want to insert some raw text and used verbatim in the cell of a tabular. Here is the code: \documentclass{article} \begin{document} \begin{tabular}{p{0.45\textwidth}|p{0.45\textwidth}} \hline ...
3
votes
1answer
76 views

Usage of minted inside newenvironment in minted 2.0a³

As a followup question to Lstinline macro inside another environment, I kind of want to do the same thing for minted as well, but I'm held back by the following: I used the code from Using minted to ...
5
votes
1answer
90 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? ...
3
votes
1answer
57 views

\verbatiminput stopped working?

In the past, I've used the \verbatiminput command in \fancyvrb without problems, but today it's not working for me. I checked, and /usr/share/texlive/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty is ...
1
vote
2answers
37 views

How would I take imported file and format it to account for spacing?

Basically what I'm trying to do is use something like \input{details.txt} which contains: ____Here are some random details with stuff everywhere. This is to see if latex will use this ...
2
votes
1answer
120 views

Using Sagetex on cloud.sagemath.com, is it possible to make Sageblock code wrap automatically?

Creating a LaTeX document on the Sage Math Cloud. Whenever I use a sageblock, I end up with endless typesetting warnings because the notes and code inside the sageblock does not automatically wrap ...
10
votes
2answers
208 views

Overlay red rectangles on top of verbatim text

I am using Beamer to prepare a presentation. In some slide I need to print a great deal of verbatim text and, also, I need to draw some red rectangles on top of it. What would be the most ...
2
votes
1answer
54 views

Usage of minted inside a new environment, inside IfFileExists

I want to conditionally load minted and define an environment, but after using IfFileExists I'm running into an error: FancyVerb Error: Extraneous input `resetoptions \setkeys ...
2
votes
0answers
32 views

LaTeX doesn't create new pages of bibliography or in the verbatim

It seems that I have some inherent problem in my document and I don't even know what the problem can be and where to search... When I create a bibliography using \bibliography{bibliography} LaTeX ...
2
votes
0answers
44 views

Package tikz Error when writing some text in verbatim [duplicate]

I got from texlive on windows 8.1 an error when I wrote some text in verbatim. The error was: (c:/texlive/2013/texmf-dist/tex/latex/lm/t1lmtt.fd) ...
2
votes
0answers
125 views

fancyvrb inline verbatim with \newcommand and \CustomVerbatimCommand

I've just registered. This is my first question to this site. I am trying to make a verbatim command for inline code. This has been asked and answered many times before, but I never found a direct ...
4
votes
1answer
59 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 ...
6
votes
1answer
73 views

Problem in using comment line in tcolorbox in a bash code

I am recently introduced to tcolorbox, which is a great package. I am trying to use it to highlight computer codes such as bash, python, and c++ in my document. When I run the following MWE, I get the ...
7
votes
1answer
88 views

Conflict between verbatim.sty and ltxdoc.cls

I am writing a package which uses the verbatim package. \RequirePackage{verbatim} For the documentation I'm using the ltxdoc class. So I have to put an % character before every line of the ...
15
votes
2answers
563 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 ...
4
votes
2answers
121 views

Change Verbatim Font To PCR

I'm writing a document using LaTeX, and I would like to use the PCR font inside of a verbatim block. This question is almost identical to mine, but when I try to apply it to use PCR, I can't get it ...
10
votes
4answers
5k views

Change font size of the verbatim environment

I want to apply small fonts inside the Verbatim environment e.g. {\small \begin{Verbatim} 1 double x, y; 2 double z, w; 3 main(); 4 return 0; \end{Verbatim}} Before the command \small ...
6
votes
2answers
131 views

Seemingly trivial: verbatim, newenvironment, and colorbox

I am, once again, trying to achieve what seems like a trivial goal. I want to use \newenvironment to define a verbatim environment with a background color. I need to define my own environment because ...
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 ...
16
votes
1answer
181 views

Why is there a \null in \verb?

In source2e.pdf, the definition of \verb is \def\verb{\relax\ifmmode\hbox\else\leavevmode\null\fi \bgroup \verb@eol@error \let\do\@makeother \dospecials \verbatim@font\@noligs ...
2
votes
1answer
67 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 ...
3
votes
1answer
43 views

put a link in the document

I'm using the following code snippet to put a link in the document: \begin{footnotesize} \begin{verbatim} http://vlm1.uta.edu/~zhangzhong/fall_detection/ \end{verbatim} \end{footnotesize} But the ...
4
votes
2answers
166 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
0answers
95 views

ConTeXt: Double or Triple Hyphen are Interpreted inside Verbatim Blocks

For example: \definetyping [code] [numbering=line, bodyfont=small, before={\startframedtext[width=\textwidth]}, after={\stopframedtext}] \startcode <-- \stopcode will produce < ...
7
votes
1answer
198 views

© not handle correctly by a verbatim

Is there a reason why the following verbatim section doesn't work as expected: \begin{verbatim} © copyright blahblah ..... \end{verbatim} In fact I get: Âl’ copyright blah blah Instead of the ...
8
votes
4answers
388 views

how fancyvrb background color fill completely with fillcolor?

I'd like the whole Verbatim (fancyvrb) block to have a background color. How do I do it? The fancyvrb package does define a fillcolor -- but that only colors the area around the margin -- not the ...
4
votes
3answers
256 views

Verbatim frame latex with no waste

I have a frame/boarder round my Verbatim environment however the frame is extended to the page side, thus alot of wasted space. The following is my code: \begin{Verbatim}[frame=single] s=0 ...
4
votes
1answer
132 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 ...
1
vote
1answer
362 views

How to escape properly and output regex in latex?

Escaping regex is a heck of a work on LaTeX. How should I write in latex syntax such that I can output the following regexes: ^\(?\s?\w{1,5}\s*[):.]\s* and [\[\(].{1,}[\]\)] I've tried ...
8
votes
3answers
226 views

How can I have numbered verbatim environments?

How can I have an automatically numbered verbatim environment, just like equations? I tried putting it like this: \begin{equation} \begin{verbatim} bla... bla... bla... \end{verbatim} \end{equation} ...
3
votes
2answers
75 views

Decreasing font size in verbatim

How can I modify the following command to make it work? \newcommand{\code}[1]{\begingroup \fontsize{10pt}{10pt}\selectfont \begin{verbatim} #1 \end{verbatim} \endgroup} I currently get the ...