Das Paket `` ist defekt

Das Paket `` ist defekt

Ich versuche, meine Klasse zu erweitern, indem ich mehrere Papierformate unterstütze und daher einige Optionen hinzufüge, indem ich

\DeclareOption{a5paper}{% Paper size: 148mm x 210mm
%   \SBpaperAfivetrue
%   \SBpaperAsixfalse
}

Mein gesamtes Dokument als MWE sieht so aus

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{Liederbuch}[2016/02/04 version 1.00 Decoration and placement of songs]
\typeout{Book subclass: Liederbuch 2016/02/04 v 1.00}
% --- Class structure: declaration of options part
% --- 
% This class extends the book class
% Read all the documentclass options; pass them to book
\DeclareOption*{\InputIfFileExists{\CurrentOption.min}{}{%
    \PassOptionsToClass{\CurrentOption}{book}}}

% --- Class structure: execution of options part
% --- 
\ProcessOptions \relax

% --- Class structure: declaration of options part
% ---
\LoadClass{book}
%Page layout
%\RequirePackage{xcolor}
\RequirePackage{gtrcrd}
\RequirePackage{stackengine}
\RequirePackage{graphicx}
\RequirePackage[utf8]{inputenc} 
\RequirePackage[T1]{fontenc} 
\RequirePackage[dvipsnames]{xcolor} 
\RequirePackage[object=vectorian]{pgfornament}
\usetikzlibrary{calc}
\RequirePackage[left=1in, right=1in, top=1in, bottom=1in]{geometry}
\RequirePackage{fancyhdr}

% --- Page size
% --- Option declaration for page size
\DeclareOption{a5paper}{% Paper size: 148mm x 210mm
%   \SBpaperAfivetrue
%   \SBpaperAsixfalse
}

in ein Dokument importiert als

\documentclass[8pt,a6paper]{Liederbuch}
%\usepackage[utf8]{inputenc}
\begin{document}
Hallo 2
\newpage
Test
\newpage
Test 3
\end{document}

Wenn ich das verlasse \DeclareOption, erhalte ich die Fehlermeldung

The package `' is defective.
It attempts to load `pdftexcmds' in the options section, i.e.,
between \DeclareOption and \ProcessOptions.

Wenn ich es entferne, ist alles in Ordnung. Wenn ich die \ProcessOptionOption nach der Deklaration verschiebe, bekomme ich noch mehr Fehler. Was mache ich falsch?

Antwort1

Die richtige Reihenfolge sollte sein

\DeclareOption{<option>}{<code>} % any number of them
\ExecuteOptions{<option list>} % optional
\ProcessOptions\relax

\LoadClass{<class>}

Nach dieser Zeile können weitere Einstellungen hinzugefügt werden, insbesondere das Hinzufügen von Paketen.

verwandte Informationen