LaTeX forum ⇒ Text Formattingfancyvrb + math

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

fancyvrb + math

Postby x42bn6 » Sun Nov 22, 2009 6:13 am

Hi all,

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

%& -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:

! 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
meeheal
Posts: 1
Joined: Mon Oct 28, 2024 8:28 pm

fancyvrb + math

Postby meeheal » Mon Oct 28, 2024 8:56 pm

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):
\begin{Verbatim}[commandchars=\\\{\},
codes={\catcode`$=3}]

and it ran fine
$\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


Return to “Text Formatting”

Who is online

Users browsing this forum: No registered users and 6 guests