This document explains the markdown template structure and cross-referencing system implemented in this project. For related information, see ../core/how-to-use.md for usage guidance, ../core/architecture.md, ../core/workflow.md, and ../README.md.
The template demonstrates a academic paper structure with the following markdown files:
manuscript/preamble.md- LaTeX preamble with styling and packagesmanuscript/01_abstract.md- Research overview and key contributionsmanuscript/02_introduction.md- Introduction with section references and overviewmanuscript/03_methodology.md- Mathematical framework with numbered equationsmanuscript/04_experimental_results.md- Results with figure and equation referencesmanuscript/05_discussion.md- Discussion with cross-references to previous sectionsmanuscript/06_conclusion.md- Conclusion summarizing all contributionsmanuscript/98_symbols_glossary.md- Auto-generated API reference fromprojects/{name}/src/
Use \ref{sec:section_name} to reference sections:
# Introduction {#sec:introduction}
The methodology described in Section \ref{sec:methodology} shows...Available section labels:
{#sec:introduction}- Introduction{#sec:methodology}- Methodology{#sec:experimental_results}- Experimental Results{#sec:discussion}- Discussion{#sec:conclusion}- Conclusion
Use \eqref{eq:equation_name} to reference equations:
\begin{equation}\label{eq:convergence}
\|x_k - x^*\| \leq C \rho^k
\end{equation}
The convergence rate \eqref{eq:convergence} shows...Key equations in the template:
eq:objective- Main objective functioneq:optimization- Optimization problemeq:update- Algorithm update ruleeq:convergence- Convergence boundeq:adaptive_step- Adaptive step sizeeq:memory- Memory scalingeq:accuracy- Accuracy metriceq:advantage_metric- Performance advantageeq:robustness_metric- Robustness measureeq:complexity_bound- Complexity boundeq:final_improvement- Overall improvement
Use \ref{fig:figure_name} to reference figures:
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{../output/figures/experimental_setup.png}
\caption{Experimental setup diagram}
\label{fig:experimental_setup}
\end{figure}
Figure \ref{fig:experimental_setup} shows the pipeline...Available figures:
fig:example_figure- Basic example function plotfig:convergence_plot- Algorithm convergence comparisonfig:experimental_setup- Experimental pipeline diagramfig:scalability_analysis- Performance scaling analysisfig:ablation_study- Component ablation resultsfig:hyperparameter_sensitivity- Parameter sensitivity surface
Use \ref{tab:table_name} to reference tables:
| Metric | Value | Unit |
|--------|-------|------|
| Performance | 23.7% | improvement |
Table \ref{tab:performance_summary} shows...The template shows proper use of LaTeX equation environments:
\begin{equation}\label{eq:example}
f(x) = \sum_{i=1}^{n} w_i \phi_i(x)
\end{equation}Examples of mathematical notation used:
-
Greek letters:
$\alpha$ ,$\beta$ ,$\lambda$ ,$\rho$ ,$\epsilon$ -
Mathematical operators:
$\min$ ,$\max$ ,$\sum$ ,$\prod$ -
Special symbols:
$\mathbb{R}$ ,$\mathcal{X}$ ,$\nabla$ -
Subscripts/superscripts:
$x_k$ ,$x^*$ ,$w_i$
Demonstrates various cross-reference patterns:
- Section references: Section \ref{sec:methodology}
- Equation references: \eqref{eq:convergence}
- Figure references: Figure \ref{fig:convergence_plot}
- Multiple references: equations \eqref{eq:objective} through \eqref{eq:convergence}The template includes two figure generation scripts that demonstrate the thin orchestrator pattern:
example_figure.py- Basic example figure usingprojects/{name}/src/methodsgenerate_research_figures.py- research figures usingprojects/{name}/src/methods
Scripts in the scripts/ directory are thin orchestrators that:
- Import mathematical functions from
projects/{name}/src/modules - Use tested methods for all computation (never implement algorithms)
- Handle visualization, I/O, and orchestration
- Generate figures and data outputs
- Validate that
projects/{name}/src/integration works correctly
Example integration:
# Import projects/{name}/src/ methods for computation
from project.src.example import add_numbers, calculate_average
def generate_figure():
# Use projects/{name}/src/ methods for all computation
data = [1, 2, 3, 4, 5]
avg = calculate_average(data) # From projects/{name}/src/example.py
# Script handles visualization and output
fig, ax = plt.subplots()
ax.plot(data)
ax.set_title(f"Average: {avg}")
return figFigures are automatically saved to:
output/figures/- PNG filesoutput/data/- NPZ and CSV data files
Figures are referenced in markdown using relative paths:
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{../output/figures/figure_name.png}
\caption{Figure caption}
\label{fig:figure_name}
\end{figure}Markdown validation is performed via the infrastructure validation module:
uv run python -m infrastructure.validation.cli markdown projects/{name}/manuscript/This checks:
- Image file existence
- Equation label uniqueness
- Cross-reference validity
- No bare URLs
Glossary generation is not a fixed numbered pipeline stage in the root scripts/ DAG; run it manually when needed (see modules guide):
uv run python -m infrastructure.documentation.generate_glossary_cli \
projects/code_project/src/ projects/code_project/manuscript/98_symbols_glossary.mdThis:
- Scans the given
src/tree for public APIs - Generates a markdown table
- Injects it into the target manuscript file (created if missing)
The pipeline orchestrator (scripts/execute_pipeline.py):
- Runs tests with coverage requirements (90% project, 60% infra)
- Executes scripts to generate figures and data (validating projects/{name}/src/ integration)
- Validates manuscript for references and images
- Builds individual PDFs for each manuscript file
- Creates combined PDF with all sections
- Exports LaTeX source files
Generated outputs include:
- Individual PDFs for each section
- Combined PDF with all sections
- LaTeX source files
- Figures and data files
- Coverage reports
- Add section label:
# Section Title {#sec:section_name} - Use descriptive equation labels:
\label{eq:descriptive_name} - Reference previous content: Use
\ref{}and\eqref{} - Include figures: Reference generated figures with
\ref{fig:name}
- Use equation environment:
\begin{equation}\label{eq:name}...\end{equation} - Choose descriptive labels: Avoid generic names like
eq:1 - Reference consistently: Use
\eqref{eq:name}throughout
- Generate with scripts: Use scripts in
projects/{name}/scripts/directory - Use projects/{name}/src/ methods: Import and use tested methods from
projects/{name}/src/modules - Save to output: Place in
output/figures/ - Reference properly: Use
\ref{fig:name}in markdown - Include data: Save both figures and data files
- Create new markdown file in
manuscript/ - Add section label:
{#sec:new_section} - Include cross-references to existing content
- Add to the build pipeline (automatic)
- Update equation content and labels
- Update all references using
\eqref{} - Ensure label uniqueness across document
- Add new figure generation functions to existing scripts or create new ones
- Import from projects/{name}/src/: Ensure scripts use
projects/{name}/src/methods for computation - Update scripts to generate new figures
- Add figure references in markdown
- Ensure proper file paths and naming
- Create modules in
projects/{name}/src/directory - Add tests in
projects/{name}/tests/directory (coverage requirements apply) - Update scripts to import and use new
projects/{name}/src/methods - Validate integration through the build pipeline
- Missing references: Check that labels exist and are spelled correctly
- Figure not found: Verify figure file exists in
output/figures/ - Equation numbering: Ensure unique labels across all files
- Build failures: Check markdown validation output
- Script import errors: Ensure
projects/{name}/src/modules exist and are properly tested
Symptom: \ref{sec:label} shows ?? in PDF
Solution: Check label exists - search for {#sec:label_name} in manuscript files
Symptom: Figure renders but wrong location
Solution: Use relative path ../output/figures/name.png not absolute paths
The validation system will report:
- Missing image files
- Unresolved cross-references
- Duplicate equation labels
- Bare URLs or non-informative links
- Missing figures: Run appropriate generation scripts
- Broken references: Check label spelling and existence
- Validation errors: Address each reported issue
- Build failures: Fix all validation issues before rebuilding
- Import errors: Ensure
projects/{name}/src/modules meet coverage requirements
This template enforces the thin orchestrator pattern where:
projects/{name}/src/contains ALL business logic, algorithms, and mathematical implementationsprojects/{name}/scripts/are lightweight wrappers that import and useprojects/{name}/src/methodsprojects/{name}/tests/ensures coverage ofprojects/{name}/src/functionalityscripts/execute_pipeline.pyorchestrates the entire 10-stage DAG pipeline
Scripts in projects/{name}/scripts/ MUST:
- Import methods from
projects/{name}/src/modules - Use
projects/{name}/src/methods for all computation - Handle only I/O, visualization, and orchestration
- Include proper error handling for imports
- Print output paths for render system
- Set
MPLBACKEND=Aggfor headless operation
Scripts MUST NOT:
- Implement mathematical algorithms
- Duplicate business logic from
projects/{name}/src/ - Contain complex computations
- Define new data structures
This template provides a framework for academic writing with:
- Structured organization of content into logical sections
- cross-referencing system for equations, figures, and sections
- Automated figure generation with proper integration using
projects/{name}/src/methods - Validation system ensuring document integrity
- Build pipeline generating both individual and combined PDFs
- LaTeX export for further customization
- Thin orchestrator pattern ensuring maintainability and testability
The system demonstrates best practices for academic writing while maintaining the flexibility to adapt to different research domains and writing styles, all while enforcing the architectural principles of the generic project template.
For more details on architecture and workflow, see:
../core/architecture.md- System design overview../architecture/two-layer-architecture.md- two-layer architecture guide../core/workflow.md- Development workflow
For manuscript formatting standards, see:
docs/rules/manuscript_style.md- manuscript formatting and style guide (equations, figures, tables, citations, lists, cross-references)