Text Formattingfancyvrb + math

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
x42bn6
Posts: 14
Joined: Tue Apr 07, 2009 1:35 am

fancyvrb + math

Post by x42bn6 »

Hi all,

I'm trying to put mathematical symbols in a Verbatim environment:

Code: Select all

%& -shell-escape

\documentclass[a4paper]{article}

\usepackage{fancyvrb}

\begin{document}
\begin{Verbatim}[commandchars=\\\{\},
codes={\catcode‘$=3\catcode‘^=7}]
x=1/sqrt(z**2) ! $\frac{1}{\sqrt{z^2}}$
\end{Verbatim}
\end{document}
This is basically the example given in the documentation (section 4.1.16).

It fails to compile:

Code: Select all

! Missing number, treated as zero.
<to be read again>
                   `
l.9 codes={\catcode`$=3\catcode`^=7}]
Does anyone know why?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
meeheal
Posts: 1
Joined: Mon Oct 28, 2024 8:28 pm

fancyvrb + math

Post by meeheal »

Getting errors just like the one you were getting. I changed my code to this (note it's a back-tick, not a single quote after the catcode):

Code: Select all

\begin{Verbatim}[commandchars=\\\{\},
codes={\catcode`$=3}]
and it ran fine

Code: Select all

$\lambda$
was properly included as the Greek letter lambda, inside the Verbatim section. I couldn't ever figure out how to not get the error when it had both catcodes together \catcode`$=3\catcode`^=7
Post Reply