# How to configure a custom class such that consumer settings must be loaded before the class settings?

## My custom class

The purpose of this class is to create a single PSTricks diagram in a tight paper size.

\ProvidesClass{pst-xport}[2011/07/23 v 0.01 class for creating a single PStricks diagram]
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax
\RequirePackage{pstricks}

\newcommand\LL{-1}
\newcommand\RR{1}
\newcommand\BB{-1}
\newcommand\TT{1}

\special{papersize=\the\paperwidth,\the\paperheight}

\parindent=0pt
\pagestyle{empty}

%%%%%%%%%%%%%%%%%%%
%%%% INTERFACE %%%%
%%%%%%%%%%%%%%%%%%%

\newcommand\SetCanvas[4]
{
\renewcommand\LL{#1}
\renewcommand\BB{#2}
\renewcommand\RR{#3}
\renewcommand\TT{#4}
}

\newcommand\SetCan[1]
{
\SetCanvas{-#1}{-#1}{#1}{#1}
}

{
}

{
}

\endinput


## Consumer

The consumer uses pst-xport class as follows.

\documentclass{pst-xport}

%\SetCanvas{-2}{-2}{2}{2}
\SetCan{2}

\psset
{
xunit=1cm,
yunit=2cm
}

\begin{document}
\begin{pspicture}[showgrid=true](\LL,\BB)(\RR,\TT)
\psframe[linecolor=red](\LL,\BB)(\RR,\TT)
\end{pspicture}
\end{document}


## Problem

However, the consumer settings cannot affect because they come last. How to configure a custom class such that consumer settings must be loaded before the class settings?

Bonus question: How to translate those settings to key-value settings that are more sophisticated?

-
You seem to forget about \AtBeginDocument –  egreg Jul 22 '11 at 18:51

You could calculate your settings at the end of the preamble so that the user changes take effect.

\AtBeginDocument{%

Or provide some \updatesettings macro which does all adjustsments.