I will use a general class file that can load the specific class as an option and create a boolean type test for all the different classes. The following is just a first try. It can be enhanced with keyvalues, etc.
Edit 1: Add command \ClassList to provide your own class list.
%%%% generalclass.cls %%%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{generalclass}[2012/04/19 v0.1 General class (DNJ ELS)]
\RequirePackage{etoolbox}
\newcommand*\DeclareClassList[2]{%
\def\@clsopt@select{#1}%-------------------- default class
\edef\@clsopt@list{\zap@space#2 \@empty}%--- list of classes
\@for\@clsopt@item:=\@clsopt@list\do{%
\newbool{@clsopt@test@\@clsopt@item}%
\csedef{@clsopt@def@\@clsopt@item}{%
\def\noexpand\@clsopt@select{\@clsopt@item}}}
\edef\@currclass@opt{\@ptionlist{\@currname.\@currext}}%
\@for\CurrentOption:=\@currclass@opt\do{%--- Go through documents options
\ifcsdef{@clsopt@def@\CurrentOption}{%
\csuse{@clsopt@def@\CurrentOption}%
\csdef{ds@\CurrentOption}{}%
\@use@ption}{}}}
\newcommand*\ThisClass{}
\newcommand\SetClassOption{%
\edef\@clsopt@temp{%
\noexpand\booltrue{@clsopt@test@\@clsopt@select}%
\def\noexpand\ThisClass{\@clsopt@select}}%
\@clsopt@temp}
\newcommand\IfClass[3]{%
\ifbool{@clsopt@test@#1}{#2}{#3}}
%----------------------------------------------------------------------
\providecommand*\ClassDefault{article} % Edit 1
\providecommand*\ClassList{article,report,book,letter} % Edit 1
\DeclareClassList{\ClassDefault}{\ClassList} % Edit 1
\SetClassOption
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\ThisClass}}
\ProcessOptions\relax
\LoadClass{\ThisClass}
\endinput
It can then be used as follows:
\newcommand*\DocType{memoir}
\newcommand*\FontSize{10pt}
\newcommand*\PaperSize{a4paper}
%---- [ Put this in template for \input{} ] -------------
\newcommand*\ClassList{article,report,book,letter,memoir}
\documentclass[\DocType,\FontSize, \PaperSize]{generalclass}
%% Usage
%\IfClass{article}{..<true>..}{..<false..}
%\IfClass{report}{..<true>..}{..<false..}
%\IfClass{book}{..<true>..}{..<false..}
%\IfClass{letter}{..<true>..}{..<false..}
%\IfClass{memoir}{..<true>..}{..<false..}
%---- [ End template ] ----------------------------------
\begin{document}
This class is: \ThisClass \par
This is \IfClass{article}{an}{not an} article class document\par
This is \IfClass{report}{a}{not a} report class document\par
This is \IfClass{book}{a}{not a} book class document\par
This is \IfClass{letter}{a}{not a} letter class document\par
This is \IfClass{memoir}{a}{not a} memoir class document\par
\end{document}
\doctypebe the document class itself? So then you can say\documentclass{\doctype}, and afterwards load the appropriate preamble. – Peter Grill Apr 18 '12 at 19:56\ifx. See here for an example: What does \ifx\#1\ stand for? – Marco Daniel Apr 18 '12 at 19:57