> ## Documentation Index
> Fetch the complete documentation index at: https://resources.latex-cloud-studio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Music Notation

> Master music notation in LaTeX. Learn musical symbols, notes, chord notation, and how to create professional music scores and examples.

Learn how to typeset musical notation, symbols, and scores professionally in LaTeX.

## Rendered Previews (prototype)

Below each relevant code block, we show a “Rendered output” image that illustrates the expected result. These SVGs are placeholders for now; after your approval we can hook in a build step to generate them automatically from the LaTeX examples.

## Essential Music Packages

<CodeGroup>
  ```latex packages theme={null}
  \usepackage{musixtex}       % Complete music typesetting
  \usepackage{harmony}        % Chord symbols
  \usepackage{guitar}         % Guitar chord diagrams
  \usepackage{abc}            % ABC notation support
  \usepackage{lilyglyphs}     % LilyPond symbols
  \usepackage{leadsheets}     % Lead sheets and songs
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Packages are loaded in the preamble and produce no visible output. They enable music notation commands throughout your document.
</Card>

## Musical Symbols

| Symbol | LaTeX              | Description         |
| :----: | :----------------- | :------------------ |
|  **♩** | `\quarternote`     | Quarter note        |
|  **♪** | `\eighthnote`      | Eighth note         |
|  **♫** | `\twonotes`        | Beamed eighth notes |
|  **♭** | `\flat`            | Flat                |
|  **♯** | `\sharp`           | Sharp               |
|  **♮** | `\natural`         | Natural             |
| **𝄞** | `\trebleclef`      | Treble clef         |
| **𝄢** | `\bassclef`        | Bass clef           |
| **𝄐** | `\textmusicalnote` | Generic note        |

## Basic Music Notation

### Note Values and Rests

<CodeGroup>
  ```latex notes theme={null}
  % Note values
  \whole          % Whole note
  \half           % Half note
  \quarter        % Quarter note
  \eighth         % Eighth note
  \sixteenth      % Sixteenth note

  % Rests
  \wholerest      % Whole rest
  \halfrest       % Half rest
  \quarterrest    % Quarter rest
  \eighthrest     % Eighth rest

  % Dotted notes
  \quarter.       % Dotted quarter
  \half..         % Double dotted half
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays musical note values: whole note (𝅝), half note (𝅗𝅥), quarter note (♩), eighth note (♪), sixteenth note (𝅘𝅥𝅯). Corresponding rests appear as horizontal bars or symbols. Dotted notes show a small dot after the note head extending the duration by half.
</Card>

### Accidentals and Key Signatures

<CodeGroup>
  ```latex accidentals theme={null}
  % Accidentals
  C\sharp         % C sharp
  B\flat          % B flat
  F\natural       % F natural
  G\doublesharp   % G double sharp
  D\doubleflat    % D double flat

  % Key signatures
  \keysignature{3\sharp}    % A major / F# minor
  \keysignature{2\flat}     % Bb major / G minor
  \keysignature{0}          % C major / A minor
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Shows accidental symbols: C♯ (sharp raises pitch), B♭ (flat lowers pitch), F♮ (natural cancels previous accidental), G𝄪 (double sharp), D𝄫 (double flat). Key signatures display appropriate sharps or flats at the beginning of the staff.
</Card>

## Chord Notation

### Chord Symbols with harmony

<CodeGroup>
  ```latex chords theme={null}
  % Basic chords
  \Cma            % C major
  \Cmi            % C minor
  \Cdim           % C diminished
  \Caug           % C augmented

  % Seventh chords
  \CmaSe          % C major 7
  \CmiSe          % C minor 7
  \Cdom           % C7 (dominant)
  \CmiSeFlat      % C minor 7 flat 5

  % Extended chords
  \Cnine          % C9
  \Celeven        % C11
  \Cthirteen      % C13

  % Slash chords
  C/G             % C major over G
  Am/F            % A minor over F
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays professionally formatted chord symbols: Cmaj, Cmin, Cdim, Caug for basic triads. Seventh chords appear as Cmaj7, Cmin7, C7, Cm7♭5. Extended chords show C9, C11, C13. Slash chords display as C/G and Am/F with the bass note after the slash.
</Card>

