0

I'm deriving my own class from scrartcl but wan to introduce variables as in scrlttr2 for the user of the class to set several values. I find the \setkomavar resp. \usekomavar mechanism with key, value and description quite convenient.

Is there any way of using komavars if I'm not using the scrlttr2 class?

My actual problem

Currently I get Undefined control sequence. \setkomavar if I use \setkomavar.

My new class will have a title page which includes an address and a logo which I want to set with komavars as it is done in scrlttr2. To define this titlepage I renew the \maketitle command, which is not available if I would derive my class from scrlttr2.

white_gecko
  • 2,101
  • No, \newkomavar is only defined in scrlttr2.cls (and will be in scrletter.sty). You could however extract it from the definition. – Johannes_B Nov 27 '14 at 09:26
  • There are other ways for the user to set variables. What do you have in mind? A short example (great if its compilable) will make it easier to help. – Johannes_B Nov 27 '14 at 09:27
  • Ok, I hope I could make my point a little bit more understandable with this edit. – white_gecko Nov 27 '14 at 09:44
  • Please look at the very bottom of this answer: How to add a flyleaf code? – Johannes_B Nov 27 '14 at 09:46
  • Ok, that looks good in the way that I could add titlepages to scrlttr with this package but I will not be able to change the descriptions of the values Gutachter, 2. Gutachter, … in your example. – white_gecko Nov 27 '14 at 09:52
  • This is not your first question on TeX.SX, you know how to provide information in a way, that a helper understands what you are after. – Johannes_B Nov 27 '14 at 09:56
  • You are developing a class (for scientific writing i guess) and want to have a titlepage. You can use a class like scrreprt and use the titlepage project. If you give us some detailed information, we will be able to help you in a less generic way. – Johannes_B Nov 27 '14 at 10:00
  • I appreciate your help and I'm sorry if there are any misunderstandings. – white_gecko Nov 27 '14 at 10:02
  • No need to feel sorry, i just had a bad start. ;-) sorry. – Johannes_B Nov 27 '14 at 10:05
  • I'm developing a class, that is correct but unfortunately it is not for scientific writing but rather a brochure. I've already created the theme with pstricks and now want to add some placeholders for values, which the user will be able to set, while some will have a description, which might be changed (the whole layout is not as fixed as e.g. for a thesis). So I found the way komvar is doing it quite flexible (with key, value and description) but I think in the end any simple key-value mechanism should do the trick as well. – white_gecko Nov 27 '14 at 10:12
  • Ok, as it seams \csdef and \csuse from etoolbox is what I'm looking for (http://tex.stackexchange.com/a/37429/11820). – white_gecko Nov 27 '14 at 10:56

2 Answers2

4

With the current version of KOMA-script you get package scrletter which is is still in beta. It provides the ability to write letters with the with the article, report or book class of KOMA-script. Hence, it defines the mechanism you want.
In the following a simple example to set the page header with the name.

\documentclass{scrartcl}
\usepackage{blindtext}
\usepackage{scrletter}
\newkomavar[Autor:]{name}
\setkomavar{name}{White Gecko}
\usepackage{scrlayer-scrpage}
\ohead*{\usekomavar*{name}~\usekomavar{name}}
\begin{document}
\blinddocument
\end{document}
Johannes_B
  • 24,235
  • 10
  • 93
  • 248
3

A good general replacement for komavar is \csdef, \csuse from etoolbox as explained here: https://tex.stackexchange.com/a/37429/11820

A usage scenario is this:

\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{simplevar}[2014/11/27 simplevar package]

\RequirePackage{etoolbox}

% Set a value for a key
\newcommand\setVar[2]{\csdef{simpleVarValue#1}{#2}}
% Get the value for the key
\newcommand\getVar[1]{\csuse{simpleVarValue#1}}

% Set a label for a key
\newcommand\setLabel[2]{\csdef{simpleVarLabel#1}{#2}}
% Get the label for a key
\newcommand\getLabel[1]{\csuse{simpleVarLabel#1}}

\endinput

It could also be extended to use the same syntax as komavar or maybe one could introduce a kind of namespace to make the simpleVar… part configurable.

white_gecko
  • 2,101