Skip to main content

Questions tagged [verbatim]

{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.

Filter by
Sorted by
Tagged with
28 votes
4 answers
12k 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: !...
user avatar
212 votes
7 answers
366k 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?
Martin's user avatar
  • 4,585
24 votes
5 answers
8k 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 ...
Andrew Stacey's user avatar
79 votes
5 answers
99k views

Verbatim environment that can break 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 ...
user avatar
7 votes
2 answers
669 views

Why can't I use <some macro> inside the argument of <some other macro>?

I have some macro X and Y, which works well when used independently. However, when I try to put one inside another, it results in some error. Why is that the case and how can I fix it? Note: this is ...
user202729's user avatar
  • 7,483
28 votes
2 answers
16k views

Verbatim inside a command [duplicate]

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}
Isai's user avatar
  • 4,153
12 votes
3 answers
1k views

How to handle verbatim material in LuaLaTeX?

While trying to implement an own working alternative to shdoc (one of its issues see here) I encountered an interesting behaviour of LuaLaTeX I cannot explain. Consider the following code: \...
TeXnician's user avatar
  • 33.7k
19 votes
1 answer
8k 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 ...
Pjanc Matuzl's user avatar
44 votes
2 answers
3k 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 ...
Jake's user avatar
  • 233k
15 votes
2 answers
2k views

Print small TeX code verbatim and render it

To write some documentation, I would like the ability to define a command such as \showcase{x^{y}\in\Omega} which expands to something roughly equivalent to \verb|x^{y}\in\Omega| & $x^{y}\in\...
Juan A. Navarro's user avatar
10 votes
2 answers
31k 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} \...
周明暘's user avatar
  • 209
16 votes
5 answers
6k 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 ...
Ari B. Friedman's user avatar
9 votes
2 answers
3k views

How to copy/paste multiple spaces from lstlistings?

This is a continuation of a question that I asked already: How to copy/paste from lstlistings?. The solution presented there does not work if the text within the lstlistings environment contains ...
maurera's user avatar
  • 391
6 votes
2 answers
784 views

Keyboard TAB character in argument v (xparse)

I'm trying to understand how the TAB character of the keyboard behaves within verbatim. I have defined a new command using the v argument of the xparse, but, I get errors and a rather strange output ...
Pablo González L's user avatar
55 votes
3 answers
55k views

Verbatim in beamer showing error: "File ended while scanning use of \@xverbatim."

I am using Texmaker and MiKTeX on Windows 7. I have the following beamer code, \documentclass{beamer} \theme{AnnArbor} \begin{document} \begin{frame} \begin{verbatim} \begin{frame}[<alignment&...
Deepu's user avatar
  • 665
42 votes
4 answers
83k 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 and ...
trebor's user avatar
  • 421
24 votes
3 answers
5k views

In LuaLaTeX, how do I pass the content of an environment to Lua verbatim?

In LuaLaTeX, how would I go about capturing the content of an environment for (verbatim) processing by Lua? For example, consider something like \begin{foobar} Hello {World} \end{foobar} I'd like ...
Anselm Lingnau's user avatar
18 votes
4 answers
12k views

Adding background color to \verb or \lstinline command without \Colorbox

Update: In addition to my previous post, here's a screenshot to give you a better visual example. This was created with HTML and CSS for demo only. In CSS, the code part is made using font-family: ...
guest_5758's user avatar
12 votes
5 answers
7k views

newcommand for verbatim

I'm trying to write a \newcommand for verbatim: \newcommand{\codeline}[1]{\begin{verbatim}{#1}\end{verbatim}} and use it as \codeline{int foo;} but it gives an error "File ended while scanning use ...
Paul S.'s user avatar
  • 1,189
10 votes
1 answer
3k 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 ...
JJD's user avatar
  • 1,977
65 votes
6 answers
21k 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 this:...
vanden's user avatar
  • 31.3k
27 votes
2 answers
3k 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). ...
Tobi's user avatar
  • 56.6k
24 votes
4 answers
9k 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 ...
xubuntix's user avatar
  • 809
