Questions tagged [fancyvrb]

{fancyvrb} is a package that provides sophisticated facilities for reading and writing verbatim TeX code.

fancyvrb is a package that provides

flex­i­ble han­dling of ver­ba­tim text in­clud­ing: ver­ba­tim com­mands in foot­notes; a va­ri­ety of ver­ba­tim en­vi­ron­ments with many pa­ram­e­ters; abil­ity to de­fine new cus­tomized ver­ba­tim en­vi­ron­ments; save and re­store ver­ba­tim text and en­vi­ron­ments; write and read files in ver­ba­tim mode; build "ex­am­ple" en­vi­ron­ments (show­ing both re­sult and ver­ba­tim source). [CTAN]

199 questions
13
votes
3 answers

Is there a way to make a certain character in a Verbatim have a certain formatting?

I am writing this report on a computing simulation of the Ising model. I am pressenting lattice configuration samples, which are just an array of "+" and "-". This is done in order to visualize the different "magnetic domains" which means I really…
guillefix
  • 252
8
votes
2 answers

How can I get straight single quotes in a custom Verbatim command?

I use the \Verb command from the fancyvrb pacakge for in-text verbatim fragments. To get straight single quotes, I also loaded the upquote package. Unfortunately, this does not work when I use a custom command of the…
Ian Thompson
  • 43,767
6
votes
2 answers

formatting certain texts in \fancyvrb environments automatically

I have for example the following Verbatim environment from the fancyvrb package: \begin{Verbatim} >>> 1+1 2 >>> \end{Verbatim} Whenever ">>>" appears, I want to color it blue. Instead of manually coloring those, can I do the coloring job…
Chang
  • 9,528
6
votes
1 answer

Alternative commandchars in fancyvrb

In my Verbatim I need to specify colour for my code. In this answer (fancyvrb alternate commandchars and \textcolor) the solution is to put this code in the preamble: \newcommand*{\fvtextcolor}[1]{\textcolor{#1}{#2}} and then use…
6
votes
1 answer

How to have fancyvrb number every other line starting with the first?

The following MWE using fancyvrb produces line numbers every other line, starting on the second line, like so: Writing some test 2 third line 4 fourth line fifth line so the numbers are 2, 4, 6,.... I would like the numbers to start on the…
darthbith
  • 7,384
5
votes
1 answer

fancyvrb and \overfullrule

I know I can use \overfullrule=5pt to get overfull lines marked with a black marker, but using the Verbatim environment from the fancyvrb package the overfull lines are not marked. For…
asr
  • 331
5
votes
2 answers

Is there a simple method of attaching labels to some lines inside a "Verbatim" environment?

I have many Verbatim environments in my document, which contain source code with different characters inside, including {, (, [, <. I'm trying to find a way of attaching labels to some lines inside these environments. This looks clumsy, since I have…
yegor256
  • 12,021
5
votes
1 answer

Unicode characters within VerbatimOut of fancyvrb

Consider the following example, in which the sentence Ceci est un résumé. is written into the file \jobname.mytmp and then being read back. \documentclass{article} \usepackage{fancyvrb} \begin{document} \begin{VerbatimOut}{\jobname.mytmp} …
Jinwen
  • 8,518
5
votes
1 answer

Combining DefineVerbatimEnvironment with UseVerbatim

I would like to combine the power of \DefineVerbatimEnvironment with \UseVerbatim within a combined beamer presentation and handout scenario. I have already defined the environment coding, and now I can typeset my code using \begin{coding} …
vwegert
  • 2,875
4
votes
1 answer

How to disable "commandchars" in a "Verbatim" environment?

How can I disable commandchars for a particular Verbatim environment, if I set it as a global option via \fvset earlier? I'm trying…
yegor256
  • 12,021
4
votes
1 answer

How to escape a TeX command inside a Verbatim environment?

I'm trying this: \documentclass{article} \usepackage{fancyvrb} \fvset{commandchars=\|} \begin{document} \begin{Verbatim} Hello, |\textbf{world}|! \end{Verbatim} \end{document} However, I'm getting this: ! Improper alphabetic constant.
yegor256
  • 12,021
4
votes
1 answer

line number not works for fancyvrb with SaveVerbatim

The following code tells every thing \documentclass{article} \usepackage{fancyvrb} \begin{SaveVerbatim}{FOO} However, if I define an reusable Verbatim by SaveVerbatim, line number failed to…
Qiang
  • 184
3
votes
2 answers

How to pass arguments to a "Verbatim" environment from a variable?

The arguments that I need to pass to a Verbatim environment are in a variable. I'm trying to do this: \documentclass{article} \usepackage{fancyvrb} \begin{document} \def\opts{numbers=left} \begin{Verbatim}[\opts] Hello,…
yegor256
  • 12,021
3
votes
1 answer

fancyvrb dynamic label

I load multiple source files into a document using the fancyvrb package. I found out how to include a static label. Now, I want to display the filename in the label (dynamic label based on input file). How can I achieve this? In the following…
Molitoris
  • 177
3
votes
1 answer

fancyvrb: multiple actives

this works great---well, I stole it right out of the docs: { \catcode`!=\active \begin{Verbatim}[defineactive=\def!{\color{red}\bf}] black ! red black \end{Verbatim} } now I would like to have multiple active characters, each…
ivo Welch
  • 3,766
1
2