GeneralErrors with labels in new environment

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
flashflail
Posts: 7
Joined: Wed Dec 02, 2009 12:30 pm

Errors with labels in new environment

Post by flashflail »

Hi there,

I defined a new environment. The problem with it is, that I get errors if I place a \label{} in it. What am I doing wrong?

The definition:

Code: Select all

%minisec
\newcommand*{\minisec}[1]{\par
  \vspace{-\parskip}\vspace{8mm}\noindent
  \textsf{\textbf{#1}}\par\nobreak
  \vspace{-\parskip}\nobreak\vspace{2mm}\nobreak\noindent
  \ignorespaces
}

\newcounter{uczaehler}
\def\theuczaehler{[UC.\arabic{uczaehler}]}

\newenvironment{usecase}[2]{
	\refstepcounter{uczaehler}
	\minisec{\theuczaehler\ #1}
	#2
	\vspace{5mm}\sffamily\footnotesize%
	\rowcolors{1}{tapbabyblue}{white}%
	\begin{longtable}{|p{.2\textwidth}p{.65\textwidth}|}
		\hline\endfirsthead
		\hline\endlastfoot
}
{\end{longtable}\normalsize\rmfamily}
The normal usage:

Code: Select all

\begin{usecase}{Header}
\par Bla & Some more bla  \\
Blabla & enough of bla\\
etc & and so on \\
\end{usecase}
My usage with \label{}, which produces error:

Code: Select all

\begin{usecase}{Header}\label{mylabel}
\par Bla & Some more bla  \\
Blabla & enough of bla\\
etc & and so on \\
\end{usecase}
I also tried to define the label at different positions, no improvement.

And now what latex tries to tell me (the first error):

Code: Select all

! Missing \endcsname inserted.
<to be read again>
                  \protect
l.253 ...{35}{ASectionName\relax }{uczaehler.5}{}}
"ASectionName" means the last subsection-name.
The error points at the following line in the aux-file

Code: Select all

\newlabel{\vspace  }{{[UC.5]}{35}{ASectionName\relax }{uczaehler.5}{}}
Further errors are:

Code: Select all

! Missing number, treated as zero.
<to be read again>
                   \endcsname
l.253 ...{35}{ASectionName\relax }{uczaehler.5}{}}

! Illegal unit of measure (pt inserted).
<to be read again>
                   \endcsname
l.253 ...{35}{ASectionName\relax }{uczaehler.5}{}}

! Extra \endcsname
<to be read again>
                   \endcsname
l.253 ...{35}{ASectionName\relax }{uczaehler.5}{}}
I really have no idea what these errors try to tell me :cry:

Help please!!!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Errors with labels in new environment

Post by gmedina »

Hi,

with your definitions, try using the environment like this:

Code: Select all

\begin{usecase}{Header}{}
  \label{mylabel}
  \par Bla & Some more bla  \\
  Blabla & enough of bla\\
  etc & and so on \\
\end{usecase}
1,1,2,3,5,8,13,21,34,55,89,144,233,...
flashflail
Posts: 7
Joined: Wed Dec 02, 2009 12:30 pm

Re: Errors with labels in new environment

Post by flashflail »

Thanks so far, the error is gone.

But by referencing the entry I don't get what I was expecting.
Reference looks like: 3.1 (Chapter.EnvironmentNumber)
I expected: [UC.1] (like defined in \theuczaehler)

If I use more than one usecase-environment with a label, the same error as before occurs.

Any further solutions?
Post Reply