## Guitar Chord Diagrams

### Using the guitar Package

<CodeGroup>
  ```latex guitar-chords theme={null}
  % Basic chord diagram
  \gtab{C}{3:002010}
  \gtab{G}{3:002220}
  \gtab{Am}{X02210}
  \gtab{F}{1:X33211}

  % With finger positions
  \gtab*{D}{XX0232:000132}
  \gtab*{Em}{022000:012000}

  % Barre chords
  \gtab{Bm}{2:X13321}
  \gtab{F\sharp m}{2:133111}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Renders guitar chord diagrams as fretboard grids showing finger positions. Each diagram displays 6 vertical strings and horizontal frets with dots indicating where to press. X marks strings not played, O marks open strings. Barre chords show a bar across multiple strings.
</Card>

## Simple Scores with MusiXTeX

### Basic Staff Notation

<CodeGroup>
  ```latex simple-score theme={null}
  \begin{music}
  \instrumentnumber{1}
  \setstaffs1{1}
  \generalmeter{\meterfrac44}
  \startpiece

  % Simple melody
  \notes\qu c\en    % Quarter note C
  \notes\hu d\en    % Half note D
  \notes\qu{ef}\en  % Quarter notes E and F
  \notes\wh g\en    % Whole note G

  \endpiece
  \end{music}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays a musical staff with treble clef (𝄞) and 4/4 time signature. Notes appear on the five-line staff: C (quarter), D (half), E-F (quarters), G (whole). Note heads are positioned at correct pitch heights with appropriate stems.
</Card>

### Two-Staff System

<CodeGroup>
  ```latex piano-score theme={null}
  \begin{music}
  \instrumentnumber{1}
  \setstaffs1{2}              % Two staves
  \setclef1{\treble\bass}     % Treble and bass clefs
  \generalmeter{\meterfrac44}
  \startpiece

  % Right hand
  \notes\qu{ceg}\en           % C major chord
  \notes\qu{ceg}\en
  % Left hand
  \Notes\ql{C}\en
  \Notes\ql{G}\en

  \endpiece
  \end{music}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Shows a grand staff (piano system) with treble clef (𝄞) on top and bass clef (𝄢) on bottom, connected by a brace. The right hand plays C major chord (C-E-G) on the upper staff while the left hand plays bass notes C and G on the lower staff.
</Card>

## Lead Sheets with leadsheets

### Song Structure

<CodeGroup>
  ```latex lead-sheet theme={null}
  \begin{song}{title={My Song}, 
               composer={John Doe}, 
               key={C major}}

  \begin{verse}
  \chord{C}This is the \chord{Am}first line
  \chord{F}Of my \chord{G}song \chord{C}today
  \end{verse}

  \begin{chorus}
  \chord{F}Sing a\chord{C}long
  \chord{G}Everyone \chord{C}sing
  \end{chorus}

  \end{song}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Produces a formatted lead sheet with title "My Song" and composer credit. Verse and chorus sections are labeled. Chord symbols (C, Am, F, G) appear above the lyrics at the appropriate syllables, creating a professional songbook layout.
</Card>

## Rhythm Notation

### Time Signatures and Tempo

