\DeclareOption の Fancypagestyle

\DeclareOption の Fancypagestyle

私のクラスでは、最初にページ レイアウトを定義し\DeclareOption、宣言中にそれを変更したいと考えています\newenvironment。そのためには、パッケージを使用したいと考えていましたfancyhdr。現在の問題は、a) 後でパッケージをロードする必要があること\ProcessOptionsと、b) 環境内でページ プロパティをオンザフライで変更または拡張する方法がわからないことです\newenvironment。基本的に必要なのは (疑似コード):

\DeclareOption{test}{%
    \fancypagestyle{aSix}{%
    }
} 
\ProcessOptions
\newenvironment{test2}{%
\fancypagestyle{aSix2}{
%Takes the pagestyle aSix and update it with additional values}

これどうやってするの?

答え1

クラス オプションが使用されている場合は、でこれを に設定するなどconditional、別のアプローチを使用することをお勧めします。\ifaSixtrue\aSixtrue

初級クラス

\ProvidesClass{ishouldgivemoreinformation}

\newif\ifaSix
\DeclareOption{aSix}{\global\aSixtrue}


\ProcessOptions

\LoadClass{article}

\RequirePackage{fancyhdr}

\fancypagestyle{aSix}{%
  \fancyhead[C]{Foo}
  \renewcommand{\headrulewidth}{5pt}
}

\ifaSix
\fancypagestyle{aSix2}{%
  \pagestyle{aSix}%
  \fancyfoot[c]{Foobar}%
  % Some updates here
}
\else
\fancypagestyle{aSix2}{%
  \pagestyle{aSix}%
}
\fi

\endinput

driver.tex

\documentclass[aSix]{ishouldgivemoreinformation}


\pagestyle{aSix2}
\begin{document}
FOO
\end{document}

関連情報