Skip to content

Commit 2bc9ec9

Browse files
committed
Fix Quarto cross-references and equation labels
- Fix @eq- to @sec- prefix for section cross-references - Convert alignat to aligned environments for proper equation labeling - Replace invalid characters (= and .) in figure labels - Add blank lines before headings after math blocks - Update CLAUDE.md for Quarto build system - Clean up markdown formatting
1 parent 54da851 commit 2bc9ec9

41 files changed

Lines changed: 1867 additions & 3435 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.markdownlint-cli2.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# markdownlint-cli2 configuration
2+
# Include both .md and .qmd files for Quarto support
3+
globs:
4+
- "**/*.md"
5+
- "**/*.qmd"

.markdownlint.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,49 @@ MD041: false
1616
# MD046 - Code block style (allow both fenced and indented)
1717
MD046: false
1818

19+
# Rules disabled for LaTeX/math-heavy QMD files
20+
# MD010 - Hard tabs (often in raw LaTeX)
21+
MD010: false
22+
23+
# MD037 - Spaces inside emphasis (false positives from *u* in math)
24+
MD037: false
25+
26+
# MD040 - Fenced code language ({=latex} not recognized)
27+
MD040: false
28+
29+
# MD049 - Emphasis style (underscores common in math)
30+
MD049: false
31+
32+
# MD050 - Strong style (similar issue)
33+
MD050: false
34+
35+
# MD011 - Reversed link syntax (false positives from math like [D^{2x}])
36+
MD011: false
37+
38+
# MD032 - Blanks around lists (false positives from + in equations)
39+
MD032: false
40+
41+
# MD003 - Heading style (false positives from = in LaTeX equations)
42+
MD003: false
43+
44+
# MD025 - Multiple H1 headings (Quarto books have multiple titled sections)
45+
MD025: false
46+
47+
# MD001 - Heading increment (Quarto YAML title acts as H1, sections may start at H3)
48+
MD001: false
49+
50+
# MD022 - Blanks around headings (false positives from LaTeX arrays/matrices)
51+
MD022: false
52+
53+
# MD012 - Multiple consecutive blank lines (false positives in Python code blocks with PEP8 style)
54+
MD012: false
55+
56+
# MD004 - Unordered list style (allow both dash and plus - converted from DocOnce)
57+
MD004: false
58+
59+
# MD031 - Blanks around fences (false positives in nested documentation examples)
60+
MD031: false
61+
1962
# MD007 - Unordered list indentation
2063
MD007:
2164
indent: 2

.markdownlintignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@
33

44
# Build outputs
55
doc/pub/
6+
_book/
7+
8+
# Virtual environments
9+
venv/
10+
.venv/

CLAUDE.md

Lines changed: 91 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,9 @@ This is the source repository for *Finite Difference Computing with PDEs - A Mod
1111
### Build Book PDF
1212

1313
```bash
14-
cd doc/.src/book
15-
bash make.sh nospell # Skip spellcheck (faster)
16-
bash make.sh # With spellcheck
17-
```
18-
19-
### Build Individual Chapter
20-
21-
```bash
22-
cd doc/.src/chapters/vib # or wave, diffu, advec, nonlin, trunc, softeng2, formulas
23-
bash make.sh
14+
quarto render --to pdf # Build PDF
15+
quarto render # Build all formats (HTML + PDF)
16+
quarto preview # Live preview with hot reload
2417
```
2518

2619
### Run Tests
@@ -45,28 +38,30 @@ pre-commit run --hook-stage manual # Run auto-fix hooks
4538

4639
### Directory Structure
4740

48-
- `src/` - Python source code organized by chapter (vib, wave, diffu, nonlin, etc.)
49-
- `doc/.src/book/` - Main book build (book.do.txt includes all chapters)
50-
- `doc/.src/chapters/` - DocOnce source for each chapter:
51-
- `*.do.txt` - DocOnce markup files (main content)
52-
- `fig-*/` - Figures for the chapter
53-
- `exer-*/` - Exercise solutions and supporting code
54-
- `.dict4spell.txt` - Chapter-specific spelling dictionary
41+
- `chapters/` - Quarto source files organized by topic:
42+
- `vib/` - Vibration ODEs
43+
- `wave/` - Wave equations
44+
- `diffu/` - Diffusion equations
45+
- `advec/` - Advection equations
46+
- `nonlin/` - Nonlinear problems
47+
- `appendices/` - Truncation errors, formulas, software engineering
48+
- `src/` - Python source code organized by chapter
49+
- `_book/` - Generated output (PDF, HTML)
50+
- `_quarto.yml` - Book configuration
5551

56-
### DocOnce Document Format
52+
### Quarto Document Format
5753

