I am trying to figure out how to use a variable in a class.

From another question (Macro for Declaring Variables in Class Files) I got started. However, I find myself in need of using four lines or rather unclear code. This is what I have:

\printheadertitle{} % This will print the string in the variable

It works, but doesn't look good. I simply want to use \headertitle{string} in my document, and be able to somehow call it (e.g. \headertitle{} within my class. Can I simplify this?


1 Answer 1


The first and fourth lines are not doing anything very useful, so you can simplify by removing them, then:

If your class or package code has


then your document can go

\headertitle{hello world}

and at any point later


will produce hello world

This will mean that you get an error if \printheadertitle is used without defining a title. If you want a default title to be silently accepted add in your class code


or some default other than empty.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .