{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

15
votes
4answers
3k views

Getting those %#!^& signs in the footnote!

This is basically an expanded version of part of Control command arguments . The original questioner there wants to redefine \href so that all the links end up in foonotes (rather than in the main ...
34
votes
2answers
521 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 ...
14
votes
1answer
3k views

Verbatim environment and line-breaking

I've been wondering about how to display simple codes. I used verbatim and then found the fancyvrb package which added a lot of nice little features, but then I inserted some code with a long line and ...
15
votes
2answers
2k 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 ...
25
votes
5answers
5k views

How to obtain verbatim text in a footnote?

I want to employ a \verb command in a footnote. But, when I run pdflatex on \documentclass{article} \begin{document} I want this.\footnote{\verb|But, it does not work!|} \end{document} I get ...
8
votes
1answer
628 views

How to format an email conversation?

I am currently writing my thesis and need to include a bunch of email conversions. I am using classicthesis. I wonder, how you would format stacked conversions. Moreover, how would you deal with the ...
49
votes
2answers
36k views

When should one use \verb and when \texttt

Sometimes people here use \verb!A SHORT COMMAND! and sometimes \textt{A SHORT COMMAND}. I'm unsure when to use which. Are there any guidelines or arguments for \verbatim vs. \texttt?
14
votes
2answers
1k views

Verbatim inside a command

I have a question about a Verbatim, I want to write a word inside of the subsubsection title. I got an error. How can I fix it?: \subsubsection{The \verb+@interface+ Section}
5
votes
2answers
1k views

Inserting LaTeX code into LaTeX

I have problem with adding text into LaTeX document. I have LaTeX document about LaTeX and I need to insert some code snippets. I need to add "\usepackage{musixtex}" as a text, which should be ...
14
votes
3answers
2k views

How to put \verb command inside of \textbf{} block?

It looks like you can't use \verb|...| inside of \textbf{...}. I tried the following: \textbf{Be very careful when using \verb|-i| as it's destructive and it's not reversible!} And got this error: ...
7
votes
1answer
976 views

Using minted to define a new environment

Can I define a newenvironment that has inside it a minted environment? eg and environment that would be a quickhand for the following code: \begin{figure}[htp] \centering ...
17
votes
5answers
2k views

How can I provide a verbatim (unescaped) commandline for executing with \write18?

When using \write18 to execute shell commands, there are some cases where lots of backslash strings, and other 'special' LaTeX characters are required in the commandline to be executed (e.g. if a ...
20
votes
5answers
912 views

typesetting different characters with different colors in a DNA sequence

I have created a macro which I used to format DNA sequences, as they should be in the monospaced font and uppercased: \newcommand{\DNA}[1]{\texttt{\uppercase{#1}}} Now I have a column with some ...
22
votes
4answers
12k views

Verbatim environment that can break too long lines?

I want to generate a PDF of user-submitted text using LaTeX. To handle crazy user input, I first thought about using the verbatim package, but of course it doesn't break up too long lines. Is there ...
2
votes
1answer
611 views

Verbatim text can't be shown correctly in pdf

I try to change the font of verbatim text as below % Used by @verbatim ... @endverbatim \newenvironment{DoxyVerb}{% \verbatim% \fontencoding{OT1}\fontfamily{ptm}\fontseries{m}\fontshape{n}% ...
5
votes
4answers
1k views

Wrapping code (listings, verbatim, or other method) inside a newcommand

For some teaching I've been doing, I'd like to have code from two different languages side-by-side. To do so, I hacked together a newcommand which uses a tabular environment to arrange two verb ...
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 ...
13
votes
2answers
714 views

Format a verbatim paragraph

How can I format a verbatim paragraph? I.e. break, fill and join input lines to produce globally balanced output with the lengths of each line approaching the target \textwidth as closely as possible. ...
10
votes
2answers
447 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 ...
15
votes
2answers
765 views

Write environment body verbatim to a file

How can one write the body of an environment verbatim to an external file. I tried the following but get problems if the body contains undefined macros (error) or e.g. a % (disappears in the output). ...
11
votes
1answer
4k views

center /verbatim text in /figure

I'm trying to center a the content of a figure that has verbatim text in it, but the verbatim text is always right-aligned: \begin{figure} \centering \begin{verbatim} some text here ...
2
votes
2answers
482 views

Making more easy the itemized of item with tabulation system

Actually, isn’t not really a question. (Since my examinations get close, I don't really have the time to search for a solution to my problems.) Rather than using the common \item, I'd like to use ...
15
votes
2answers
2k views

Verbatim description list item

How do I make an item in a description list verbatim? \verb in \item[] seems to be not allowed: \begin{description} \item[\verb+list comprehension [f a | a <- M a]+] bla bla bla ...
9
votes
1answer
5k views

Boldface and subscripts in verbatim mode?

How do I create boldface and subscripts in verbatim mode? I've seen mention of a fancyvrb package that might be able to help. Can anyone provide working LaTeX code, either with or without fancyvrb?
4
votes
2answers
115 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
2answers
1k views

Change typeface of verbatim environment

I am new here and the following code is what I am testing. Is it possible to change the typeface of the words from a .txt file? Thank you for any kind help! \documentclass[a4paper]{article} ...
2
votes
1answer
763 views

\pause won't generate extra slides in a containsverbatim frame

It seems that the [containsverbatim] option when applied to a frame prevents beamer from generating intermediate slides if text animation is wanted in it. Only the first step of the animation is ...
7
votes
3answers
2k views

Putting in MATLAB codes in a box as figures? [duplicate]

how do I put MATLAB codes in a box or deal with them as if they are figures? Is there a way to do it within LaTeX itself? I am currently using the verbatim environment to present my codes and to be ...
7
votes
3answers
637 views

How can I redefine the \verb|…| command?

I'd like to redefine the \verb|...| command so that it had a light-gray background and a little bit darker border around it, and a little bit of padding to make this background "box" noticable. Anyone ...
22
votes
2answers
1k 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 ]; ...
15
votes
3answers
1k views

Writing { and } to a file with LaTeX

How can the special characters { and } be written literally to an external file in LaTeX, without being balanced? Obviously the following does not work: \immediate\write\my@outfile{{} ...
12
votes
2answers
767 views

Highlighting a .diff file

Is there a way to highlight the syntax of a diff file (i.e. by using the listings package)?
9
votes
3answers
1k views

Include Sweave input as verbatim

How do I keep Sweave from compiling things in a verbatim environment? For example: \documentclass{article} \begin{document} \begin{verbatim} <<>>= 1+1 @ \end{verbatim} \end{document} ...
9
votes
5answers
8k views

How to draw box around text that contains a verbatim block?

Typically, to box in some text, I use the following: \fbox { \parbox{\linewidth}{ This is some text! Blah blah blah... } } However, say I have a verbatim block within that. It will ...
7
votes
1answer
766 views

verbatim with black background and white text

How could I set up a verbatim-environment which has black background white text in scriptsize ?
6
votes
2answers
2k views

How to import a text file (with accent, special chars)

I got some text file (logs) that I want to import I saw this post: How do I import a text file so that it becomes the body text of my LaTeX document? which work, but all the special chars (UTF-8) are ...
15
votes
1answer
1k views

beamer's fragile frame as default

Is there a way to specify fragile mode as default for all frames? Now I know how to define a fragile frame: \begin{frame}[fragile].
12
votes
2answers
726 views

LaTeX Verbatim Source Code Beside the Typeset Output

I am a beginner to LaTeX, and I am reading Leslie Lamport's A Document Preparation System. In various places of his book, he puts the LaTeX source code beside the output obtained by running latex on ...
10
votes
2answers
148 views

Preserving (and Controlling) Expandedness

In most cases, by the time output gets to your screen, arguments are fully expanded and my question is moot. But sometimes (verbatim being a common example), one wishes to operate on arguments with ...
10
votes
1answer
1k views

Displaying `\begin{verbatim}…\end{verbatim}` inside the environment verbatim

I would like to display \begin{verbatim}...\end{verbatim} inside the environment verbatim like in the folowing piece of code. Is it possible ? \begin{verbatim} Bla, bla, ...
10
votes
2answers
632 views

Produce a hyperlinked DOI?

Friends, I'm trying to write a command that prints appropriately hyperlinked DOIs for a bibliography system. Here was my first attempt \newcommand{\formatdoi}[1]{\href{http://dx.doi.org/#1}{#1}} ...
10
votes
1answer
2k views

verbatim useable with a newenvironment definition?

I'm trying to create a simple newenvironment allowing me to display source code in a verbatim text block with a caption, numbering etc. The solution I'm after is with the in-built LaTeX verbatim ...
9
votes
4answers
1k 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 ...
9
votes
4answers
371 views

How to redefine an environment to produce no output?

I am using the verbatim environment with \begin{verbatim} XXXX \end{verbatim} I would like the option of redefining the verbatim environment so that nothing between \begin{verbatim} and ...
6
votes
2answers
386 views

Highlight \verb in inline text

I'm new in LaTeX and I'm searching for solution to highlight verbatim text inside paragraph (for example, it is like on this page, where code is highlighted). Can anyone help me with this? Let say, ...
6
votes
1answer
741 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 ...
6
votes
1answer
2k views

How to force line breaks within a fancyvrb verbatim environment?

Consider the following LaTeX document: \documentclass{article} \usepackage{fancyvrb} \DefineVerbatimEnvironment{example}{Verbatim}{commandchars=\\\{\}} \begin{document} \begin{example} Foo\\{}Bar ...
6
votes
1answer
380 views

LaTeX documentation with verbatim environment

I am trying to document some LaTeX macros concerning marginals. I think a good way for the documentation would be the LaTeX code on the verso page and the output on the recto page. So I came up with ...
5
votes
3answers
876 views

is it possible to define a verbatim{} command?

Is it possible to define a verbatim{} command that I could use instead of the environment? \begin{verbatim} \end{verbatim}
2
votes
1answer
2k views

Background color in Verbatim

I've to use the yellow background for data values in the following code. \usepackage \begin{Verbatim}[commandchars=\\\{\}] \color{blue}DATA \color{black}Heart; \color{blue}INPUT \color{black}X Y @@; ...