Testing whether a document has option "fleqn"

David Carlisle d.p.carlisle at gmail.com
Sat May 4 13:55:32 CEST 2019


if you can assume amsmath is loaded you can use \if at fleqn rather than
\@ifclasswith{fleqn}{%
or you could use \ifx\mathindent\@undefined...

On Sat, 4 May 2019 at 12:51, Hefferon, Jim S. <jhefferon at smcvt.edu> wrote:
>
> Thank you, Herbert.  I should have thought of that.  However ..
>
> \AtBeginDocument{\newenvironment{display}{%
>   \@ifclasswith{fleqn}{%
>     \trivlist \item \relax \hspace*{\mathindent}
>     }{%
>     \trivlist \centering \item \relax
>     }
> }{%
>   \endtrivlist %
> }}
>
> still gives me
>
> ! LaTeX Error: Can be used only in preamble.
>
> See the LaTeX manual or LaTeX Companion for explanation.
> Type  H <return>  for immediate help.
>  ...
>
> l.1582 \begin{display}
>
> Jim
>
> ----------
> ... those dreadful hammers!
>   --John Ruskin, 1851
>
> ________________________________________
> From: Herbert Voss <Herbert.Voss at fu-berlin.de>
> Sent: Saturday, May 4, 2019 0:14
> To: texhax at tug.org
> Subject: Re: Testing whether a document has option "fleqn"
>
> 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