| name | lab-report |
| description | Use this skill when the user asks to write, generate, or help with a university lab report (实验报告), physics experiment report (物理实验报告), circuit experiment report (电路实验报告), or any academic experiment report. Triggers include: "写实验报告", "实验报告", "lab report", "experiment report", "帮我写报告", or when the user provides experiment data, textbook content, or PPT slides for report generation. This skill MUST be used whenever the user mentions 实验报告 in any context.
|
| version | 1.0.0 |
| allowed-tools | ["Read","Write","Bash","Glob","Grep","Edit","Agent","AskUserQuestion"] |
University Lab Report Writer (大学实验报告写作助手)
Overview
This skill generates university-level lab reports as .docx Word files. It reads the user's experiment materials (PPT slides, textbook photos, handwritten data, templates), processes data with Python, and outputs a properly formatted Word document with OMML formulas, embedded images, data tables, charts, and error analysis.
Core Principles
1. NEVER Fabricate Content
- Do NOT invent experimental procedures, data, phenomena, or results.
- If any detail is uncertain (e.g., handwritten data is hard to read, experimental steps are unclear), you MUST use
AskUserQuestion to confirm with the user before writing.
- Only write content directly supported by: the textbook, PPT slides, user-provided data, or user confirmation.
2. Follow the User's Template
- Use the user's provided Word template to match their school's formatting requirements.
- Preserve fonts, sizes, margins, spacing, and header layout from the template.
- If no template is provided, ask the user for one or use the generic format.
3. Be Rigorous and Academic
- Use formal, academic Chinese (学术性中文).
- All formulas must use Word-native OMML format with proper numbering.
- All figures must have numbered captions and be referenced in text.
- Data tables must have proper headers with units.
- Error analysis must be thorough with quantitative calculations.
Report Structure (报告结构)
The standard report follows a 6-section structure (思考题 only if user requests):
Header Section
- University logo (extracted from user's template)
- Title (e.g., "大学物理实验(一)实验报告")
- Experiment name
- Student info: class, name, group number, date, instructor, lab partners
Section 一、实验目的 (Experimental Purpose)
- List all objectives clearly and completely
- Source: PPT slides + textbook
Section 二、实验仪器 (Experimental Equipment)
- List ALL equipment with model numbers if available
- Include an equipment photo if available (from PPT)
Section 三、实验原理 (Experimental Principles)
This is a key section — must be detailed and thorough, NEVER overly brief.
Three mandatory components:
- Text description: Complete explanation, organized in numbered sub-sections
- OMML Formulas: All relevant formulas numbered (公式1, 公式2...) and referenced in text
- Diagrams: Principle diagrams and circuit diagrams with numbered captions
Source: primarily from textbook, supplemented by PPT. Follow the depth of the textbook — do not skip intermediate derivations.
Section 四、实验内容及操作步骤 (Procedure)
- Detailed step-by-step instructions from PPT/textbook
- Must reflect the actual experiment procedure
- If unsure about any step, ASK the user
Section 五、数据记录及数据处理 (Data & Analysis)
This is the highest-weighted section. Must include:
- Raw data tables: Well-formatted with headers and units
- Detailed calculations: Show formula → substitution → result for at least one complete example. Do NOT just write final results.
- Charts/Graphs: Generated with matplotlib, properly labeled axes
- Error analysis: 3 error sources, each with a bold sub-heading + detailed explanation of why it causes error and its effect direction. Include relative error calculation.
Section 六、实验总结 (Summary)
- One paragraph summarizing the experiment, results, and insights
Section 七、思考题 (Discussion Questions) — ONLY if user explicitly requests
- Default: do NOT include this section
- Only add when user says "要写思考题" or similar
Formatting Specifications (格式要求)
These are default values — always defer to the user's template if provided.
| Element | Font | Size | Notes |
|---|
| Document title | 宋体 | 16-18pt | With university logo |
| Experiment name | 宋体 | 15pt (小三) | Centered, bold |
| Section headings (一、二、...) | 宋体 | 14pt (四号) | Bold |
| Body text | 宋体 | 12pt (小四) | Single line spacing, first-line indent 0.74cm |
| Table text | 宋体 | 11pt | Centered in cells |
| Figure captions | 宋体 | 10pt | Centered below figure |
OMML Formula Requirements
- All formulas MUST use Word-native OMML format (Office Math Markup Language)
- Use
m:oMathPara for centered display formulas, m:oMath for inline formulas
- Font: Cambria Math, size: 12pt (w:sz="24")
- Variables in italic (default), numbers/operators in upright (
m:sty m:val="p")
- See
references/omml-formulas.md for code snippets
Image Requirements
- Images extracted from PPT (unzip .pptx → ppt/media/)
- Centered, appropriate width (principle diagrams: 3-4 inches, data charts: 5 inches)
- Numbered caption below each image (e.g., "图1 描述文字")
- Must be referenced in text (e.g., "如图1所示")
Workflow (工作流程)
Step 1: Gather Materials
Check what the user has provided. Ask for missing items:
Step 2: Read and Extract All Materials
1. Read template → understand header format, font requirements, structure
2. Extract PPT → unzip .pptx, read text content, get images from ppt/media/
3. Read textbook photos → understand principles, formulas, procedures
4. Read data photos → identify all measurements
Step 3: Confirm Uncertainties
Before writing, use AskUserQuestion to confirm:
- Any handwritten data that's hard to read
- Whether to include thought questions (default: NO)
- Any missing information
Step 4: Process Data
Use Python with matplotlib (Agg backend) to:
- Perform all calculations
- Generate charts/graphs
- Calculate errors
Step 5: Generate .docx Report
Use python-docx + lxml to generate the complete report:
- Extract logo from template (unzip → word/media/)
- Build header section matching template format
- Write all sections with OMML formulas
- Embed images (from PPT + matplotlib charts)
- Format tables with Table Grid style
Step 6: Verify Output
- Use markitdown to extract and review text content
- Check all sections are present
- Verify formulas rendered correctly
- Confirm image count matches expectations
Technical Implementation Notes
Extracting PPT Content
import zipfile
with zipfile.ZipFile('slides.pptx', 'r') as z:
z.extractall('ppt_extracted')
from pptx import Presentation
prs = Presentation('slides.pptx')
for slide in prs.slides:
for shape in slide.shapes:
if shape.has_text_frame:
print(shape.text_frame.text)
OMML Formula Construction
from lxml import etree
from docx.oxml.ns import qn
def make_fraction(num_elements, den_elements):
f = etree.SubElement(etree.Element('dummy'), qn('m:f'))
num = etree.SubElement(f, qn('m:num'))
for el in num_elements: num.append(el)
den = etree.SubElement(f, qn('m:den'))
for el in den_elements: den.append(el)
return f
See references/omml-formulas.md for complete OMML helper functions.
python-docx Key Patterns
from docx import Document
from docx.shared import Pt, Cm, Inches
from docx.enum.text import WD_ALIGN_PARAGRAPH
run.font.name = '宋体'
run._element.rPr.rFonts.set(qn('w:eastAsia'), '宋体')
paragraph.paragraph_format.first_line_indent = Cm(0.74)
Writing Style Guidelines
- Language: Formal academic Chinese (学术中文)
- Tone: Objective, precise, rigorous
- Person: Third person or impersonal ("将仪器放置于平台上" not "我把仪器放上去")
- Formulas: Numbered and referenced in text (如公式(1)所示)
- Figures: Numbered with captions, referenced in text (如图1所示)
- Data: Show complete calculation process, not just results
Checklist Before Delivery