paper-latex-writing
Trackable LaTeX academic paper editing with session-based logging
Purpose
Perform systematic, trackable edits to LaTeX academic papers using coding-by-logging methodology. All changes are logged with before/after diffs, metrics tracking, and git-compatible version control.
Capabilities
1. Length Reduction
- •Identify verbose sections and redundant content
- •Cut to target page/word count while preserving key points
- •Iterative reduction with metrics tracking
- •Section-level or global scope
2. Clarity Improvement
- •Rewrite dense paragraphs for readability
- •Simplify complex sentences
- •Improve logical flow and transitions
- •Strengthen topic sentences
3. Citation Management
- •Fix broken/missing citations
- •Add citations for uncited claims
- •Remove unnecessary citations
- •Ensure consistent citation style
- •Update bibliography entries
4. Structural Reorganization
- •Move sections/subsections
- •Merge related content
- •Split overly long sections
- •Reorder for better narrative flow
5. Figure/Table Management
- •Fix broken references
- •Add/update captions
- •Ensure all figures are referenced
- •Check figure placement and sizing
6. Consistency Checking
- •Terminology consistency (e.g., "dataset" vs "data set")
- •Notation consistency (math symbols, variable names)
- •Formatting consistency (capitalization, hyphenation)
- •Style guide compliance (e.g., ICML, NeurIPS)
Paper Structure Auto-Detection
Hybrid Detection Strategy
On first invocation, the skill automatically:
- •
Scans current directory for paper structure:
code- Main .tex file: Find file with \documentclass - Bibliography: Find .bib file - Sections: Detect \input{} patterns - Structure type: Modular (separate files) or Monolithic (single file) - Logging location: paper/code-logging/ or create if missing - •
Creates
.paper-latex-config.yamlwith detected structure:yaml# Auto-generated on 2026-01-17 main_tex: fairglucose_icml2026.tex bibliography: fairglucose_icml2026.bib sections_dir: _sections/ structure: modular logging_dir: paper/code-logging/ # Section mapping (auto-detected from \input commands) sections: abstract: _sections/00_abstract.tex introduction: _sections/01_introduction.tex related_work: _sections/02_related_work.tex dataset_design: _sections/03_dataset_design.tex benchmark_protocol: _sections/04_benchmark_protocol.tex baseline_results: _sections/05_baseline_results.tex discussion: _sections/06_discussion.tex conclusion: _sections/07_conclusion.tex appendix_sections: dataset_statistics: _sections/appendix/A_dataset_statistics.tex model_evaluation: _sections/appendix/B_model_evaluation.tex experiment_details: _sections/appendix/C_experiment_details.tex # Figures and tables figures_dir: Figures/ tables_dir: Table/ appendix_figures_dir: AppendixFigure/ appendix_tables_dir: AppendixTable/ # Compilation compiler: pdflatex bibtex: bibtex # Target metrics (can be updated) target_pages: 8 current_pages: 35 venue: ICML 2026 track: Datasets & Benchmarks
- •
User can override by editing
.paper-latex-config.yamlor providing custom config:bash/paper-latex-writing --config custom-paper-config.yaml "reduce to 10 pages"
Fallback Behavior
If auto-detection fails:
- •Ask user to specify main .tex file
- •Prompt for structure type (modular/monolithic)
- •Create minimal config and proceed
Session-Based Logging
Log File Structure
paper/code-logging/
├── latex-writing-sessions.md # Main log (all sessions)
└── archives/
├── session-001-length-reduction.md
├── session-002-clarity-pass.md
└── session-003-citation-fixes.md
Log Format
CRITICAL: Inline Modification Format
All changes in session logs MUST use the strikethrough/CC-modify notation for trackability:
Format Rules:
**P1**: ~~Old content description~~
New content description >> CC-modify
**P2**: ~~Text to delete~~ >> CC-modify: DELETE
**P3 (NEW)**: New paragraph to add >> CC-modify
Notation Standards:
- •KEEP = no comment (leave original text as-is)
- •MODIFY =
oldon first line, new text on second line (indented with spaces) >> CC-modify - •DELETE (single line) =
text>> CC-modify: DELETE - •DELETE (multi-line) = Each line gets ~~ markers, then >> CC-modify at end
- •ADD = new text >> CC-modify (mark as NEW)
Readability tip: For long modifications, always use two lines:
- •Line 1:
strikethrough old text - •Line 2: Indented new text (4+ spaces) >> CC-modify
Multi-line deletion example:
~~**Subsection Title**:~~ ~~First paragraph to remove...~~ ~~Second paragraph to remove...~~ >> CC-modify: DELETE
LaTeX-specific examples (with % comments for compilation safety):
When editing .tex files directly, ALL tracking notation must be commented with %:
% ~~\subsection{Verbose Title That's Too Long}~~
% \subsection{Concise Title} >> CC-modify
\subsection{Concise Title}
% ~~Figure~\ref{fig:removed} shows the detailed analysis...~~
% >> CC-modify: DELETE
% \textbf{Event Impact} (NEW): Events increase error by 8.2 mg/dL. >> CC-modify
\textbf{Event Impact}: Events increase error by 8.2 mg/dL.
CRITICAL LaTeX Rule:
- •All
~~strikethrough~~lines → prefix with% - •All
>> CC-modifymarkers → prefix with% - •Actual new code → NO
%(must compile) - •This keeps tracking visible in source but doesn't break compilation
Complete LaTeX modification example:
% File: _sections/05_baseline_results.tex
% Lines: 45-52
% ~~\subsection{Subgroup Performance Analysis}~~
% \subsection{Subgroup Performance and Generalization} >> CC-modify
\subsection{Subgroup Performance and Generalization}
% ~~Across all demographic and clinical subgroups, we observe substantial~~
% ~~heterogeneity in model performance. Male patients in the 18-39 age group~~
% ~~consistently demonstrate lower prediction error compared to their female~~
% ~~counterparts...~~
% Model performance varies substantially across demographic strata:
% \begin{itemize}
% \item \textbf{Age-Gender}: Males 18-39 outperform females by 3.2 mg/dL
% \item \textbf{Diabetes Type}: T1D shows 15\% higher error than T2D
% \end{itemize} >> CC-modify
Model performance varies substantially across demographic strata:
\begin{itemize}
\item \textbf{Age-Gender}: Males 18-39 outperform females by 3.2 mg/dL
\item \textbf{Diabetes Type}: T1D shows 15\% higher error than T2D
\end{itemize}
Two-location tracking:
- •In .tex files - Use
%commented tracking for in-place edits - •In session logs - Show both commented tracking AND clean before/after for clarity
This format ensures: ✓ Every change is explicitly marked ✓ Before/after states are clear ✓ Changes are git-trackable ✓ User can review modifications before approval ✓ Session logs are self-documenting ✓ LaTeX files still compile with tracking in place
Edit Workflow with LaTeX Comment Tracking
Step 1: Read original content
Read(_sections/05_baseline_results.tex, lines 45-52)
Step 2: Make edit with commented tracking
Edit(_sections/05_baseline_results.tex):
old_string: "\subsection{Subgroup Performance Analysis}"
new_string: "% ~~\subsection{Subgroup Performance Analysis}~~
% \subsection{Subgroup Performance and Generalization} >> CC-modify
\subsection{Subgroup Performance and Generalization}"
Step 3: Log in session file (unformatted for readability)
Change 1: Updated subsection title
~~\subsection{Subgroup Performance Analysis}~~
\subsection{Subgroup Performance and Generalization} >> CC-modify
Step 4: Verify compilation
pdflatex fairglucose_icml2026.tex # Comments are ignored, new code compiles ✓
Cleanup Option (post-session): After session is complete and logged, user can optionally run:
# Remove all % commented tracking from .tex files sed -i '/^% ~~/d' _sections/*.tex sed -i '/^% >> CC-modify/d' _sections/*.tex
But tracking can safely stay in files indefinitely - it's just comments.
Session Log Template:
Paper LaTeX Writing - Session Log
==================================
Session Metadata
----------------
Session ID: 003
Date: 2026-01-17
Task: "Reduce Section 5 to 1.5 pages while keeping key results"
Mode: Hybrid (Plan → Approve → Execute)
Author: >> CC (Claude Code)
Current Paper State
-------------------
- Total Pages: 35
- Target Pages: 8
- Venue: ICML 2026
- Sections: 8 main + 3 appendix
---
Analysis Phase
--------------
> JL: "Reduce Section 5 to 1.5 pages while keeping key results"
>> CC: Analyzing Section 5 (Baseline Results)...
Current State:
- File: _sections/05_baseline_results.tex
- Lines: 287
- Estimated Pages: 3.2
- Target: 1.5 pages (~140 lines)
- Reduction Needed: ~50%
Content Breakdown:
1. Overview paragraph (15 lines)
2. Subgroup Performance subsection (85 lines)
- Verbose description of disparities
- Redundant pattern descriptions
3. Generalization subsection (72 lines)
- Detailed OD/ID analysis
- Overlaps with main text Figure 2 discussion
4. Event Impact subsection (95 lines)
- Three paragraphs on event effects
- Some redundancy with Dataset Design section
5. Model Comparison (20 lines)
Reduction Strategy:
- Keep: Overview, Event Impact (key contribution)
- Condense: Subgroup Performance (50% reduction)
- Merge: Generalization into Subgroup Performance
- Cut: Redundant pattern descriptions, overlapping content
Estimated Savings: 147 lines → Target: 140 lines ✓
---
Reduction Plan
--------------
>> CC: Proposed Changes (for approval)
Change 1: Condense Subgroup Performance
- Before: 85 lines (3 paragraphs of detailed description)
- After: 42 lines (1 concise paragraph + bullet points)
- Savings: 43 lines
Change 2: Merge Generalization into Subgroup Performance
- Before: 72 lines (separate subsection)
- After: 25 lines (integrated into one paragraph)
- Savings: 47 lines
Change 3: Tighten Event Impact
- Before: 95 lines (3 verbose paragraphs)
- After: 60 lines (2 concise paragraphs)
- Savings: 35 lines
Change 4: Remove redundant Figure 2 discussion
- Before: 22 lines
- After: 0 lines (already in Section 3)
- Savings: 22 lines
Total Reduction: 147 lines (51% reduction)
Final Estimate: 140 lines (1.5 pages) ✓
> JL: Approved. Proceed.
---
Execution Phase
---------------
>> CC: Executing changes...
[Change 1/4] Condensing Subgroup Performance subsection
File: _sections/05_baseline_results.tex
Lines: 45-130
BEFORE (85 lines):
```latex
\subsection{Subgroup Performance Analysis}
Across all demographic and clinical subgroups, we observe substantial
heterogeneity in model performance. Male patients in the 18-39 age group
consistently demonstrate lower prediction error compared to their female
counterparts in the same age bracket, with rMSE values differing by an
average of 3.2 mg/dL (p < 0.01). This pattern reverses in the 65+ age
group, where female patients exhibit better model performance...
[... 80 more lines of detailed description ...]
AFTER (42 lines):
\subsection{Subgroup Performance and Generalization}
Model performance varies substantially across demographic strata:
- **Age-Gender Interaction**: Males (18-39) outperform females by 3.2 mg/dL
rMSE; pattern reverses in 65+ group
- **Diabetes Type**: T1D patients show 15% higher error than T2D across all
models despite structured insulin regimens
- **Generalization**: OD/ID error ratios span 0.8-1.4 across subgroups; T1D
females (40-64) show greatest degradation under distribution shift
These intersectional disparities highlight the need for fairness-aware
evaluation beyond marginal attributes.
DIFF:
- •Lines reduced: 85 → 42 (-43 lines, -51%)
- •Content preserved: All key findings retained in bullet format
- •Merged: Generalization findings integrated
- •Improved: Scannable structure, removed verbose descriptions
✓ Change 1 complete
[Change 2/4] Already integrated into Change 1 ✓ Change 2 complete
[Change 3/4] Tightening Event Impact subsection ...
Session Summary
CC: Session 003 Complete
Changes Made:
- •Sections Modified: 1 (_sections/05_baseline_results.tex)
- •Lines Changed: 147 removed, 85 added
- •Net Reduction: 62 lines
- •Commits: 1 (with detailed commit message)
Metrics:
- •Section 5 Before: 287 lines (3.2 pages)
- •Section 5 After: 140 lines (1.5 pages)
- •Target Achievement: ✓ (1.5 pages)
- •Overall Paper: 35 pages → 33.3 pages
Next Steps:
- •Recompile PDF to verify page count
- •Review Section 3 for additional reduction opportunities
- •Consider moving detailed results to appendix
Git Status: M _sections/05_baseline_results.tex
Suggested commit message:
Reduce Section 5 (Baseline Results) to 1.5 pages - Condense Subgroup Performance to bullet points - Merge Generalization into Subgroup Performance - Tighten Event Impact description - Remove redundant Figure 2 discussion Session: 003 Reduction: 287 → 140 lines (51% cut) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
===================================================================
## Invocation Patterns ### Natural Language Examples ```bash # Length reduction /paper-latex-writing "reduce the paper from 35 to 8 pages" /paper-latex-writing "shorten Section 3 by 50%" /paper-latex-writing "cut Introduction to 1 page" # Clarity improvement /paper-latex-writing "improve clarity in the Discussion section" /paper-latex-writing "simplify the methodology description" /paper-latex-writing "make the abstract more accessible" # Citation fixes /paper-latex-writing "fix all citation errors" /paper-latex-writing "add citations for claims in Section 2" /paper-latex-writing "ensure all references compile correctly" # Structural changes /paper-latex-writing "move the event characterization to Section 3" /paper-latex-writing "merge subsections 4.1 and 4.2" /paper-latex-writing "reorganize Related Work by theme" # Combined tasks /paper-latex-writing "reduce to 10 pages and fix all citations" /paper-latex-writing "tighten Section 5, improve clarity, ensure all figures are referenced" # Global operations /paper-latex-writing "analyze the entire paper for reduction opportunities" /paper-latex-writing "check terminology consistency throughout"
Execution Workflow
Hybrid Mode (Plan → Approve → Execute)
┌─────────────────────────────────────────────┐
│ 1. PARSE TASK │
│ - Extract intent from natural language │
│ - Identify scope (section/global) │
│ - Determine primary capability needed │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ 2. AUTO-DETECT / LOAD CONFIG │
│ - Find .paper-latex-config.yaml │
│ - If missing: auto-detect structure │
│ - Create config for future use │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ 3. ANALYSIS PHASE │
│ - Read relevant sections │
│ - Measure current metrics │
│ - Identify issues/opportunities │
│ - Log analysis to session file │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ 4. PLANNING PHASE │
│ - Create detailed change plan │
│ - Estimate impact (lines/pages saved) │
│ - Show before/after previews │
│ - Log plan with numbered changes │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ 5. APPROVAL CHECKPOINT │
│ - Present plan to user │
│ - Wait for: Approve / Modify / Reject │
│ - If modifications: return to Planning │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ 6. EXECUTION PHASE │
│ - Execute each change sequentially │
│ - Log each change with diffs │
│ - Update metrics after each change │
│ - Verify compilation after edits │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ 7. SUMMARY & COMMIT │
│ - Summarize all changes │
│ - Report final metrics │
│ - Generate commit message │
│ - Archive session log │
└─────────────────────────────────────────────┘
Special Features
Length Reduction Strategies
Strategy 1: Analyze First
/paper-latex-writing "analyze paper for reduction to 8 pages"
- •Provides breakdown of each section
- •Identifies low-value content
- •Suggests specific cuts
- •No changes made (analysis only)
Strategy 2: Global Plan
/paper-latex-writing "create reduction plan to reach 8 pages"
- •Multi-section coordinated plan
- •Balanced reduction across sections
- •Preserves paper flow
- •Requires approval before execution
Strategy 3: Iterative Reduction
/paper-latex-writing "reduce paper by 10%" # Review results /paper-latex-writing "reduce by another 10%" # Repeat until target reached
- •Gentle, controlled reduction
- •Easy to review incremental changes
- •Can stop when quality starts degrading
Metrics Tracking
Automatically tracked across sessions:
metrics: total_pages: 35 → 33.3 → 30.1 → 28.5 total_lines: 4200 → 3980 → 3654 → 3421 sections_modified: [5, 3, 1, 2] citations_fixed: 12 figures_checked: 18 compilation_success: true sessions_completed: 4
Diff Visualization
Each change shows:
File: _sections/03_dataset_design.tex Lines: 45-68 - Despite this advancement, existing CGM modeling benchmarks are hindered by - unbalanced datasets, limited demographic diversity, and lack of event - annotations (meals, exercise, medication), obscuring both performance - disparities across patient types and prediction challenges driven by - glucose-altering events. + Existing CGM benchmarks lack demographic balance and event annotations, + obscuring both fairness issues and event-driven prediction challenges. Lines: 2 → 1 (-1 line, -50%) Words: 48 → 16 (-32 words, -67%)
Integration with Git
Commit Message Generation
After each session, generates detailed commit message:
Reduce Section 5 and fix citations (Session 003) Length Reduction: - Section 5: 287 → 140 lines (1.5 pages) - Condensed Subgroup Performance to bullets - Merged Generalization subsection - Removed redundant Figure 2 discussion Citation Fixes: - Fixed 3 broken citations (tft, informer) - Updated bibliography formatting - Added missing citations in Related Work Metrics: - Total pages: 35 → 33.3 (-5%) - Compilation: ✓ successful - Session log: paper/code-logging/archives/session-003-length-reduction.md Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Configuration Reference
.paper-latex-config.yaml Schema
# Paper identification
main_tex: string # Main .tex file
bibliography: string # .bib file
structure: modular|monolithic # File organization
# Directories
sections_dir: string # Modular sections folder
figures_dir: string
tables_dir: string
appendix_figures_dir: string
appendix_tables_dir: string
logging_dir: string # Session logs location
# Section mapping (for modular papers)
sections:
section_name: path/to/file.tex
appendix_sections:
appendix_name: path/to/file.tex
# Compilation
compiler: pdflatex|xelatex|lualatex
bibtex: bibtex|biber
compile_flags: [string]
# Target metrics
target_pages: integer
current_pages: integer
venue: string
track: string
# Style preferences (optional)
style:
max_sentence_length: integer
max_paragraph_lines: integer
prefer_active_voice: boolean
terminology_map:
dataset: "dataset" # Enforce consistency
data-set: "dataset"
# Custom ignore patterns
ignore_sections:
- acknowledgments
- references
Best Practices
1. Start with Analysis
Always run analysis before making changes:
/paper-latex-writing "analyze paper for 8-page reduction" # Review analysis /paper-latex-writing "execute the reduction plan"
2. One Capability at a Time
For complex tasks, separate concerns:
# Bad: Too many goals /paper-latex-writing "reduce length, fix all citations, reorganize structure" # Good: Sequential focused tasks /paper-latex-writing "reduce to target length" /paper-latex-writing "fix all citations" /paper-latex-writing "reorganize Related Work"
3. Verify After Each Session
Always compile and review:
pdflatex fairglucose_icml2026.tex # Check page count, references, formatting
4. Use Git for Safety
Commit before major operations:
git add . git commit -m "Before length reduction session" /paper-latex-writing "reduce by 30%" # If unhappy with results: git reset --hard HEAD
5. Iterative for Large Cuts
For large reductions (35 → 8 pages), iterate:
/paper-latex-writing "reduce to 20 pages" # -43% # Review and adjust /paper-latex-writing "reduce to 12 pages" # -40% # Review and adjust /paper-latex-writing "reduce to 8 pages" # -33%
Error Handling
Common Issues
Issue: Main .tex file not found
- •Detection: Auto-scan finds multiple .tex files or none
- •Resolution: Prompt user to specify, create config
Issue: Compilation fails after edits
- •Detection: Run pdflatex after each change
- •Resolution: Automatic rollback of last change, log error
Issue: Section file missing
- •Detection: \input{} references non-existent file
- •Resolution: Update config, skip missing sections
Issue: Citation key not found in .bib
- •Detection: Parse .bib and cross-check \cite{} commands
- •Resolution: List missing keys, ask user to add or remove citations
Advanced Usage
Custom Reduction Rules
Create .paper-latex-rules.yaml:
reduction_priorities:
high:
- verbose_descriptions
- redundant_citations
- overlapping_content
medium:
- example_details
- background_material
low:
- key_contributions
- novel_results
- fairness_findings
protected_content:
- \section{Introduction} # Never auto-cut introduction
- Figure 1 # Key figure must stay
- Table 2 # Main results table
cut_candidates:
- "Moreover," # Remove filler transitions
- "It is worth noting that"
- "In other words"
Batch Operations
Process multiple papers:
/paper-latex-writing --config paper1-config.yaml "reduce to 8 pages" /paper-latex-writing --config paper2-config.yaml "reduce to 8 pages"
Tool Requirements
The skill should use these Claude Code tools:
- •Read: Read .tex, .bib, config files
- •Edit: Make precise text replacements
- •Write: Create config files, session logs
- •Bash: Run pdflatex, bibtex, check compilation
- •Glob: Find all .tex files, figures
- •Grep: Search for citations, references, patterns
Output Format
Always respond with:
- •Session header with task and metadata
- •Analysis summary with current state
- •Proposed plan with estimated impact
- •Approval request (if hybrid mode)
- •Execution log with diffs
- •Final summary with metrics and commit message
Implementation Notes
This skill should be invoked via:
/paper-latex-writing "natural language task description"
The skill activates when user provides paper editing task in natural language. All changes are logged, trackable via git, and reversible.