我試圖透過支援多種紙張尺寸來擴展我的課程,因此請添加一些選項
\DeclareOption{a5paper}{% Paper size: 148mm x 210mm
% \SBpaperAfivetrue
% \SBpaperAsixfalse
}
我作為 MWE 的整個文件看起來像
\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
}
在文件中導入為
\documentclass[8pt,a6paper]{Liederbuch}
%\usepackage[utf8]{inputenc}
\begin{document}
Hallo 2
\newpage
Test
\newpage
Test 3
\end{document}
如果我離開\DeclareOption
,那麼我會收到錯誤
The package `' is defective.
It attempts to load `pdftexcmds' in the options section, i.e.,
between \DeclareOption and \ProcessOptions.
如果我刪除它,一切都很好。如果我\ProcessOption
在聲明之後移動該選項,則會收到更多錯誤。我究竟做錯了什麼?
答案1
正確的順序應該是
\DeclareOption{<option>}{<code>} % any number of them
\ExecuteOptions{<option list>} % optional
\ProcessOptions\relax
\LoadClass{<class>}
在此行之後,可以添加其他設置,特別是添加軟體包。