I know LaTeX just to the point of making simple documents and modifying simple characteristics of a document's layout. Now I'm creating a class for a kind of document in order not to have to copy a huge preamble in every document, and I don't know to achieve what I want to do. First of all, the class inherits from the article class, uses otf fonts so I'm compiling with XeLaTeX, and uses the fancyhdr package.

I want to specify the fancyhdr headers inside the .cls file because they're all going to have the same style, so I would like to include in the .cls file the lines:

\lhead[<even output>]{<odd output>}
\chead[<even output>]{<odd output>}
\rhead[<even output>]{<odd output>}

What's inside, though, would have to be parameters that would be specified in the .tex file, like the document's title, or the author's name, or other stuff. How could I pass this kinds of arguments to the .cls file. If a general solution is given (in order to learn LaTeX besides being able to do what I want), I would very much appreciate it too.

Thank you very much.


As it can be seen in the article class file article.cls the above parameters can be called via \@author, \@title and so on. The below answer by Christian answers what I asked in the comments, and shows how to create different parameters in the class file that could be defined from the .tex file.

  • Did you look into article.cls as a starter? – user31729 Jun 14 '15 at 8:31
  • @ChristianHupfer Well, I feel very embarrased to say I didn't. I saw it uses \@author and so on. Is that general? How could I define in the class a "parameter" (I don't know how to call it) so I could access it from the cls via that method? Because the article class doesn't define author and title (I guess they're standard TeX parameters). – MyUserIsThis Jun 14 '15 at 8:39
  • @ChristianHupfer Should I add those questions to the original question? – MyUserIsThis Jun 14 '15 at 8:40
  • I'll try to provide a solution, give me some minutes ;-) – user31729 Jun 14 '15 at 8:41
  • the \@author etc commands are defined using \author etc. They are no class options – user31729 Jun 14 '15 at 9:08

The class



\def\docauthorname{A. U. Thor}%


\define@key{mysuperclass.cls}{author}[A. U. Thor]{%




The class driver file:


  • I will add the second question to the original post to make it coherent with this answer. Thank you again. – MyUserIsThis Jun 14 '15 at 8:53
  • @MyUserIsThis: Please wait, there is an error! – user31729 Jun 14 '15 at 8:53
  • No problem. I will not use it right away. Thank you again for the help. – MyUserIsThis Jun 14 '15 at 8:55
  • @MyUserIsThis: Well, I corrected the solution – user31729 Jun 14 '15 at 9:07

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.