Paper Formatter Skill
Reformat an academic manuscript to match the style of a target journal, based on a sample paper (范文).
Workflow
Step 1: Receive Inputs
Ask the user for:
- Sample paper (范文): A paper from the target journal that exemplifies its formatting. Can be
.docx or .tex.
- User manuscript: The manuscript to reformat. Can be
.docx, .tex, or plain text.
- Desired output format:
.docx or .tex (default: same as manuscript format).
Step 2: Analyze Sample Paper Style
If sample is .docx:
Run the analysis script:
pip install python-docx 2>/dev/null
python ~/.claude/skills/paper-formatter/scripts/analyze_docx.py "<sample.docx>" "<output_rules.json>"
This extracts:
- Page layout (margins, paper size, orientation, columns)
- Paragraph styles per role (title, headings, body, abstract, captions, references)
- Font families, sizes, bold/italic
- Line spacing, indentation, paragraph spacing
- Table styles
- Citation style detection (numeric, author-year, etc.)
If sample is .tex:
Read the .tex file and extract style information from the preamble:
\documentclass options (font size, paper, columns)
\usepackage{geometry} margins
- Font packages and settings (
fontspec, xeCJK, ctex)
\usepackage{setspace} line spacing
\titleformat / \titlesec heading styles
- Citation package (
natbib, biblatex) and style
\fancyhdr header/footer settings
- Custom commands for title, abstract, keywords formatting
Produce a JSON style-rules object with the same structure as the docx analyzer output.
Step 3: Present Extracted Style Rules
Show the user a summary of extracted formatting rules organized by the checklist in references/formatting-elements.md:
- Page: paper size, margins, orientation
- Title: font, size, bold, alignment
- Authors/Affiliations: format
- Abstract: font, size, indentation
- Keywords: separator, font
- Headings: each level's font, size, bold, numbering scheme
- Body: font, size, line spacing, first-line indent, alignment
- Captions: position, font, size
- References: citation style, bibliography format
- Header/Footer: content
Ask the user to confirm or adjust any rules before proceeding.
Step 4: Parse User Manuscript
Read the user's manuscript and extract structured content:
{
"title": "...",
"authors": ["..."],
"affiliations": ["..."],
"abstract": "...",
"keywords": ["..."],
"sections": [
{
"heading": "Introduction",
"level": 1,
"content": ["paragraph1...", "paragraph2..."],
"subsections": [...]
}
],
"references": ["[1] ...", "[2] ..."],
"acknowledgments": "...",
"footnotes": ["..."]
}
For .docx manuscripts: use python-docx to read paragraphs, classify by style (similar to analyze_docx.py logic).
For .tex manuscripts: parse section commands (\section, \subsection), extract text between them, identify \begin{abstract}, \bibliography, etc.
For plain text: ask the user to identify sections or use heuristic detection (numbered headings, "Abstract:", "References" headers).
Step 5: Apply Formatting
If output is .docx:
Save the structured content to a temporary JSON file, then run:
python ~/.claude/skills/paper-formatter/scripts/format_docx.py "<content.json>" "<style_rules.json>" "<output.docx>"
If output is .tex:
python ~/.claude/skills/paper-formatter/scripts/generate_latex.py "<content.json>" "<style_rules.json>" "<output.tex>"
Step 6: Review & Iterate
After generating the output:
- Tell the user the output file path
- Ask them to review and identify any formatting issues
- Adjust style rules or content structure as needed
- Re-run the formatting script with updated inputs
Important Notes
Chinese Journal Support (中文期刊支持)
- Chinese font size names (字号) are mapped: 五号=10.5pt, 小四=12pt, etc.
- Common Chinese fonts: 宋体 (body), 黑体 (headings), 楷体 (abstract), 仿宋
- First-line indent: typically 2em (2 characters)
- Use
ctexart document class for LaTeX output
- GB/T 7714-2015 citation format with document type identifiers [J], [M], [C], etc.
- Full-width punctuation handling
Citation Styles
Refer to references/common-citation-styles.md for detailed formatting rules for:
- APA 7th, GB/T 7714-2015, Vancouver, IEEE, Chicago, MLA
Formatting Checklist
Refer to references/formatting-elements.md for the complete list of formatting elements to check and apply.
Dependencies
python-docx: Required for .docx analysis and generation. Install with pip install python-docx.
- For LaTeX output: the generated .tex file requires XeLaTeX compilation (for font support).
- Chinese LaTeX documents require:
ctex, xeCJK packages and appropriate Chinese fonts installed.
1---2name: paper-formatter3description: Format academic manuscripts to match a target journal's style. Use when users provide a sample paper (范文) from a journal and want their manuscript reformatted to match. Supports Word (.docx) and LaTeX (.tex) input/output. Covers Chinese and English journals. Handles title/abstract formatting, heading styles, body text font/size/spacing, figure/table captions, reference/bibliography style, page layout (margins, columns, headers/footers), footnotes, and section numbering.4---56# Paper Formatter Skill78Reformat an academic manuscript to match the style of a target journal, based on a sample paper (范文).910## Workflow1112### Step 1: Receive Inputs1314Ask the user for:151. **Sample paper (范文)**: A paper from the target journal that exemplifies its formatting. Can be `.docx` or `.tex`.162. **User manuscript**: The manuscript to reformat. Can be `.docx`, `.tex`, or plain text.173. **Desired output format**: `.docx` or `.tex` (default: same as manuscript format).1819### Step 2: Analyze Sample Paper Style2021**If sample is `.docx`:**2223Run the analysis script:24```bash25pip install python-docx 2>/dev/null26python ~/.claude/skills/paper-formatter/scripts/analyze_docx.py "<sample.docx>" "<output_rules.json>"27```2829This extracts:30- Page layout (margins, paper size, orientation, columns)31- Paragraph styles per role (title, headings, body, abstract, captions, references)32- Font families, sizes, bold/italic33- Line spacing, indentation, paragraph spacing34- Table styles35- Citation style detection (numeric, author-year, etc.)3637**If sample is `.tex`:**3839Read the `.tex` file and extract style information from the preamble:40- `\documentclass` options (font size, paper, columns)41- `\usepackage{geometry}` margins42- Font packages and settings (`fontspec`, `xeCJK`, `ctex`)43- `\usepackage{setspace}` line spacing44- `\titleformat` / `\titlesec` heading styles45- Citation package (`natbib`, `biblatex`) and style46- `\fancyhdr` header/footer settings47- Custom commands for title, abstract, keywords formatting4849Produce a JSON style-rules object with the same structure as the docx analyzer output.5051### Step 3: Present Extracted Style Rules5253Show the user a summary of extracted formatting rules organized by the checklist in `references/formatting-elements.md`:5455- **Page**: paper size, margins, orientation56- **Title**: font, size, bold, alignment57- **Authors/Affiliations**: format58- **Abstract**: font, size, indentation59- **Keywords**: separator, font60- **Headings**: each level's font, size, bold, numbering scheme61- **Body**: font, size, line spacing, first-line indent, alignment62- **Captions**: position, font, size63- **References**: citation style, bibliography format64- **Header/Footer**: content6566Ask the user to **confirm or adjust** any rules before proceeding.6768### Step 4: Parse User Manuscript6970Read the user's manuscript and extract structured content:7172```json73{74 "title": "...",75 "authors": ["..."],76 "affiliations": ["..."],77 "abstract": "...",78 "keywords": ["..."],79 "sections": [80 {81 "heading": "Introduction",82 "level": 1,83 "content": ["paragraph1...", "paragraph2..."],84 "subsections": [...]85 }86 ],87 "references": ["[1] ...", "[2] ..."],88 "acknowledgments": "...",89 "footnotes": ["..."]90}91```9293**For `.docx` manuscripts**: use `python-docx` to read paragraphs, classify by style (similar to analyze_docx.py logic).9495**For `.tex` manuscripts**: parse section commands (`\section`, `\subsection`), extract text between them, identify `\begin{abstract}`, `\bibliography`, etc.9697**For plain text**: ask the user to identify sections or use heuristic detection (numbered headings, "Abstract:", "References" headers).9899### Step 5: Apply Formatting100101**If output is `.docx`:**102103Save the structured content to a temporary JSON file, then run:104```bash105python ~/.claude/skills/paper-formatter/scripts/format_docx.py "<content.json>" "<style_rules.json>" "<output.docx>"106```107108**If output is `.tex`:**109110```bash111python ~/.claude/skills/paper-formatter/scripts/generate_latex.py "<content.json>" "<style_rules.json>" "<output.tex>"112```113114### Step 6: Review & Iterate115116After generating the output:1171. Tell the user the output file path1182. Ask them to review and identify any formatting issues1193. Adjust style rules or content structure as needed1204. Re-run the formatting script with updated inputs121122## Important Notes123124### Chinese Journal Support (中文期刊支持)125126- Chinese font size names (字号) are mapped: 五号=10.5pt, 小四=12pt, etc.127- Common Chinese fonts: 宋体 (body), 黑体 (headings), 楷体 (abstract), 仿宋128- First-line indent: typically 2em (2 characters)129- Use `ctexart` document class for LaTeX output130- GB/T 7714-2015 citation format with document type identifiers [J], [M], [C], etc.131- Full-width punctuation handling132133### Citation Styles134135Refer to `references/common-citation-styles.md` for detailed formatting rules for:136- APA 7th, GB/T 7714-2015, Vancouver, IEEE, Chicago, MLA137138### Formatting Checklist139140Refer to `references/formatting-elements.md` for the complete list of formatting elements to check and apply.141142### Dependencies143144- `python-docx`: Required for .docx analysis and generation. Install with `pip install python-docx`.145- For LaTeX output: the generated .tex file requires XeLaTeX compilation (for font support).146- Chinese LaTeX documents require: `ctex`, `xeCJK` packages and appropriate Chinese fonts installed.