Batch-unify typography (font family, size, italics) for Word table cells and embedded charts; use when you need consistent formatting across theses/reports without changing body text.
66
80%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
View guide
Passed
No findings from the security scan
scripts/change_table_font.py is the most direct path to complete the request.chart-style-unifier package behavior rather than a generic answer.scripts/change_table_font.py plus 2 additional script(s).references/ for task-specific guidance.Python: 3.10+. Repository baseline for current packaged skills.Third-party packages: not explicitly version-pinned in this skill package. Add pinned versions if this skill needs stricter environment control.cd "20260316/scientific-skills/Others/chart-style-unifier"
python -m py_compile scripts/change_table_font.py
python scripts/change_table_font.py --helpExample run plan:
CONFIG block or documented parameters if the script uses fixed settings.python scripts/change_table_font.py with the validated inputs.scripts/change_table_font.py with additional helper scripts under scripts/.references/ contains supporting rules, prompts, or checklists.config.json, then execute.outputs/runs/<timestamp>/ for traceability.| Dependency | Version | Purpose | Notes |
|---|---|---|---|
| python-docx | >= 0.8.11 | Modify Word table cell runs/fonts | Used by scripts/change_table_font.py |
| pywin32 | >= 306 | Word/Excel COM automation for chart macros | Windows-only; required for COM-based operations |
Installation:
pip install python-docx pywin32Optional (mirror):
pip install -i https://mirrors.aliyun.com/pypi/simple python-docx pywin32# 1) Initialize a run directory for table processing
python scripts/init_run.py --table
# 2) Edit the generated config:
# outputs/runs/<timestamp>/config.json
# 3) Execute the table font unification
python scripts/change_table_font.pyExample outputs/runs/<timestamp>/config.json:
{
"target_doc_path": "C:/Users/xxx/Desktop/document.docx",
"font_name": "SimSun",
"font_size": 10,
"target_type": "table",
"italic_numbers": false,
"italic_chinese": false,
"lowercase_letters": false,
"status": "pending"
}Paste into Word VBA Editor (Alt+F11) and run NormalizeChartTypography:
Option Explicit
Public Sub NormalizeChartTypography()
Dim fontName As String
Dim baseSize As Single, titleSize As Single
Dim axisTitleSize As Single, tickLabelSize As Single
Dim legendSize As Single, dataLabelSize As Single
fontName = InputBox("Font Name", "Unify Chart Fonts", "Times New Roman")
baseSize = CSng(InputBox("Base Size (ChartArea)", "Unify Chart Fonts", "9"))
titleSize = CSng(InputBox("Chart Title Size", "Unify Chart Fonts", "11"))
axisTitleSize = CSng(InputBox("Axis Title Size", "Unify Chart Fonts", "9"))
tickLabelSize = CSng(InputBox("Tick Label Size", "Unify Chart Fonts", "8"))
legendSize = CSng(InputBox("Legend Size", "Unify Chart Fonts", "10"))
dataLabelSize = CSng(InputBox("Data Label Size", "Unify Chart Fonts", "8"))
Application.ScreenUpdating = False
Dim ish As InlineShape, shp As Shape
For Each ish In ActiveDocument.InlineShapes
If ish.HasChart Then
ApplyChartTypography ish.Chart, fontName, baseSize, titleSize, axisTitleSize, tickLabelSize, legendSize, dataLabelSize
End If
Next ish
For Each shp In ActiveDocument.Shapes
If shp.HasChart Then
ApplyChartTypography shp.Chart, fontName, baseSize, titleSize, axisTitleSize, tickLabelSize, legendSize, dataLabelSize
End If
Next shp
Application.ScreenUpdating = True
End Sub
Private Sub ApplyChartTypography(cht As Object, fontName As String, baseSize As Single, _
titleSize As Single, axisTitleSize As Single, tickLabelSize As Single, _
legendSize As Single, dataLabelSize As Single)
On Error Resume Next
With cht.ChartArea.Format.TextFrame2.TextRange.Font
.Name = fontName
.Size = baseSize
End With
If cht.HasTitle Then
With cht.ChartTitle.Format.TextFrame2.TextRange.Font
.Name = fontName
.Size = titleSize
End With
End If
If cht.HasLegend Then
With cht.Legend.Format.TextFrame2.TextRange.Font
.Name = fontName
.Size = legendSize
End With
End If
Dim axType As Variant, axGroup As Variant, ax As Object
For Each axType In Array(1, 2) ' 1=xlCategory, 2=xlValue
For Each axGroup In Array(1, 2) ' 1=xlPrimary, 2=xlSecondary
Set ax = Nothing
Set ax = cht.Axes(axType, axGroup)
If Not ax Is Nothing Then
ax.TickLabels.Font.Name = fontName
ax.TickLabels.Font.Size = tickLabelSize
If ax.HasTitle Then
ax.AxisTitle.Format.TextFrame2.TextRange.Font.Name = fontName
ax.AxisTitle.Format.TextFrame2.TextRange.Font.Size = axisTitleSize
End If
End If
Next axGroup
Next axType
Dim s As Object
For Each s In cht.SeriesCollection
If s.HasDataLabels Then
s.DataLabels.Font.Name = fontName
s.DataLabels.Font.Size = dataLabelSize
End If
Next s
On Error GoTo 0
End SubRun in Excel on the source workbook(s) before refreshing links in Word:
Option Explicit
Public Sub NormalizeLinkedChartTypography()
Dim fontName As String
Dim baseSize As Single, titleSize As Single
Dim axisTitleSize As Single, tickLabelSize As Single
Dim legendSize As Single, dataLabelSize As Single
fontName = InputBox("Font Name", "Unify Chart Fonts", "Times New Roman")
baseSize = CSng(InputBox("Base Size (ChartArea)", "Unify Chart Fonts", "9"))
titleSize = CSng(InputBox("Chart Title Size", "Unify Chart Fonts", "11"))
axisTitleSize = CSng(InputBox("Axis Title Size", "Unify Chart Fonts", "9"))
tickLabelSize = CSng(InputBox("Tick Label Size", "Unify Chart Fonts", "8"))
legendSize = CSng(InputBox("Legend Size", "Unify Chart Fonts", "10"))
dataLabelSize = CSng(InputBox("Data Label Size", "Unify Chart Fonts", "8"))
Application.ScreenUpdating = False
Dim ws As Worksheet, co As ChartObject
For Each ws In ActiveWorkbook.Worksheets
For Each co In ws.ChartObjects
ApplyChartTypography co.Chart, fontName, baseSize, titleSize, axisTitleSize, tickLabelSize, legendSize, dataLabelSize
Next co
Next ws
Application.ScreenUpdating = True
End Subtarget_doc_path).outputs/runs/<timestamp>/.../) and sensitive system directories.outputs/runs/<timestamp>/config.json..docx and iterates tables → rows → cells → paragraphs → runs.font_name and font_size to runs inside table cells.Recommended parameter mapping (used by the VBA macros):
| Element | VBA Target | Parameter |
|---|---|---|
| Chart area base | Chart.ChartArea | baseSize |
| Chart title | Chart.ChartTitle | titleSize |
| Axis titles | Axes(...).AxisTitle | axisTitleSize |
| Tick labels | Axes(...).TickLabels | tickLabelSize |
| Legend | Chart.Legend | legendSize |
| Data labels | Series.DataLabels | dataLabelSize |
| Script | Purpose |
|---|---|
scripts/init_run.py | Create outputs/runs/<timestamp>/ and a starter config.json |
scripts/generate_style_pack.py | Generate matplotlib/plotly style packs from a unified config |
scripts/change_table_font.py | Apply table cell font normalization based on config.json |
tests/test_table_font.pyreferences/style-apply-checklist.mdreferences/style-spec-template.mdf5ef65b
If you maintain this skill, you can claim it as your own. Once claimed, you can manage eval scenarios, bundle related skills, attach documentation or rules, and ensure cross-agent compatibility.