58-
The book uses [DocOnce](https://github.com/doconce/doconce), a markup language that compiles to LaTeX/PDF. Key syntax:
54+
The book uses [Quarto](https://quarto.org/) for scientific publishing. Key syntax:
5955

60-
- `@@@CODE path/to/file.py fromto: start_pattern@end_pattern` - Include code snippet between patterns
61-
- `!bc pycod` / `!ec` - Python code block
62-
- `!bt` / `!et` - LaTeX math block
63-
- `idx{term}` - Index entry
64-
- `ref{label}` - Cross-reference
65-
- `# #include "file.do.txt"` - Include another file
56+
- ` ```python ` / ` ``` ` - Python code block
57+
- `$$ ... $$` - Display math with optional `{#eq-label}`
58+
- `@sec-label`, `@eq-label`, `@fig-label` - Cross-references
59+
- `{{< include file.qmd >}}` - Include another file
60+
- `{=latex}` blocks for raw LaTeX when needed
6661

6762
### Code Organization Pattern
6863

69-
Each chapter's Python code lives in `src/CHAPTER/` and is referenced by documentation in `doc/.src/chapters/CHAPTER/`. The `@@@CODE` directive pulls code snippets directly from source files into the documentation, keeping code and docs in sync.
64+
Each chapter's Python code lives in `src/CHAPTER/` and can be included in QMD files using fenced code blocks or Quarto includes.
7065

7166
## Pre-commit Hooks
7267

@@ -80,11 +75,78 @@ Pre-commit hooks run automatically on commit:
8075

8176
## Key Dependencies
8277

83-
- **doconce** - Document generation from .do.txt files
78+
- **quarto** - Document generation from .qmd files
8479
- **numpy, scipy, matplotlib, sympy** - Scientific Python stack for examples
8580
- **pdflatex** - LaTeX compilation (requires TeX Live installation)
8681

8782
## Build Output
8883

89-
- `doc/.src/book/book.pdf` - Generated book PDF
90-
- `doc/pub/book/pdf/fdm-book.pdf` - Published copy of book PDF
84+
- `_book/Finite-Difference-Computing-with-PDEs.pdf` - Generated book PDF
85+
86+
## Quarto Equation Labeling Guidelines
87+
88+
**Known Bug (GitHub Issue #2275)**: Quarto's `{#eq-label}` syntax cannot label individual lines within `\begin{align}` environments. This causes "macro parameter character #" LaTeX errors.
89+
90+
### What Fails
91+
92+
```markdown
93+
$$
94+
\begin{align}
95+
a &= 0+1 {#eq-first} <!-- causes LaTeX error -->
96+
b &= 2+3 {#eq-second}
97+
\end{align}
98+
$$
99+
```
100+
101+
### Working Patterns
102+
103+
**Single equation or whole block label** - place label AFTER closing `$$`:
104+
```markdown
105+
$$
106+
\begin{split}
107+
a &= 0+1 \\
108+
b &= 2+3
109+
\end{split}
110+
$$ {#eq-block}
111+
```
112+
113+
**Multiple separate equations** - use separate `$$` blocks:
114+
```markdown
115+
$$
116+
a = 0+1
117+
$$ {#eq-first}
118+
$$
119+
b = 2+3
120+
$$ {#eq-second}
121+
```
122+
123+
**Individual line labels in align** - use pure AMS LaTeX syntax:
124+
```latex
125+
\begin{align}
126+
a &= 0+1 \label{eq:first} \\
127+
b &= 2+3 \label{eq:second}
128+
\end{align}
129+
130+
See Equation \eqref{eq:first} for details.
131+
```
132+
133+
### Best Practices
134+
135+
- **Never mix Quarto `{#eq-}` and AMS `\label{}` syntax** in the same equation
136+
- Use `\begin{equation}...\end{equation}` for single numbered equations
137+
- Use `\begin{align}...\end{align}` with `\label{}` for multiple aligned, individually-numbered equations
138+
- Use `\begin{aligned}...\end{aligned}` inside `\begin{equation}` for aligned equations sharing one number
139+
- Add `*` (e.g., `\begin{align*}`) to suppress all numbering
140+
- Reference with `\eqref{label}` for parenthesized numbers, `\ref{label}` for plain numbers
141+
- For Quarto cross-refs, use `@eq-label` syntax with label placed after `$$`
142+
143+
### Cross-Reference Prefixes
144+
145+
| Type | Prefix | Example |
146+
|------|--------|---------|
147+
| Section | `@sec-` | `@sec-vib-ode1` |
148+
| Equation | `@eq-` | `@eq-vib-ode1-step4` |
149+
| Figure | `@fig-` | `@fig-vib-phase` |
150+
| Table | `@tbl-` | `@tbl-trunc-fd1` |
151+
152+
Reference: [NMFS-OpenSci Quarto-AMS Math Guide](https://nmfs-opensci.github.io/quarto-amsmath)

_quarto.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ format:
3535
code-fold: false
3636
toc: true
3737
number-sections: true
38+
number-depth: 3
3839
crossref:
3940
chapters: true
4041
pdf:
4142
documentclass: book
4243
papersize: letter
4344
toc: true
4445
number-sections: true
46+
number-depth: 3
4547
colorlinks: true
4648
default-image-extension: png
4749
pdf-engine: pdflatex

0 commit comments

Comments
 (0)