> For the complete documentation index, see [llms.txt](https://overleaf-pro.ayaka.space/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://overleaf-pro.ayaka.space/latex/field-specific/10-attribute-value-matrices.md).

# Attribute Value Matrices

This article demonstrates typesetting attribute value matrices (AVMs), which are a practical way to present [feature structures](https://en.wikipedia.org/wiki/Feature_structure) as a group of attributes and their corresponding values.

## Advisory notes on AVM packages for LaTeX

This article uses the `avm` package, which was the preferred opinion for typesetting AVMs at the time this material was initially written. Unfortunately, the `avm` package is not distributed by TeX Live, meaning Overleaf users will have to upload a copy (`avm.sty`) into their projects. To address this, the [Overleaf Gallery project](https://www.overleaf.com/latex/templates/examples-of-attribute-value-matrices/fnrbcjztvjjv) that accompanies this article includes a copy of the `avm` package.

An alternative to `avm`, the [`langsci-avm` package](https://ctan.org/pkg/langsci-avm?lang=en), is now available in TeX Live, making it directly accessible via Overleaf. However, due to syntax and feature differences, the `avm`-based examples in this article will not compile with `langsci-avm` and require some editing. See section 4.6 of the [`langsci-avm` documentation](http://mirrors.ctan.org/macros/latex/contrib/langsci-avm/langsci-avm.pdf) for guidance on migrating from `avm` to `langsci-avm`.

## Getting started

Use the `avm` environment to create an attribute value matrix, as demonstrated in the following example:

```latex
\documentclass{article}
\usepackage{avm}

\begin{document}

\begin{avm}
    \[ cat\|subcat & \<NP$_{it}$, NP$_{\@2}$, S[comp]:\@3\> \\
       content & \[ relation & \bf bother\\
                    bothered & \@2 \\
                    soa-arg  & \@3 \] \]
\end{avm}

\end{document}
```

This example produce the following output:

![An attribute value matrix typeset on Overleaf using LaTeX](/files/XyPOtiiG9jKCeGqbCOF9)

\* To explore AVMs, open this [Overleaf project.](https://www.overleaf.com/project/new/template/26428?id=113292459\&templateName=Example+project+demonstrating+attribute+value+matrices\&latexEngine=pdflatex\&texImage=texlive-full%3A2022.1\&mainFile=)

## Basic usage

To typeset an attribute value matrix inside an `avm` environment there are a number of commands you need to know:

* `\avmfont{\sc}`: changes the font used in the matrices, in this case to small caps. Any other [font family](/latex/fonts/01-font-sizes-families-and-styles.md) will work. The font size and [font typeface](/latex/fonts/02-font-typefaces.md) can also be declared here.
* `\begin{avm}` and `\end{avm}`: these open and close the environment where the attribute value matrix will be created.
* `\[` and `\]`: print the squared brackets that delimit parts of the matrix. Other brackets can also be used with the commands `\<`, `\>`, `\{` and `\}`.
* `\\`: inserts a new line.
* `&`: creates a column division within the same line.

The following example demonstrates these:

```latex
\documentclass{article}

\usepackage{avm}
\avmfont{\sc}

\begin{document}
\begin{avm}
    \[ subj & \[ pers & 3 \\
                 num & sg \\
                 gend & masc\\
                 pred & \rm ‘pro’ \]\\

        pred & \rm ‘eat\q<SUBJ, OBJ\q>’\\

                 obj & \[ pers & 3 \\
                 num & pl \\
                 gend & fem \\
                 pred & \rm ‘pro’ \]
        \]
\end{avm}

\end{document}
```

This example produces the following output:

![An attribute value matrix typeset on Overleaf using LaTeX](/files/MnoZwVs16OpYocM5xvce)

\* To explore AVMs, open this [Overleaf project.](https://www.overleaf.com/project/new/template/26428?id=113292459\&templateName=Example+project+demonstrating+attribute+value+matrices\&latexEngine=pdflatex\&texImage=texlive-full%3A2022.1\&mainFile=)

## Unaligned columns

Sometimes, when a row is too long, it may be convenient to use unaligned columns to improve output:

```latex
\begin{avm}
    \[ \avmspan{system\|local\|content\; \@2} \\
        qstore & \[det & \textnormal{forall} \\
                   restpar & \@2 \[para & \@1 \\
                                   restr & \[reln & \textnormal{book} \\
                                             inst & \@1 \] \] \] \]
\end{avm}
```

This example produces the following output:

![An attribute value matrix typeset on Overleaf using LaTeX](/files/x6qoFQTyLcP39Zm0RSlG)

The command `\avmspan{}` prevents column alignment for its argument, whilst the command `\;` inserts a horizontal blank space slightly longer than normal, creating a nice separator.

\* To explore AVMs, open this [Overleaf project.](https://www.overleaf.com/project/new/template/26428?id=113292459\&templateName=Example+project+demonstrating+attribute+value+matrices\&latexEngine=pdflatex\&texImage=texlive-full%3A2022.1\&mainFile=)

## Sort labels

It is possible to add sort labels at the corners of a AVM. There are two possible styles. The first one is printing the labels inside the matrix:

```latex
\avmsortfont{\it}
\avmvalfont{\it}
\begin{avm}
    \[ \asort{indexed-obj}
       index & \[\asort{index}
                  variable & \@1 \[\asort{variable}
                                    per & 3rd \\
                                    num & sing \\
                                    gend & neut \] \\
                  restriction & \[\asort{psoa}
                                  relation & book \\
                                  instance & \@1 \] \] \]
\end{avm}
```

This code produces the following output:

![An attribute value matrix typeset on Overleaf using LaTeX](/files/ulKYDSAcfVqRWzm5SVGR)

\* To explore AVMs, open this [Overleaf project.](https://www.overleaf.com/project/new/template/26428?id=113292459\&templateName=Example+project+demonstrating+attribute+value+matrices\&latexEngine=pdflatex\&texImage=texlive-full%3A2022.1\&mainFile=)

There are three new commands in this example:

* `\avmsortfont{\it}`: sets the font type for the sort keys, italics in this case but other [font styles and sizes can be used](/latex/fonts/01-font-sizes-families-and-styles.md)
* `\avmvalfont{\it}`: sets the font type for the values in the AVM, italics in this case.
* `\asort{*key*}`: prints the sort `*key*`.

It's also possible to overlap the sort label onto the previous column, as shown in the next example:

```latex
\avmvalfont{\it}
\avmsortfont{\it}
\begin{avm}
    \sort{indexed-obj}{\[ index & \osort{index}{\[
          variable & \@1 \osort{variable}{\[  per & 3rd \\
                                              num & sing \\
                                              gend & neut \]} \\
          restriction & \osort{psoa}{\[relation & book \\
                                       instance & \@1 \]} \]} \]}
\end{avm}
```

This example produces the following output:

![An attribute value matrix typeset on Overleaf using LaTeX](/files/LWqJj2dpJdIVDvXQlfhS)

\* To explore AVMs, open this [Overleaf project.](https://www.overleaf.com/project/new/template/26428?id=113292459\&templateName=Example+project+demonstrating+attribute+value+matrices\&latexEngine=pdflatex\&texImage=texlive-full%3A2022.1\&mainFile=)

There are two new commands:

* `\sort{*label*}`: prints the `*label*`, taking up space in the column where it appears.
* `\osort{*label*}`: overlaps the *label* without checking collisions or available space.

## Reference guide

Available brackets in the **avm** package.

| Command | Output                                          |
| ------- | ----------------------------------------------- |
| `\{ \}` | ![AVMbraces.png](/files/kYyeC371FLBhHpqKmyPt)   |
| `\[ \]` | ![AVMbrackets.png](/files/J6f7YK4luKG79G7zjN61) |
| `\< \>` | ![AVMchevrons.png](/files/vSd9UCix3xSq8zWVTou7) |

## Further reading

For more information see

* [The **avm** package documentation](http://nlp.stanford.edu/manning/tex/avm-doc.pdf)
* [The **avm.sty** source code](http://nlp.stanford.edu/manning/tex/avm.sty)
* [Font sizes, families, and styles](/latex/fonts/01-font-sizes-families-and-styles.md)
* [Font typefaces](/latex/fonts/02-font-typefaces.md)
* [Tables](/latex/figures-and-tables/01-tables.md)
* [Brackets and Parentheses](/latex/mathematics/03-brackets-and-parentheses.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://overleaf-pro.ayaka.space/latex/field-specific/10-attribute-value-matrices.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
