1

Please consider the following file:

\documentclass{article}
\newcommand{\ineq}[2][$0$]{#2<#1}
\[\ineq x\]
\end{document}

If I compile it, I get an error message, as it would be expected when one uses dollar signs within a \[…\] pair. The correct definition for the \ineq command should be

\newcommand{\ineq}[2][0]{#2<#1}

However, if I compile this file:

\documentclass{article}
\usepackage{amsmath}
\newcommand{\abc}[3][$0$]{\begin{cases}
        #2& \text{ if } x \neq #1\\
        #3&\text{ if } x= #1
                             \end{cases}}
\begin{document}
\[\abc ab\]
\end{document}

then I get no error message and everything works as if I had typed [0] instead of [$0$]. Why is it so?

1 Answer 1

3

Inside an alignment you are not in $$ ... $$ but $\displaystyle...$ so single dollars just stop and start the math.

$\displaystyle...  $0$ ... $

is not as intended but not an error. It is easier to see with letters

enter image description here


\documentclass{article}
\usepackage{amsmath}
\newcommand{\abc}[3][abc$xyz0$]{\begin{cases}
        #2& \text{ if } x \neq #1\\
        #3&\text{ if } x= #1
                             \end{cases}}
\begin{document}
\[\abc ab\]
\end{document}

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.