1

Suppose that I try to write a test_cls class, in which I want to provided a command \inst, that can be used by the user and also in the class doc itself.

The class file named test_cls.cls looks like:

\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{test_cls}

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{test_cls}}
\ProcessOptions\relax
\DeclareRobustCommand{\inst}[1]{\def\inst@value{#1}}
\DeclareRobustCommand{\theauthor}{\inst@value\\\@author}

\LoadClass{article}

And the test_cls.tex is

\documentclass{test_cls}
%\inst{test}
\author{tester}
\begin{document}
  \theauthor
\end{document}

The problem is this can't work and hint me that the command \inst@value is not defined.

I can solve this problem by add the default value by

\AtEndOfPackage{
  %for the default value
  \inst{default}
}

But don't know is there any other better way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.