<CodeGroup>
  ```latex rhythm theme={null}
  % Time signatures
  \timesignature{4}{4}        % 4/4 time
  \timesignature{3}{4}        % 3/4 time
  \timesignature{6}{8}        % 6/8 time
  \timesignature{5}{4}        % 5/4 time

  % Tempo markings
  \tempo{Allegro}
  \tempo{Andante \quarternote = 72}
  \tempo{Presto \halfnote = 140}

  % Metronome markings
  MM \quarternote = 120
  MM \halfnote. = 60
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays time signatures as stacked numbers (4/4, 3/4, 6/8, 5/4). Tempo markings show Italian terms like "Allegro" or "Andante" with metronome values. Metronome markings appear as "♩ = 120" indicating beats per minute.
</Card>

## Musical Expressions

### Dynamics and Articulation

<CodeGroup>
  ```latex dynamics theme={null}
  % Dynamics
  \pp     % Pianissimo
  \p      % Piano
  \mp     % Mezzo-piano
  \mf     % Mezzo-forte
  \f      % Forte
  \ff     % Fortissimo

  % Crescendo and diminuendo
  \cresc  % Crescendo
  \dim    % Diminuendo
  \<      % Hairpin crescendo
  \>      % Hairpin diminuendo

  % Articulation
  \staccato       % Staccato dot
  \accent         % Accent mark
  \tenuto         % Tenuto line
  \fermata        % Fermata
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Shows dynamic markings in italic: pp (very soft), p (soft), mp (medium soft), mf (medium loud), f (loud), ff (very loud). Crescendo and diminuendo appear as hairpin wedges (\< and >). Articulation marks include staccato dots, accent marks (>), tenuto lines, and fermata symbols (𝄐).
</Card>

## ABC Notation Integration

### Using ABC Notation

