# \operatorname

Used to create named math operators such as \operatorname{sgn} or limit-style operators via \operatorname*{lim} when no predefined operator macro exists.

https://texform.dev/latex/commands/operatorname

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Functions and operators](https://texform.dev/latex/topics/functions) |
| Packages | ams |
| Allowed mode | math |
| Tags |  |
| Commonality | medium |
| Kind | prefix |

## Syntax

### ams

Argument specification: `s m:O`

Used to create named math operators such as \operatorname{sgn} or limit-style operators via \operatorname*{lim} when no predefined operator macro exists.

## Common tasks

### How to write a multi-letter operator

```latex
\operatorname{rank} A
```

[Open in Playground](https://play.texform.dev/?input=%5Coperatorname%7Brank%7D+A)

### How to write an operator with limits

The star form places limits like \lim; the plain form keeps side scripts.

```latex
\operatorname*{arg\,max}_x f(x)
```

[Open in Playground](https://play.texform.dev/?input=%5Coperatorname*%7Barg%5C%2Cmax%7D_x+f%28x%29)

### How to write a named map

```latex
\operatorname{Tr}(\rho\sigma)
```

[Open in Playground](https://play.texform.dev/?input=%5Coperatorname%7BTr%7D%28%5Crho%5Csigma%29)

## Examples

```latex
\operatorname a
```

[Open in Playground](https://play.texform.dev/?input=%5Coperatorname+a)

```latex
\operatorname*{lim}_{n}
```

[Open in Playground](https://play.texform.dev/?input=%5Coperatorname*%7Blim%7D_%7Bn%7D)

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| ams | full | full | full |

## Usage frequency

3.58% of formulas in the measured corpus contain this entry, rank 17 of 263 entries with frequency data.

## In TeXForm

TeXForm parses this entry as prefix syntax; the package determines its argument specification.

### [ams/operatorname-to-named-function](https://texform.dev/rules/ams/operatorname-to-named-function)

Rewrite plain operatorname arguments to equivalent base named-function or named-operator commands.

Level: authoring. Fidelity: render.

```latex
\operatorname{#1}
```

→

```latex
\#1
```

```latex
\operatorname{arccos} x
```

→

```latex
\arccos x
```

## Equivalent forms

```latex
\DeclareMathOperator{\myop}{name}
```

approximate. Defines a new command that behaves like \operatorname{name}

```latex
\mathop{\mathrm{#2}}
```

approximate. Operator spacing and font style are applied, similar to wrapping in \mathop and \mathrm, but \operatorname correctly handles limits positioning according to the star argument.

## Test cases

### ams

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \operatorname{a} | Positive: baseline | Pass | Pass | Pass |
| \operatorname*{a} | Positive: vary:s[0] | Pass | Pass | Pass |
| \operatorname a | Positive: bare[1] | Pass | Pass | Pass |
