# How to Make a newcommand to Give Different Outputs for Displayed Math or Inline Math?

Does any one know how to make a single simple command that gives different outputs for displayed and inline maths

\documentclass{article}

\usepackage{amsmath}

\begin{document}

$A^\prime$

\begin{align*}
\overline{A}
\end{align*}

\end{document}

• \newcommand*\simpleA{\mathchoice{\bar{A}}{A'}{(A)}{!A!}} and then $\simpleA \frac{\simpleA}{\simpleA}^{\simpleA_{\simpleA}}$. – Manuel Jan 29 '18 at 11:35
• I suggest (as @Manuel indicated) that you learn about \mathchoice. This post and its answers is a good place to start. – Sandy G Jan 29 '18 at 17:32
• Well this is great, but what I need is something that could detect the displayed environment to change the output. That is, even in a fraction's numerator/denominator, characters should not be treated as inline math unless they are not in a displayed environment. – ένας Jan 30 '18 at 7:57