<CodeGroup>
  ```latex abc-notation theme={null}
  % ABC notation example
  \begin{abc}[name=melody]
  X:1
  T:Simple Melody
  M:4/4
  L:1/4
  K:C
  C D E F | G2 G2 | F E D C | C4 ||
  \end{abc}

  % Inline ABC
  \abcinline{C D E F G}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Converts ABC notation into standard music notation. The melody "Simple Melody" appears on a staff in C major, 4/4 time. Notes C-D-E-F followed by two half-note Gs, then F-E-D-C, ending with a whole-note C. Bar lines separate measures.
</Card>

## Musical Analysis

### Roman Numeral Analysis

<CodeGroup>
  ```latex analysis theme={null}
  % Roman numerals for harmony
  \newcommand{\romnum}[1]{\textsc{#1}}

  In C major: \romnum{I} - \romnum{IV} - \romnum{V} - \romnum{I}

  % With inversions
  \romnum{I}\textsuperscript{6} - \romnum{IV}\textsuperscript{6/4} - \romnum{V}\textsuperscript{7}

  % Minor keys (lowercase)
  In A minor: \romnum{i} - \romnum{iv} - \romnum{V} - \romnum{i}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays Roman numeral chord analysis in small caps. Major key progression: I - IV - V - I. Inversions shown with figured bass: I6, IV6/4, V7. Minor key uses lowercase: i - iv - V - i. These symbols appear below the staff in harmonic analysis.
</Card>

### Form Analysis

<CodeGroup>
  ```latex form-analysis theme={null}
  % Sections
  \textbf{A:} mm. 1-8
  \textbf{B:} mm. 9-16
  \textbf{A':} mm. 17-24

  % Phrases
  \begin{tikzpicture}
  \draw[thick] (0,0) -- (4,0);
  \draw[thick] (0,0) -- (0,0.2);
  \draw[thick] (4,0) -- (4,0.2);
  \node at (2,-0.3) {4 measures};
  \end{tikzpicture}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Shows musical form sections labeled A (mm. 1-8), B (mm. 9-16), A' (mm. 17-24) in bold text. Phrase diagrams display horizontal lines with vertical endpoints marking phrase boundaries, with "4 measures" labeled beneath each phrase bracket.
</Card>

## Lyrics and Text

### Aligning Lyrics to Music

<CodeGroup>
  ```latex lyrics theme={null}
  \begin{music}
  \instrumentnumber{1}
  \setstaffs1{1}
  \setlyrics1{1}
  \startpiece

  \notes\qu{c}\en
  \lyrics{This }
  \notes\qu{d}\en
  \lyrics{is }
  \notes\qu{e}\en
  \lyrics{my }
  \notes\hu{f}\en
  \lyrics{song }

  \endpiece
  \end{music}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays a melodic line with lyrics aligned below each note. The words "This is my song" appear with each syllable centered under its corresponding note (C, D, E, F). The half note on "song" shows extended duration.
</Card>

## Musical Tables

### Interval Reference Table

<CodeGroup>
  ```latex interval-table theme={null}
  \begin{table}[h]
  \centering
  \begin{tabular}{|l|c|c|}
  \hline
  \textbf{Interval} & \textbf{Semitones} & \textbf{Example} \\
  \hline
  Unison & 0 & C-C \\
  Minor 2nd & 1 & C-D♭ \\
  Major 2nd & 2 & C-D \\
  Minor 3rd & 3 & C-E♭ \\
  Major 3rd & 4 & C-E \\
  Perfect 4th & 5 & C-F \\
  Tritone & 6 & C-F♯ \\
  Perfect 5th & 7 & C-G \\
  \hline
  \end{tabular}
  \caption{Common musical intervals}
  \end{table}
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Produces a formatted table with columns for Interval, Semitones, and Example. Lists musical intervals from Unison (0 semitones, C-C) through Perfect 5th (7 semitones, C-G), including Minor/Major 2nds, 3rds, Perfect 4th, and Tritone. Includes a caption "Common musical intervals."
</Card>

## Special Music Characters

### Unicode Music Symbols

<CodeGroup>
  ```latex unicode-music theme={null}
  % Requires fontspec and XeLaTeX/LuaLaTeX
  \usepackage{fontspec}

  % Musical symbols
  🎵 🎶 🎼 🎹 🎸 🎺 🎻 🥁

  % Note values
  𝅝 𝅗𝅥 𝅘𝅥 𝅘𝅥𝅮 𝅘𝅥𝅯 𝅘𝅥𝅰 𝅘𝅥𝅱 𝅘𝅥𝅲

  % Clefs
  𝄞 𝄢 𝄡 𝄟 𝄠
  ```
</CodeGroup>

**Rendered output:**

<Card title="Rendered Output" icon="eye">
  Displays Unicode music symbols including emoji instruments: 🎵 🎶 🎼 🎹 🎸 🎺 🎻 🥁. Musical notation symbols show note values from whole to 128th notes. Clef symbols display: 𝄞 (treble), 𝄢 (bass), 𝄡 (alto), and percussion clefs.
</Card>

## Best Practices

<CardGroup cols={2}>
  <Card title="Choose the Right Package" icon="check" color="#FF6037">
    Select packages based on your needs - MusiXTeX for full scores, harmony for chord symbols
  </Card>

  <Card title="Consistent Notation" icon="book" color="#FF6037">
    Use standard music notation conventions throughout
  </Card>

  <Card title="Clear Layout" icon="eye" color="#FF6037">
    Ensure adequate spacing between staves and systems
  </Card>

  <Card title="Compile Multiple Times" icon="arrows-rotate" color="#FF6037">
    Music packages often require multiple compilation passes
  </Card>
</CardGroup>

## Troubleshooting

<Warning>
  **Common issues**:

  * MusiXTeX requires special compilation: Run `musixtex` command
  * Font conflicts: Some music fonts require specific setup
  * Spacing issues: Manual adjustment often needed for complex scores
</Warning>

## Further Reading

<CardGroup cols={2}>
  <Card title="Linguistics Notation" icon="language" href="/learn/latex/specialized-notation/linguistics" color="#FF6037">
    Phonetic symbols and syntax trees
  </Card>

  <Card title="Symbol Reference" icon="book" href="/learn/reference/symbols" color="#FF6037">
    General symbol reference
  </Card>

  <Card title="Creating Diagrams" icon="diagram-project" href="/learn/latex/how-to/tikz-diagrams" color="#FF6037">
    Creating diagrams with TikZ
  </Card>

  <Card title="Advanced Text Formatting" icon="palette" href="/learn/latex/text-formatting" color="#FF6037">
    Text styling, emphasis, and structure
  </Card>
</CardGroup>
