# \comm

Used to typeset operator commutators such as [A,B] in quantum mechanics and algebra.

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

## Metadata

| Field | Value |
| --- | --- |
| Topic | [Physics: quantities](https://texform.dev/latex/topics/physics-quantities) |
| Packages | physics |
| Allowed mode | math |
| Tags |  |
| Commonality | low |
| Kind | prefix |

## Syntax

### physics

Argument specification: `s m{} m`

Used to typeset operator commutators such as [A,B] in quantum mechanics and algebra.

## Examples

```latex
\comm{A}{B}
```

[Open in Playground](https://play.texform.dev/?input=%5Ccomm%7BA%7D%7BB%7D)

```latex
\comm*{A}B
```

[Open in Playground](https://play.texform.dev/?input=%5Ccomm*%7BA%7DB)

## Renderer support

| Package | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- |
| physics | full | none | full |

## In TeXForm

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

### Expands to (physics)

```latex
\comm{#1}#2
```

→

```latex
\left[#1,#2\right]
```

If a neighboring \big, \bigg, \Big, or \Bigg follows the command, that size command is used instead of \left...\right; if starred, the result is fixed [#1,#2] and any such size modifier is consumed but ignored in the final rewrite.

### [physics/commutator-expand](https://texform.dev/rules/physics/commutator-expand)

Expand commutators to explicit square-bracket fences.

Level: faithful. Fidelity: render.

```latex
\comm{#1}{#2}
```

→

```latex
\left[#1,#2\right]
```

```latex
\comm{L_x}{L_y}=i\hbar L_z
```

→

```latex
\left[L_x,L_y\right]=i\hbar L_z
```

## Equivalent forms

```latex
\commutator{#1}#2
```

exact. 

```latex
\left[#1,#2\right]
```

exact. Matches the unstarred form when no intervening \big/\bigg/\Big/\Bigg size modifier is used.

## See also

- [\\acomm](https://texform.dev/latex/commands/acomm)
- [\\anticommutator](https://texform.dev/latex/commands/anticommutator)
- [\\commutator](https://texform.dev/latex/commands/commutator)
- [\\pb](https://texform.dev/latex/commands/pb)
- [\\poissonbracket](https://texform.dev/latex/commands/poissonbracket)

## Test cases

### physics

| Input | Case | MathJax | KaTeX | XeTeX |
| --- | --- | --- | --- | --- |
| \comm{a}{b} | Positive: baseline | Pass | Fail | Pass |
| \comm*{a}{b} | Positive: vary:s[0] | Pass | Fail | Pass |
| \comm{a}b | Positive: bare[2] | Pass | Fail | Pass |
