GeneralFunction to Create Counter If It Doesn't Exist?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
EFaden
Posts: 24
Joined: Thu Jun 04, 2009 2:58 am

Function to Create Counter If It Doesn't Exist?

Post by EFaden »

Basically I want to have a command do some stuff... inside of the command I want to create a counter using the name passed in if the counter doesn't exist.... it doesn't seem to want to do what I want it to do.... it is in a cls file. I am using xkeyvars to process #1 so the variable \myvars@countername is set by setkeys.

Code: Select all

\newcommand{\flashcard}[1]{%
	\setkeys{myvars}{#1}
	
	\@ifundefined{c@\myvars@countername}}{
              \newtotcounter{\myvars@countername}
         }		
		
        \stepcounter{\myvars@countername}
		
	\renewcommand{\groupcount}{\total{\myvars@countername}}
	\renewcommand{\groupthis}{\arabic{\myvars@countername}}

	\setkeys{myvars}{}
}
Any advice?

Recommended reading 2024:

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

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

Post Reply