21 votes
3 answers
7k 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{{} \immediate\...
Romildo's user avatar
  • 4,093
14 votes
4 answers
2k views

Verbatim in environ’s \BODY

I’d like to print a TeX install guide for different OS, but the most text is the same for all OS. So I build the following \documentclass{article} \usepackage{environ} \newcommand{\mlw}[3]{} \...
Tobi's user avatar
  • 56.6k
22 votes
1 answer
11k 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 ...
Jóhann's user avatar
  • 1,845
21 votes
2 answers
20k views

Inserting LaTeX code into LaTeX

I have a problem with adding text into a LaTeX document. I have a LaTeX document about LaTeX and I need to insert some code snippets. I need to add "\usepackage{musixtex}" as a text, which should be ...
user avatar
18 votes
1 answer
3k 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 \begin{minipage}{...
romeovs's user avatar
  • 9,112
15 votes
2 answers
4k 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 ...
alexis's user avatar
  • 7,991
13 votes
4 answers
2k 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 ...
Hendrik Vogt's user avatar
  • 38.1k
41 votes
2 answers
17k 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 ...
csl's user avatar
  • 767
28 votes
1 answer
17k views

Center-align the verbatim environment

I am trying to center align 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 \...
cam's user avatar
  • 383
32 votes
3 answers
231k views

End \verbatim command

The verbatim environment is used to display LaTeX commands instead of having them executed. To display a single command in-line, the \verb|| command can be used. To display a whole block, we can use ...
Jeffrey Lebowski's user avatar
23 votes
3 answers
11k views

Getting verbatim with soft grey background, as in tex.stackexchange

Given a verbatim as on below, \begin{verbatim} This is an awesome verbatim \end{verbatim} which is displayed with no background on the compiled pdf page : This is an awesome verbatim I would ...
Martingal's user avatar
  • 1,336
22 votes
1 answer
7k 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].
WIZARDELF's user avatar
  • 1,335
21 votes
5 answers
7k 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 ...
Mark's user avatar
  • 1,855
8 votes
2 answers
2k 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 ...
Jonathan Protzenko's user avatar
6 votes
1 answer
508 views

verbatim-like environment with optional arguments poorly behaved

[EDITED to show where I actually want to use the optional argument] This question may be answered at How to pass an optional argument to an environment with verbatim content?, but I'm having a hard ...
Steven B. Segletes's user avatar
5 votes
1 answer
445 views

Optional arguments in verbatim environments

This question is a follow up to verbatim-like environment with optional arguments poorly behaved. Based on David Carlisle's suggestion, I manually looked for an optional argument and employed \...
Steven B. Segletes's user avatar
5 votes
4 answers
4k views

\verb in custom command

I have \newcommand\dd[2]{\item[\texttt{#1}] #2} and later I have \dd{bc}{text \verb#$(echo 5+4 | bc)# text \verb#$((5+4))# text} and I get ! You can't use `macro parameter character #' in math ...
Martin Ueding's user avatar
4 votes
1 answer
285 views

Non-curly quotes in code?

Here is a quick question, how to use tex to print this ' symbol? An example is shown below: data 'a list = Nil | Cons (e, 'a list) I tried to use ' or `, but they all looks bad.. I am sorry but I am ...
lllllllllllll's user avatar
3 votes
1 answer
2k 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}% \...
Jason Xu's user avatar
  • 1,793
2 votes
3 answers
418 views

How can one construct a macro that contains a pythontex or fancyvrb environment?

Goal: I want to create a command that executes pythontex code blocks from within a macro. Application: I have a macro that typesets some equations. I'd like for a side-effect of their use to be the ...
Rob Hall's user avatar
  • 143
38 votes
7 answers
61k 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 never ...
well actually's user avatar
29 votes
4 answers
36k views

Use color in verbatim environment

Inside the verbatim environment, is it possible to use a different color, please? For example, I want a to be normal, i.e., black. But I want b to be red. \documentclass[]{article} \begin{document} ...
LaTeXFan's user avatar
  • 1,573
24 votes
5 answers
3k views

How to use "`" in the same way it is used on the SE websites?

On any SE post one can use the backtick symbol ("`") in order to mark some text as being a piece of code, or computer output. For example: void main(). Is there a way to make use of "`" the same way ...
Remi.b's user avatar
  • 471
24 votes
4 answers
9k views

Defining a new environment extending a verbatim environment

Why is it not possible to define a new environment that extends a verbatim environment? Consider, e.g.: \documentclass{article} \newenvironment{myverbatim}{\tiny\begin{verbatim}}{\end{verbatim}} \...
Håkon Hægland's user avatar
23 votes
3 answers
8k 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 \end{...
Gerold Meisinger's user avatar
23 votes
6 answers
3k 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 ...
Timtico's user avatar
  • 2,260
22 votes
2 answers
27k 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?
stackoverflowuser2010's user avatar

1
2 3 4 5
7