Consider the following style file goat.sty:
\NeedsTeXFormat{LaTeX2e}[2014/05/01]
\ProvidesPackage{goat}[2014/10/16 goat]
\DeclareOption{mammalbirdfish}{
\makeatletter
\begingroup
\catcode`\_=\active
\protected\gdef_{\@ifnextchar|\subtextup\sb}
\endgroup
\def\subtextup|#1|{\sb{\textup{#1}}}
\AtBeginDocument{\catcode`\_=12 \mathcode`\_=32768}
\makeatother}
\ExecuteOptions{mammalbirdfish}
\ProcessOptions
When I try to load the package in my LaTeX document be executing \usepackage{goat}, I get the following error:
! Missing control sequence inserted.
<inserted text>
\inaccessible
l.13 \ExecuteOptions{mammalbirdfish}
How do I get the above chunk of code into my style file?
P.S. I've never written a style file before so please forgive me if my question has a trivial answer.
Update
I also can't put
\ExplSyntaxOn
\cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
into my style file
\NeedsTeXFormat{LaTeX2e}[2014/05/01]
\ProvidesPackage{goat}[2014/10/16 goat]
\RequirePackage{expl3}
\DeclareOption{macros}{
\ExplSyntaxOn
\cs_new_eq:NN \calc \fp_eval:n
\ExplSyntaxOff
}
\ExecuteOptions{macros}
\ProcessOptions
When I compile the doucment
\documentclass{article}
\usepackage{goat}
\begin{document}
test
\end{document}
it gives the error
! Undefined control sequence.
\ds@makroer ...scriptfalse \par \ExplSyntaxOn \cs
_new_eq:NN \calc \fp _eval...
How do I fix this?
(Let my know if I should ask the update question as a new one; it was put here because I think it might be a similar problem.)
*.styfile is storing it in the same directory where is the*.texfile where you load that file. I know there is a way to store it in a local directory and there invokes it whenever you need but I don't do it yet. – Aradnix Oct 16 '14 at 00:07\makeatletter... \makeatotherin.sty,.clsetc. files.@is already a letter in this context. You only need these in documents (preferably in the preamble). [I don't suppose this is the problem. Just 'by the way...'.] – cfr Oct 16 '14 at 00:12\ifand use the option to toggle the\if, then you can execute the code after\ProcessOptionsconditionally. E.g.\newif\ifmammalbirdfish \mammalbirdfishfalseand then put\mammalbirdfishtruein the option declaration and the code which is currently there in an\ifmammalbirdfish ... \fiafter\ProcessOptions. – cfr Oct 16 '14 at 00:35\RequirePackage{expl3}first... – cfr Oct 16 '14 at 02:50\DeclareOption. Use the Option to toggle a switch and put the code after\ProcessOptions. You might want to look at one of the packages for handling keys if you are doing a lot of this. – cfr Oct 16 '14 at 03:13