# When amsart is used as a base class of another class, the “fleqn” option is ignored

I tried creating my own class based on amsart, like this one:

% file: myamsart.cls
\ProvidesClass{myamsart}


However, the option fleqn has no effect:

% file: test.tex
%\documentclass[fleqn]{amsart}
\documentclass{myamsart}

\begin{document}
$x = x$
$$y = y$$
\end{document}


Why does it work like this?

More generally, what is the difference between passing options with \documentclass and passing them with \LoadClass? Is there a general method to load a base class from cls file with the same effect as when using \docementclass?

• Note that the fleqn option in amsart is implemented rather strangely. The declared option does nothing. – daleif Nov 15 '18 at 10:46
• What do you mean by "does nothing"? It works with \documentclass[fleqn]{amsart}. – Alexey Nov 15 '18 at 10:49
• Look in amsart.cls and you'll find \DeclareOption{fleqn}{}, but it does something "strange" with it later on in a non standard manner. – daleif Nov 15 '18 at 11:17
• @daleif, "but it does something "strange" with it later on in a non standard manner" -- i think, i have to agree. – Alexey Nov 15 '18 at 13:43
• kindly observe that amsart.cls was first written before 1995, and has been used in a production capacity since then. it wasn't designed to have options passed to it except through the option to the main \documentclass line, since nobody expected it to be used that way (really, that wasn't how things like this were thought of in 1995). there are numerous classes that \LoadClass{amsart}; all of them that i know of expect the fleqn option to be specified on the \documentclass line. it's too late to change that. – barbara beeton Nov 16 '18 at 1:22

The fleqn option to amsart actually does nothing at \ProcessOptions time, because of

\DeclareOption{fleqn}{}%


The class uses a nonstandard way to set and use options. You can hack it by adding the option yourself.

\ProvidesClass{myamsart}


The first \g@addto@macro forcibly adds fleqn to the list of options myamsart.cls is loaded with, so as to make the tests \@ifclasswith{\@classname} follow the “true” branch. The second \g@addto@macro forcibly adds fleqn to the global options, so also amsmath (and all other packages) will see and honor it.

• Could you explain a bit, please, how this hack works, or at least give links or references to documentation? – Alexey Dec 15 '18 at 20:35
• @Alexey Added some explanations – egreg Dec 15 '18 at 22:44
• @Alexey Yes, sorry for the typo – egreg Dec 16 '18 at 1:05
• Thanks. To make your answer complete, could you add some link to an explanation of the difference between options of a class and global options? For example, this one, but maybe you know better. – Alexey Dec 16 '18 at 9:05

try:

\ProvidesClass{myamsart}
\PassOptionsToPackage{fleqn}{amsmath}

• Indeed, this has some effect, but not the same as when just using \documentclass[fleqn]{amsart}. – Alexey Nov 15 '18 at 11:00
• Why passing options with \documentclass is not equivalent to passing them with \LoadClass? – Alexey Nov 15 '18 at 11:03
• @Alexey documentcass options are global and seen by all packages, but if you use options to LoadClass the options are just passed to the class, so you are relying on the class to pass on the option to any packages rather than using the global option mechanism. – David Carlisle Nov 15 '18 at 11:32
• you can use \LoadClassWithOptions{amsart} and then \documentclass[fleqn]{myamsart} – user2478 Nov 15 '18 at 11:48
• @Herbert, it is more crazy than this. After glancing at amsclass source documentation and a bit of experimenting, i observed that simply using \documentclass[fleqn]{myamsart} in my example makes the option have its effect. No need to change my myamsart.cls, no need to pass any options to amsart or to use \LoadClassWithOptions. This is not what i wanted and not how a class interface should work IMHO. – Alexey Nov 15 '18 at 13:48

After being prompted by daleif, I glanced into amscls source documentation, and noticed that the actual behaviour of fleqn option is implemented starting with

\@ifclasswith{\@classname}{fleqn}{%


Having already experimented with different combinations of commands and options proposed by Herbert, I decided to be bold and to simplify my myamsart.cls to

\ProvidesClass{myamsart}

\documentclass[fleqn]{myamsart}

This produced flushed left equations exactly as when using \documentclass[fleqn]{amsart}. (However, this is not what I wanted to do, because I did not want to pass any options to myamsart.)