Match colors

A match list is a list of LaTeX patterns, each with a colour. Apply it to formulas and every occurrence of every pattern takes its colour, in all of them at once. It is the editor's version of Manim's tex_to_color_map.

Why a list

A derivation says the same letters again and again. Colouring glyphs by hand means picking each one, in each formula, and doing it again when you change a line. A list moves the work to the pattern: you say once that F is red, and every F of every formula you apply the list to is.

The list belongs to the project and is saved with it. A project can hold as many lists as you like, each with its own name.

Lists of patterns

Choose Edit ▸ Match colors ▸ Create match colors… to make a list; it opens in the Match colors dialog under the name Match colors 1. The same submenu lists the lists you have, and a click on one opens it for editing.

The Match colors dialog on the list Course colours. At the left, the lists (1). In the middle, three patterns, x in blue, y in yellow and dy over dx in green, each with a colour chip and its hex (2). Under them, a preview of the formula dy over dx = 2x + 2 with the colours the list gives it (3). At the bottom, the button Apply to 3 formulas (4).
The dialog: the lists (1), the patterns with their colours (2), a preview (3) and the button that applies the list (4).

A list is a name and some entries. Each entry is a pattern and a colour:

Every edit is one undo step, and Ctrl+Z works while the dialog is open.

The preview draws one formula of the project with the colours the list would give it, before anything is applied. Choose the formula in the menu above it. It says how many glyphs of that formula take a colour, or that no pattern occurs in it.

How a pattern matches

A pattern occurs wherever the formula's LaTeX repeats the pattern's, compared token by token. A token is a command (\frac, \sin, \,), a brace, or one other character. That gives the rules you need:

For the line \frac{dy}{dx} = 2x + 2:

PatternWhat it colours
xthe x of dx and the x of 2x
ythe y of dy
2xthe 2 and the x of 2x together
\frac{dy}{dx}the whole fraction: its d, y, bar, d and x
$x$the same as x

An entry the app cannot match says why under its pattern: an empty pattern (Type some LaTeX.), a row or column break (\\ or &), braces that do not balance, a \left without its \right. Such an entry is skipped.

When patterns overlap

Two patterns can claim the same glyphs: x and \frac{dy}{dx} both claim the x of dx. The lower entry wins. With the fraction last, the whole fraction is green. Move it up, and the fraction keeps only what no later entry claims: its y and its x take their own colours, nested inside it.

The fraction moves up two places: the green fraction now holds a yellow y and a blue x. It goes back down for the loop.

When an occurrence of one pattern only partly overlaps an occurrence of a lower one, it cannot be nested. It is dropped, and the preview names the pattern: Pattern 1 (“…”) overlaps a lower one here: the lower entry wins.

Applying a list

You apply a list to formulas: the formulas you select in the Creator, or the formulas of the clips you select in the Preview or on the timeline. Pick whichever you have at hand:

Three formulas are selected in the Creator, and the list is applied from their right-click menu. The cards show the colours at once. Ctrl+Z takes them back.

Each list in these menus shows its colours after its name, so you can tell lists apart without opening them.

The right-click menu of three selected formulas in the Creator, with Apply match colors open: the lists Course colours and Only x, each with small swatches of its colours.
The menu of the selected formulas: each list with its colours.
The Preview with two clips selected: the bar in its corner has Match colors with a menu open under it that lists the lists.
The Preview's bar, with two clips selected.
The Edit together dialog with its Match colors button (1) and the menu of lists under it.
Edit together… and its Match colors button (1).

Applying a list replaces the glyph colours of the formulas: they become exactly what the list says, and a glyph no pattern reaches goes back to the formula's colour. All the formulas change in one undo step. A notice says how many glyphs took a colour, and which formulas were left alone and why.

A notice: Course colours applied to 3 formulas, with the number of glyphs coloured.
The notice after applying a list.

What a list leaves alone

A list that starts from a palette

With a palette active, Edit ▸ Match colors ▸ New from active palette… makes a list of four rows, coloured with the palette's variable, constant, operator and result roles and with empty patterns for you to fill. Nothing is coloured until you write the patterns and apply the list. Palettes shows it.

What reaches Manim

The exported scene has no list and no patterns, only the colours they gave: each glyph carries a set_color with a plain hex value. Here is the Newton example as ManimCE writes it.

This second example is the one the dialog above shows: three lines of a derivation coloured by the list Course colours, where the fraction wins over the letters inside it.

Where to go next