Testing whether a document has option "fleqn"
Herbert Voss
Herbert.Voss at fu-berlin.de
Sat May 4 06:14:56 CEST 2019
Am 04.05.19 um 00:30 schrieb Hefferon, Jim S.:
> How can I test whether the document has the class option `fleqn`? I want to have an environment that takes the place of center but that if required gives content that is left-aligned, as equations are left-aligned under fleqn.
>
> I had in mind something like this. However this one gives `! LaTeX Error: Can be used only in preamble.`
>
> \newenvironment{display}{%
> \@ifclasswith{fleqn}{
> \trivlist \item \relax \hspace*{\mathindent}
> }{
> \trivlist \centering \item \relax
> }}{
> \endtrivlist
> }
>
> I know that there are flags like \@fleqntrue and have spent some time trying toggle commands, etc, but been unable to hit on the right one. A tip would really help me.
Try
\makeatletter
\AtBeginDocument{%
\newenvironment{display}{%
\@ifclasswith{fleqn}{
\trivlist \item \relax \hspace*{\mathindent}
}{
\trivlist \centering \item \relax
}}{
\endtrivlist
}}
\makeatother
Herbert
More information about the texhax
mailing list