{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 ...
31
votes
2answers
413 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
4k 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 ...
46
votes
2answers
32k 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
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: ...
13
votes
2answers
832 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}
7
votes
1answer
568 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 ...
5
votes
2answers
956 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 ...
17
votes
5answers
1k 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 ...
22
votes
4answers
10k 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 ...
19
votes
5answers
865 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 ...
2
votes
1answer
590 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
612 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
422 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 ...
11
votes
1answer
3k 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 ...
14
votes
2answers
704 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). ...
6
votes
1answer
916 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 ...
2
votes
2answers
454 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
4k 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
80 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 ...
2
votes
1answer
704 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
1k 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 ...
15
votes
3answers
891 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{{} ...
6
votes
3answers
612 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 ...
9
votes
3answers
962 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} ...
8
votes
5answers
7k 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 ...
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
704 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
138 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
918 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
585 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
330 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 ...
7
votes
1answer
738 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
350 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
1k 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
362 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
846 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 @@; ...
11
votes
3answers
938 views

How to pass an optional argument to an environment with verbatim content?

This is an attempt to make clear what happened in this question of xport (now deleted, sorry). The now deleted question included code that tried to make my answer to this question of xport work for ...
11
votes
1answer
1k views

Alternatives to $\backslash$

Background Instead of marking up the text with bold or emphasis, I read (and agree) that it is better to define a command, or environment, that describes the content. Then apply text formatting ...
9
votes
2answers
664 views

Highlighting a .diff file

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

Merging bib files from within LaTeX

I have two .bib files that I want to use in my bibliography. Entries do not overlap. I have found quite a few forum topics on that, but none of them really satisfied me. So my idea is to merge the two ...
5
votes
1answer
979 views

Problem with TikZ, beamer and verbatim

I'm trying to put verbatim text inside a node (in a beamer frame): \begin{frame}[fragile]{P} \tikzstyle{cell} = [rectangle, draw, thin , fill=black!10 , minimum size=5mm] \begin{tikzpicture}[node ...