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.
316
questions
16
votes
2
answers
3k
views
Using \lstinline inside a \item
I know about the fragility of verbatim-like commands, and that they should not be used as an argument of another macro, but a need to write a description environment in which the terms to be defined ...
14
votes
2
answers
5k
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}}
...
13
votes
4
answers
3k
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 \end{...
13
votes
4
answers
1k
views
How can I write % into a file?
How can I write % into an auxiliary file? % will not work, because LaTeX thinks that I start a comment with it (in the main file, not in the auxiliary file!), and \% will write \% into the file. How ...
11
votes
1
answer
13k
views
Changing color of text snippet in a verbatim environment
Is it possible to change color of part of the text that is in a verbatim environment?
Lets say I have this verbatim section. I want to change the color of the marked lines into blue.
\begin{verbatim}...
9
votes
1
answer
3k
views
Why does `! Missing $ inserted.` occur when using \verb in beamer?
When I use \verb+...+ within beamer I get
! Missing $ inserted.
<inserted text>
$
l.6 \end{frame}
?
What is going wrong and how do I fix this problem?
A minimal example is
...
6
votes
2
answers
2k
views
How do I define a custom verbatim command? [duplicate]
I'm not quite sure how to describe this, but I want to create a custom command that treats its input as verbatim and allows some control of the output.
In pseudocode, I want:
\newcommand{\code}[1]{\...
6
votes
3
answers
10k
views
How to set font size for all verbatims in Beamer presentation?
I'm trying to read through the Beamer manual, but I don't even really know what I'm looking for, so please help.
How do I change globally (but even if it is a per-frame, it will be still good) size ...
6
votes
1
answer
506
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 ...
5
votes
1
answer
2k
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 ...
5
votes
2
answers
1k
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 ...
5
votes
1
answer
771
views
Can you interpret macro parameters as verbatim?
Basically I want to define a macro whose parameter should be treated as a "script", meaning that I want to print it in a verbatim way including line breaks and special characters. Furthermore, I want ...
2
votes
3
answers
410
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 ...
2
votes
2
answers
620
views
Inserting RTL text in verbatim environment
How I can insert Persian text in verbatim environment when using XePersin package
( v11.138, 2012/05/03). Following code dose not work:
\begin{verbatim}
<!DOCTYPE book PUBLIC "-//OASIS//DTD ...
1
vote
2
answers
1k
views
Collect contents of an environment (that contains verbatim content)
EDIT: Additional and specific information.
There is some useful background info that should hopefully make clear exactly what I am doing, as well as the setting this is happening in which is relevant....
45
votes
1
answer
106k
views
In-line \verb -- overfull hbox problem
I'm having a problem that I've had before and I'm tired of hacking my way through it and hope that there is some supported solution. I'll go ahead and create a document for example:
\documentclass {...
29
votes
1
answer
46k
views
Automatically wrap the text in verbatim [duplicate]
In tex environment, when I try to use the verbatim function using verbatim packages, sometimes the longer text in the line tend to be cut off. How can I resize the text to fit into the line or ...
28
votes
1
answer
6k
views
escape `|' in \verb
In LaTeX, if I use \verb, how can I escape |? For example, I want to display ab|bc: \verb|ab[]bc|. What should replace []?
22
votes
3
answers
4k
views
Highlighting a .diff file
Is there a way to highlight the syntax of a diff file (i.e. by using the listings package)?
19
votes
2
answers
2k
views
How to make AUCTeX ignore syntax highlighting within environment
I have a problem with syntax highlighting in the Emacs editor using AUCTeX. The problem occurs in particular with the Verbatim environment from the fancyvrb package. Consider the following code:
\...
15
votes
1
answer
3k
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 ...
14
votes
2
answers
6k
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. ...
11
votes
4
answers
39k
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 following ...
11
votes
3
answers
2k
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 ...
10
votes
2
answers
4k
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, ...
10
votes
3
answers
6k
views
verbatim and overlays
I am trying to display a verbatim environment in an overlay. I have the following code but it is giving errors:
\only<2->{
\begin{verbatim}
Select T3.Subject
From T as T1, T as T2, T as T3
...
8
votes
2
answers
851
views
Changing verbatim input in beamer slide
I am trying to produce a presentation where code for a pair of arrays appear in the same position of a beamer slide.
I tried something like this (with different combinations and braces) and did not ...
7
votes
1
answer
2k
views
verbatim with black background and white text
How could I set up a verbatim-environment which has
black background
white text in scriptsize ?
7
votes
1
answer
2k
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 ...
7
votes
1
answer
760
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 ...
7
votes
1
answer
722
views
listings package in XeLaTeX: every tab in lstlisting compiles to "^^I" in the pdf [duplicate]
In beamer class, when i compile using LaTeX, the output pdf results perfectly the way i expect it to. But when i change it to XeLaTeX, in the lstlisting environment, every tab in the code results in a ...
6
votes
1
answer
7k
views
fancyvrb alternate commandchars and \textcolor
The following works:
\documentclass{article}
\usepackage{fancyvrb}
\usepackage{color}
\begin{document}
\begin{Verbatim}[commandchars=\\\{\}]
test\textcolor{red}{foo}test
\end{Verbatim}
\end{...
6
votes
1
answer
334
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
3
answers
2k
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}
5
votes
1
answer
293
views
How to print a verbatim block at its end automatically in LuaLaTeX?
This is a follow-up question to this answer by Mico. I try to adjust his Lua code to my needs and line numbering already works.
Actually there is one real usability issue and that's my question: How ...
4
votes
1
answer
532
views
Verbatim environment with catchfilebetweentags package
I would like to use a verbatim environment inside an ExecuteMetaData call from the catchfilebetweentags package.
The use case is that my econometric software creates a fixed-width table that I don't ...
3
votes
1
answer
910
views
How do I set a background color and font for inline verb text?
I wish to customize the verb command such that I can customize the font and color, as well as set a rounded colored rectangle as background.
I found this in the Tcolorbox manual:
\DeclareTotalTCBox{\...
2
votes
2
answers
997
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 ...
2
votes
3
answers
2k
views
Any ideas why this \newcommand{\n}{\lstinline|\n|} macro doesn't work?
So I created a new macro \newcommand{\n}{\lstinline|\n|} but for some reason when I use it, all I get is bold 'n' letter and not a nice \n. Any ideas?
39
votes
2
answers
40k
views
Inline code and short verb with minted
I it possible to use minted for inline code and to add a short verb sing for minted? Like \lstMakeShortInline| in listings.sty?
\documentclass{article}
\usepackage{minted}
\newminted{tex}{}
\...
34
votes
2
answers
97k
views
How to add line numbers to a program listing/code? [duplicate]
How do I copy code in to latex to get a result which looks like this:
...Without the red bars of course. I don't know how to get the numbering on the left side when I compile LaTeX. Using \verbatim ...
32
votes
2
answers
10k
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 ]; ...
30
votes
3
answers
27k
views
How to include verbatim in a figure caption?
I would like to include verbatim in a caption of a figure. I only want part of it to be verbatim, not the entire caption. The simple approach does not work because verbatim is not allowed in arguments ...
23
votes
1
answer
13k
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 ...
21
votes
1
answer
32k
views
what is the differences between "\verb" and "\tt"
I am wondering the diffference between \verb and \tt.
For example
\verb|difference| appears the same with \tt{difference}
20
votes
2
answers
1k
views
Incompatibility between verbatim and tabu? (Danger of using \scantokens in a package)
With the following MWE
\documentclass{article}
\usepackage{verbatim}
\usepackage{tabu}
\makeatletter
\renewcommand\verbatim@processline
{%
\begin{tabu}to\textwidth{|l|X[-1,l]|}
foo&\the\...
20
votes
4
answers
15k
views
How can I indent verbatim blocks?
I have blocks surrounded by \begin{verbatim} and \end{verbatim}. I'd like to indent these about half an inch. I'm using pandoc to write pdfs via XeLaTeX and the default.latex pandoc template, so I'd ...
19
votes
4
answers
14k
views
How can I have a verbatim text in specific sized box?
I am trying to typset the following
\resizebox{0.95\textwidth}{!}{%
\begin{verbatim}
require( "lattice" )
require( "grid" )
\end{verbatim}
}
I have a lot more to add to this box, and it needs ...
18
votes
3
answers
13k
views
How to box verbatim to prevent page break?
If I try
\mbox{
\begin{verbatim}
Some looooong text...
\end{verbatim}
}
Then some compilation errors occur.
17
votes
1
answer
13k
views
How do you insert an inline verbatim?
I'm trying to add an inline verbatim into a \paragraph?
Was wondering how do you do that?