Friday, 23 August 2013

LaTeX complaining commands in Verbatim

LaTeX complaining commands in Verbatim

Known Fact:
Have read this LaTeX complaining about illegal parameter number
With a Verbatim environment, every LaTeX commands will be handled as plain
text. However, I need a working command in the Verbatim.
Objective:
I have a sample.cls file that will be \VerbatimInput to a main .tex file
so that I can refer to later in the main file for explanations once it is
read in. What follows is the code I used to input sample.cls
\fvset{frame=none,numbers=left,numbersep=3pt,firstline=1,lastline=20}
\VerbatimInput[commandchars=+\[\]]{sample.cls}
and an image after read in is shown below (The sample.cls is a makeshift
here containing the following lines.)

For example, the block between line (9) and line (13) is what I am
refering to. Notice that the label format I used in sample.cls are
+label[vrb:test1] and +label[vrb:test2], which are not seen here due to
being two control sequences in the Verbertim environment.
The referring scheme by inserting a command in the Verbatim structure
works fine, but LaTeX complains those commands because they are embedded
in the sample.cls that the main file needs (in use.)
In short the labels, +label[vrb:test1] and +label[vrb:test2], are
equivalent to acting commands \label{vrb:test1} and \label{vrb:test1} in
the Verbatim environment, but LaTeX renders errors.
Question:
Although hitting ENTER key can still finish the compilation, I am writing
to seek help solving this dilemma (i.e., no need to hit ENTER key) and how
to avoid these contradictions.
Error signal obtained, Window, TeXworks environment
60 LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation. Type H for
immediate help. ...
l.60 \setlength{\topmargin}{-0.5cm} + label[vrb:psize1] 89 LaTeX Error:
Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation. Type H for
immediate help. ...
l.89 + label[vrb:cc] 175 LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation. Type H for
immediate help. ...
l.175 + label[vrb:title1]



sample.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{sample}[Sample class]
%-------------------------- initial code -----------------------
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
+label[vrb:test1]
%-------------------------- initial code -----------------------
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{report}}
%-------------------------- executation ---------------------
\ProcessOptions\relax
\LoadClass[a4paper,openright]{report}
+label[vrb:test2]
\endinput

No comments:

Post a Comment