1

The following MWE points out that, without fleqn class option, math internal mode is detected ("i" and "o") but, as soon as fleqn class option is enabled, this mode is not detected anymore ("i" and "i").

Do you see what's going on?

\documentclass
%[fleqn]
{article}
%
\newcommand{\test}{%
  \relax%
  \ifinner%
  i%
  \else%
  o%
  \fi%
}
%
\begin{document}    
$\test$
%
\begin{equation}
  \test
\end{equation}
\end{document}
Denis Bitouzé
  • 9,652
  • 4
  • 27
  • 85

1 Answers1

1

\ifinner does not really test anything useful in math mode whether or not fleqn is used.

If you want to distinguish displaystyle then unfortunately you need to use \mathchoice.

The following produces t inline and d in display whether or not the [fleqn] option is used.

\documentclass
[fleqn]
{article}
%
\newcommand{\test}{%
\mathchoice
{\displaystyle d}%
{\textstyle t}%
{\scriptstyle s}%
{\scriptscriptstyle 2}%
}
%
\begin{document}    
$\test$
%
\begin{equation}
  \test
\end{equation}
\end{document}
David Carlisle
  • 757,742