The linop package v0.1
Johannes Weytjens
johannes.weytjens@nietsissimpel.org June 6, 2016
Contents
1 Introduction
1
2 List of commands
2
3 List of options
2
4 Advanced control
4
1. Introduction
There exist already many packages to help you typeset common and less common mathematical notation with ease. Yet, to the best of my knowledge, there does not yet exist a package that provides an easy way to typeset operators as they appear for example in many body physics, quantum (field) theory or linear algebra. The aim of this package is to provide two simple commands and many options to easily write operators in any of the ways they commonly appear.
Besides providing easy to use macros, this package also ensures consistent spacing for subscript and superscript. To illustrate this point, compare the normal way for typesetting operators with the macros provided by this package.
\hat{a}_{in}\hat{a}_{in}^{\dagger}
ˆainˆain†\op{a}{in}\hc{a}{in}
ˆainˆain†Typesetting the
\dagger
and a subscript simultaneously pushes the subscript down, this is no longer the case with the here defined macros.1.1. Required packages
As these are simple macros, you only need the
xparse
package.1
2. List of commands
The two macros defined in this package are
\op
and\hc
as well as their starred versions.\op[
superscript spacing]{
operator}{
subscript}{
superscript}{
supersuperscript}
\hc[
superscript spacing]{
operator}{
subscript}{
superscript}{
supersuperscript}
These macros typeset an operator and the Hermitian conjugate respectively. Only the operator argument is mandatory, all other arguments can either be empty or be skipped entirely if no subscript or superscript is desired. The optional argumentsuperscript spacingonly applies to the starred versions.
Supersuperscripts are implemented to distinguish between e.g. the order in some expansion and the square of the operator.
\op{a}{in}{0}
aˆ0in\op{a}{}{(1)}{2}
aˆ(1)2\hc{b}{out}{0}
ˆb†0out\hc{b}{out}{}{2}
ˆb†out2The defaults style is to typeset all operators with a hat. The none starred versions use
\hat
and are only appropriate for single symbol operators. The starred version use\widehat
which scales with the width of the operator and can therefore be used for wider symbols. The\widehat
often overlaps with the superscripts however, so the starred version insert a\>
before the superscripts and a\:
for the Hermitian conjugate superscript. Controling the spacing of the superscript for individual operators can be done with the optionalsuperscript spacingargument.\op*{A}{in}{0}
Abin0\hc*{ab}{out}
a bcout†\hc*[\kern4pt]{\mathcal{L}}
Lc†3. List of options
3.1. bold
Some prefer to use bold letters for operators instead of hats. This can be achieved by using the
bold
option when loading the package. When using this option, the starred versions will produce the same result as the none starred versions.\op{a}{in}{0}
a0in\hc{b}{out}
b†out3.2. bmbold
The
bmbold
option achieves the same effect as bold, but instead uses the bold math font provided by thebm
package.2
\op{a}{in}{0}
a0in\hc{b}{out}
b†out3.3. nohat
The option
nohat
typesets the operators without a\hat
. This also applies to the starred versions.\op{a}{in}{0}
a0in\hc{b}{out}
b†out3.4. wide
With the wide option, all operators will use
\widehat
, regardless of whether you’re using the starred or non starred versions.3.5. star
The
star
options typesets the Hermitian conjugate with a star instead of a dagger.\hc{b}{out}
ˆb∗out3.6. compact
The consistent spacing is provided by using
\mathstrut
in both the subscript and superscript. As the misalignment is caused by using a\dagger
in the superscript, the same effect can be achieved by using a\phantom{\dagger}
in the superscript of the non Hermitian conjugated operator. This turns out to be slightly more compact than using\mathstrut
, though the effect is minimal1.\op{a}{in}\hc{a}{in}
ˆainˆain† using\mathstrut
\op{a}{in}\hc{a}{in}
ˆainˆain† using\phantom{\dagger}
Figure 1
Illustrating the difference between\mathstrutand\phantom{\dagger}. The light grey letters are the compact version that used\phantom{\dagger}.
1 This is because\mathstrutis defined as\def\mathstrut{\vphantom(}and(turns out be slightly larger than
\dagger.
3
3.7. square
To help distinguish between the operator and the indices, the subscript and superscripts can be given in square brackets as well when using the
square
option.\op{a}[in][0]
ˆa0in\hc{b}[out]
ˆb†out4. Advanced control
All the options above are set by renewing some custom commands which are
command default value description
\linopstyle \hat
style of operators\linopstylewide \widehat
style of starred operators\linopconjugate \dagger
symbol used for Hermitian conjugate\linopspacewide \>
spacing in superscript ofop*
\linopspacewidehc \:
spacing in superscript ofhc*
\linopsubscript \mathstrut
equal spacing in subscript\linopsuperscript \mathstrut
equal spacing in superscript ofop
\linopsuperscripthc \mathstrut
equal spacing in superscript ofhc
These can be changed with
\renewcommand
for even further control.4