4

The built-in command \det simply prints 'det' in roman style. However, a superscript in display math (e.g. \[\det^N\]) appears directly above and centered, rather than at the top-right corner. I've never seen this behavior for any other type of superscript.

Why does \det have this special behavior, and how can I turn it off?

Minimum working example:

\documentclass{article}
\begin{document}
\[\det^2\]
\end{document}
5
  • 1
    Try \det\nolimits^2 Commented Nov 24, 2017 at 18:08
  • Or code \det{}^2.
    – Bernard
    Commented Nov 24, 2017 at 18:10
  • I'm not sure why Knuth defined \det to take limits like \lim or \sum in display math; LaTeX followed suit. On the other hand, I've never seen \det^{N}: what should it mean?
    – egreg
    Commented Nov 24, 2017 at 18:33
  • @egreg Like $\sin^n(x)$, I wanted to use it as a shorthand for $\det(\text{very long expression})^N$. Otherwise, it's easy for the $N$ to get lost.
    – knzhou
    Commented Nov 24, 2017 at 18:34
  • I don't think your readers will understand. Anyway, use \det\nolimits^{N}.
    – egreg
    Commented Nov 24, 2017 at 18:36

1 Answer 1

5

From latex.ltx:

\def\log{\mathop{\operator@font log}\nolimits}
\def\lim{\mathop{\operator@font lim}}
\def\det{\mathop{\operator@font det}}

\det is defined in the same manner as \lim, but you want the behavior of \log. This can be achieved by appending \nolimits to the definition of \det, for example:

\documentclass{article}
\usepackage{etoolbox}
\begin{document}
\[ \log_0^1 \textstyle \log_0^1 \]
\[ \lim_0^1 \textstyle \lim_0^1 \]
\[ \det_0^1 \textstyle \det_0^1 \]

\apptocmd{\det}{\nolimits}{}{\errmessage{Could not patch \string\det.}}

\[ \det_0^1 \textstyle \det_0^1 \]
\end{document}

Result

Package amsmath

Package amsmath follows defines the commands in the following way:

\def\det{\qopname\relax m{det}}
\def\lim{\qopname\relax m{lim}}
\def\log{\qopname\relax o{log}}

Thus, \det can be redfined:

documentclass{article}
\usepackage{amsmath}
\begin{document}
\[ \log_0^1 \textstyle \log_0^1 \]
\[ \lim_0^1 \textstyle \lim_0^1 \]
\[ \det_0^1 \textstyle \det_0^1 \]

\renewcommand*{\det}{\qopname\relax o{det}}

\[ \det_0^1 \textstyle \det_0^1 \]
\end{document}

Result amsmath

The official way is using \DeclareMathOperator. It is limited to the preamble:

\usepackage{amsmath}
\let\det\relax % "Undefine" \det
\DeclareMathOperator{\det}{det}
1
  • +1 for mentioning the "official way" of changing the definition of \det. :-)
    – Mico
    Commented Nov 25, 2017 at 6:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .