f



Problem using fancyvrb package

Please can someone familiar with the fancyvrb package help me resolve
the following problem?

\documentclass{article}
\usepackage{fancyvrb,xcolor}
\makeatletter

% I replaced \end with \finish in the following codes because I prefer
to use finish. No problem here:

\begingroup
\catcode`\!=0
\catcode`\[=1
\catcode`\]=2
!gdef!FV@CheckEnd@i#1[!FV@@CheckEnd#1\finish{}!@nil]
!gdef!FV@@CheckEnd@i#1\finish#2#3!@nil[!def!@tempa[#2]!def!@tempb[#3]]
!gdef!FV@@@CheckEnd@i[\finish{}]
\catcode`!\=12
!gdef!FV@CheckEnd@ii#1[!FV@@CheckEnd#1\finish{}!@nil]
!gdef!FV@@CheckEnd@ii#1\finish#2#3!@nil[!def!@tempa[#2]!def!
@tempb[#3]]
!gdef!FV@@@CheckEnd@ii[\finish{}]
!catcode`!{=12
!catcode`!}=12
!gdef!FV@CheckEnd@iii#1[!FV@@CheckEnd#1\finish{}!@nil]
!gdef!FV@@CheckEnd@iii#1\finish{#2}#3!@nil[!def!@tempa[#2]!def!
@tempb[#3]]
!gdef!FV@@@CheckEnd@iii[\finish{}]
!catcode`!\=0
!gdef!FV@CheckEnd@iv#1[!FV@@CheckEnd#1\finish{}!@nil]
!gdef!FV@@CheckEnd@iv#1\finish{#2}#3!@nil[!def!@tempa[#2]!def!
@tempb[#3]]
!gdef!FV@@@CheckEnd@iv[\finish{}]
\endgroup

\CustomVerbatimEnvironment{myverbatim}{Verbatim}{numbers=left,
  label={\mylabel},labelposition=topline,firstnumber=last,
  frame=single,rulecolor=\color{blue},commentchar=&}

\newcommand*\startmyverbatim[1][Example]{%
  \def\mylabel{\textcolor{blue}{#1}}%
  \begin{myverbatim}%
}

\newcommand\start[1]{%
  \ifcsname start#1\endcsname
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\csname start#1\endcsname}%
  {\@latex@error{Command '\@backslashchar start#1' not defined}\@ehc}%
}

\begin{document}

% Failed:

\start{myverbatim}
This is a sample verbatim text.
\finish{myverbatim}

% Worked with optional argument [Example]:

\start{myverbatim}[Example]
This is a sample verbatim text.
\finish{myverbatim}

\end{document}

The error is from the following. I wonder why it can't find
\endlinechar ^^M on the first line when there is no optional argument:

\begingroup
\catcode`\^^M=\active
  \gdef\FV@BeginScanning#1^^M{%
    \def\@tempa{#1}\ifx\@tempa\@empty\else\FV@BadBeginError\fi%
    \FV@GetLine
  }%
\endgroup
0
Pluto
9/8/2010 7:36:15 PM
comp.text.tex 39029 articles. 3 followers. Post Follow

0 Replies
592 Views

Similar Articles

[PageSpeed] 8

Reply: