{"data":{"slug":"github-aipoch-medical-research-skills-scientific-skills-other-chart-style-unifier-df52d2049355","title":"Unify Typography in Word Tables and Charts","summary":"Batch-unify typography (font family, size, italics) for Word table cells and embedded charts to ensure consistent formatting across reports and theses without altering body text. The process generates a final output with unified styling.","url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-other-chart-style-unifier-df52d2049355","json_url":"https:\/\/skillshunter.net\/api\/public\/v1\/skills\/github-aipoch-medical-research-skills-scientific-skills-other-chart-style-unifier-df52d2049355","markdown_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-other-chart-style-unifier-df52d2049355.md","download_url":"https:\/\/skillshunter.net\/skills\/github-aipoch-medical-research-skills-scientific-skills-other-chart-style-unifier-df52d2049355\/download","category":{"slug":"content-editorial","name":"Content & Editorial"},"editor_note":"Ensure Python 3.10+ is installed, and install required dependencies (`python-docx` and `pywin32`) before running the script. For linked charts, unify styles in Excel sources first, then refresh in Word.","instructions":"---\nname: chart-style-unifier\ndescription: 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.\nlicense: MIT\nauthor: AIPOCH\n---\n> **Source**: [https:\/\/github.com\/aipoch\/medical-research-skills](https:\/\/github.com\/aipoch\/medical-research-skills)\n\n# Chart Style Unifier\n\n## When to Use\n\n- Use this skill when you need 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 in a reproducible workflow.\n- Use this skill when a others task needs a packaged method instead of ad-hoc freeform output.\n- Use this skill when the user expects a concrete deliverable, validation step, or file-based result.\n- Use this skill when `scripts\/change_table_font.py` is the most direct path to complete the request.\n- Use this skill when you need the `chart-style-unifier` package behavior rather than a generic answer.\n\n## Key Features\n\n- Scope-focused workflow aligned to: 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.\n- Packaged executable path(s): `scripts\/change_table_font.py` plus 2 additional script(s).\n- Reference material available in `references\/` for task-specific guidance.\n- Structured execution path designed to keep outputs consistent and reviewable.\n\n## Dependencies\n\n- `Python`: `3.10+`. Repository baseline for current packaged skills.\n- `Third-party packages`: `not explicitly version-pinned in this skill package`. Add pinned versions if this skill needs stricter environment control.\n\n## Example Usage\n\n```bash\ncd \"20260316\/scientific-skills\/Others\/chart-style-unifier\"\npython -m py_compile scripts\/change_table_font.py\npython scripts\/change_table_font.py --help\n```\n\nExample run plan:\n1. Confirm the user input, output path, and any required config values.\n2. Edit the in-file `CONFIG` block or documented parameters if the script uses fixed settings.\n3. Run `python scripts\/change_table_font.py` with the validated inputs.\n4. Review the generated output and return the final artifact with any assumptions called out.\n\n## Implementation Details\n\n- Execution model: validate the request, choose the packaged workflow, and produce a bounded deliverable.\n- Input controls: confirm the source files, scope limits, output format, and acceptance criteria before running any script.\n- Primary implementation surface: `scripts\/change_table_font.py` with additional helper scripts under `scripts\/`.\n- Reference guidance: `references\/` contains supporting rules, prompts, or checklists.\n- Parameters to clarify first: input path, output path, scope filters, thresholds, and any domain-specific constraints.\n- Output discipline: keep results reproducible, identify assumptions explicitly, and avoid undocumented side effects.\n\n## 1. When to Use\n\n- You need to normalize **table cell fonts** across a Word document (e.g., thesis tables must use SimSun 10pt).\n- You have many **embedded Word charts** and want consistent typography (title\/axis\/ticks\/legend\/data labels) without manual editing.\n- You are preparing a **final submission\/export (PDF\/print)** and want to eliminate inconsistent chart\/table styling.\n- Your document contains **mixed chart types** (with\/without titles\/legends) and you need a robust batch operation that won\u2019t fail on missing elements.\n- You have **linked charts** and want a safe workflow: unify styles in the Excel sources first, then refresh in Word.\n\n## 2. Key Features\n\n- **Word table-only processing**: updates typography inside **table cells only**; does **not** modify body text styles.\n- **Embedded chart typography normalization (VBA)**:\n  - Chart area base font\n  - Chart title\n  - Axis titles\n  - Tick labels\n  - Legend\n  - Data labels\n- **Config-driven Python workflow**: initialize a run directory, edit a generated `config.json`, then execute.\n- **Run isolation**: outputs are written to `outputs\/runs\/<timestamp>\/` for traceability.\n- **Linked chart guidance**: highlights that Word-side changes can be overwritten by Excel link refresh.\n\n## 3. Dependencies\n\n| Dependency | Version | Purpose | Notes |\n|---|---:|---|---|\n| python-docx | >= 0.8.11 | Modify Word table cell runs\/fonts | Used by `scripts\/change_table_font.py` |\n| pywin32 | >= 306 | Word\/Excel COM automation for chart macros | Windows-only; required for COM-based operations |\n\nInstallation:\n\n```bash\npip install python-docx pywin32\n```\n\nOptional (mirror):\n\n```bash\npip install -i https:\/\/mirrors.aliyun.com\/pypi\/simple python-docx pywin32\n```\n\n## 4. Example Usage\n\n### 4.1 Unify Word Table Cell Fonts (Python, runnable)\n\n```bash\n\n# 1) Initialize a run directory for table processing\npython scripts\/init_run.py --table\n\n# 2) Edit the generated config:\n\n# outputs\/runs\/<timestamp>\/config.json\n\n# 3) Execute the table font unification\npython scripts\/change_table_font.py\n```\n\nExample `outputs\/runs\/<timestamp>\/config.json`:\n\n```json\n{\n  \"target_doc_path\": \"C:\/Users\/xxx\/Desktop\/document.docx\",\n  \"font_name\": \"SimSun\",\n  \"font_size\": 10,\n  \"target_type\": \"table\",\n  \"italic_numbers\": false,\n  \"italic_chinese\": false,\n  \"lowercase_letters\": false,\n  \"status\": \"pending\"\n}\n```\n\n### 4.2 Unify Embedded Chart Typography (Word VBA, runnable)\n\nPaste into **Word VBA Editor** (Alt+F11) and run `NormalizeChartTypography`:\n\n```vba\nOption Explicit\n\nPublic Sub NormalizeChartTypography()\n    Dim fontName As String\n    Dim baseSize As Single, titleSize As Single\n    Dim axisTitleSize As Single, tickLabelSize As Single\n    Dim legendSize As Single, dataLabelSize As Single\n\n    fontName = InputBox(\"Font Name\", \"Unify Chart Fonts\", \"Times New Roman\")\n    baseSize = CSng(InputBox(\"Base Size (ChartArea)\", \"Unify Chart Fonts\", \"9\"))\n    titleSize = CSng(InputBox(\"Chart Title Size\", \"Unify Chart Fonts\", \"11\"))\n    axisTitleSize = CSng(InputBox(\"Axis Title Size\", \"Unify Chart Fonts\", \"9\"))\n    tickLabelSize = CSng(InputBox(\"Tick Label Size\", \"Unify Chart Fonts\", \"8\"))\n    legendSize = CSng(InputBox(\"Legend Size\", \"Unify Chart Fonts\", \"10\"))\n    dataLabelSize = CSng(InputBox(\"Data Label Size\", \"Unify Chart Fonts\", \"8\"))\n\n    Application.ScreenUpdating = False\n\n    Dim ish As InlineShape, shp As Shape\n    For Each ish In ActiveDocument.InlineShapes\n        If ish.HasChart Then\n            ApplyChartTypography ish.Chart, fontName, baseSize, titleSize, axisTitleSize, tickLabelSize, legendSize, dataLabelSize\n        End If\n    Next ish\n\n    For Each shp In ActiveDocument.Shapes\n        If shp.HasChart Then\n            ApplyChartTypography shp.Chart, fontName, baseSize, titleSize, axisTitleSize, tickLabelSize, legendSize, dataLabelSize\n        End If\n    Next shp\n\n    Application.ScreenUpdating = True\nEnd Sub\n\nPrivate Sub ApplyChartTypography(cht As Object, fontName As String, baseSize As Single, _\n                                 titleSize As Single, axisTitleSize As Single, tickLabelSize As Single, _\n                                 legendSize As Single, dataLabelSize As Single)\n    On Error Resume Next\n\n    With cht.ChartArea.Format.TextFrame2.TextRange.Font\n        .Name = fontName\n        .Size = baseSize\n    End With\n\n    If cht.HasTitle Then\n        With cht.ChartTitle.Format.TextFrame2.TextRange.Font\n            .Name = fontName\n            .Size = titleSize\n        End With\n    End If\n\n    If cht.HasLegend Then\n        With cht.Legend.Format.TextFrame2.TextRange.Font\n            .Name = fontName\n            .Size = legendSize\n        End With\n    End If\n\n    Dim axType As Variant, axGroup As Variant, ax As Object\n    For Each axType In Array(1, 2) ' 1=xlCategory, 2=xlValue\n        For Each axGroup In Array(1, 2) ' 1=xlPrimary, 2=xlSecondary\n            Set ax = Nothing\n            Set ax = cht.Axes(axType, axGroup)\n            If Not ax Is Nothing Then\n                ax.TickLabels.Font.Name = fontName\n                ax.TickLabels.Font.Size = tickLabelSize\n                If ax.HasTitle Then\n                    ax.AxisTitle.Format.TextFrame2.TextRange.Font.Name = fontName\n                    ax.AxisTitle.Format.TextFrame2.TextRange.Font.Size = axisTitleSize\n                End If\n            End If\n        Next axGroup\n    Next axType\n\n    Dim s As Object\n    For Each s In cht.SeriesCollection\n        If s.HasDataLabels Then\n            s.DataLabels.Font.Name = fontName\n            s.DataLabels.Font.Size = dataLabelSize\n        End If\n    Next s\n\n    On Error GoTo 0\nEnd Sub\n```\n\n### 4.3 Unify Linked Chart Source Files (Excel VBA, runnable)\n\nRun in Excel on the **source workbook(s)** before refreshing links in Word:\n\n```vba\nOption Explicit\n\nPublic Sub NormalizeLinkedChartTypography()\n    Dim fontName As String\n    Dim baseSize As Single, titleSize As Single\n    Dim axisTitleSize As Single, tickLabelSize As Single\n    Dim legendSize As Single, dataLabelSize As Single\n\n    fontName = InputBox(\"Font Name\", \"Unify Chart Fonts\", \"Times New Roman\")\n    baseSize = CSng(InputBox(\"Base Size (ChartArea)\", \"Unify Chart Fonts\", \"9\"))\n    titleSize = CSng(InputBox(\"Chart Title Size\", \"Unify Chart Fonts\", \"11\"))\n    axisTitleSize = CSng(InputBox(\"Axis Title Size\", \"Unify Chart Fonts\", \"9\"))\n    tickLabelSize = CSng(InputBox(\"Tick Label Size\", \"Unify Chart Fonts\", \"8\"))\n    legendSize = CSng(InputBox(\"Legend Size\", \"Unify Chart Fonts\", \"10\"))\n    dataLabelSize = CSng(InputBox(\"Data Label Size\", \"Unify Chart Fonts\", \"8\"))\n\n    Application.ScreenUpdating = False\n\n    Dim ws As Worksheet, co As ChartObject\n    For Each ws In ActiveWorkbook.Worksheets\n        For Each co In ws.ChartObjects\n            ApplyChartTypography co.Chart, fontName, baseSize, titleSize, axisTitleSize, tickLabelSize, legendSize, dataLabelSize\n        Next co\n    Next ws\n\n    Application.ScreenUpdating = True\nEnd Sub\n```\n\n## 5. Implementation Details\n\n### 5.1 Processing Scope and Constraints\n\n- **Allowed input**: only the Word document path explicitly provided by the user (`target_doc_path`).\n- **Output directory**: `outputs\/runs\/<timestamp>\/`.\n- **Disallowed access**: parent traversal (`..\/`) and sensitive system directories.\n- **No network usage**: local-only operations; no external APIs; no credentials.\n\n### 5.2 Python Table Unification Logic (Conceptual)\n\n- Reads `outputs\/runs\/<timestamp>\/config.json`.\n- Opens the `.docx` and iterates **tables \u2192 rows \u2192 cells \u2192 paragraphs \u2192 runs**.\n- Applies:\n  - `font_name` and `font_size` to runs inside table cells.\n  - Optional toggles (if enabled in config): italics rules for numbers\/Chinese\/lowercase letters.\n- Saves results into the run output directory (implementation-dependent).\n\n### 5.3 Chart Typography Tokens (What Gets Normalized)\n\nRecommended parameter mapping (used by the VBA macros):\n\n| Element | VBA Target | Parameter |\n|---|---|---|\n| Chart area base | `Chart.ChartArea` | `baseSize` |\n| Chart title | `Chart.ChartTitle` | `titleSize` |\n| Axis titles | `Axes(...).AxisTitle` | `axisTitleSize` |\n| Tick labels | `Axes(...).TickLabels` | `tickLabelSize` |\n| Legend | `Chart.Legend` | `legendSize` |\n| Data labels | `Series.DataLabels` | `dataLabelSize` |\n\n### 5.4 Linked Charts: Overwrite Behavior\n\n- If a chart in Word is **linked** to Excel, refreshing the link can overwrite Word-side formatting.\n- Safe workflow:\n  1. Normalize chart typography in the **Excel source files** (Excel VBA).\n  2. Refresh\/update links in Word.\n  3. Only use Word VBA for charts that are truly **embedded** (not linked).\n\n### 5.5 Repository Entry Points\n\n| Script | Purpose |\n|---|---|\n| `scripts\/init_run.py` | Create `outputs\/runs\/<timestamp>\/` and a starter `config.json` |\n| `scripts\/generate_style_pack.py` | Generate matplotlib\/plotly style packs from a unified config |\n| `scripts\/change_table_font.py` | Apply table cell font normalization based on `config.json` |\n\n### 5.6 References\n\n- Test cases: `tests\/test_table_font.py`\n- Evaluation checklist: `references\/style-apply-checklist.md`\n- Style specification template: `references\/style-spec-template.md`\n","use_cases":["Normalize table cell fonts across a Word document (e.g., thesis tables must use SimSun 10pt).","Standardize typography for embedded Word charts (title\/axis\/ticks\/legend\/data labels) without manual editing.","Prepare a final submission\/export (PDF\/print) with consistent chart\/table styling."],"limitations":[],"compatibility":[],"setup_tip":null,"sample_input":null,"sample_output":null,"source_url":"https:\/\/github.com\/aipoch\/medical-research-skills\/blob\/686e09dfdb45d9fa1a08664f06bb93769b3c9d91\/scientific-skills\/Other\/chart-style-unifier\/SKILL.md","source_commit":"686e09dfdb45d9fa1a08664f06bb93769b3c9d91","license":"MIT","version":null,"listing_approved_at":"2026-11-26","created_at":"2026-11-24T14:25:31.000000Z","updated_at":"2026-11-26T09:24:51.000000Z","seo_title":"Unify Word Table and Chart Fonts","seo_description":"Automate consistent typography across Word tables and embedded charts with batch processing. Ideal for reports and theses.","seo_keywords":["unify word table fonts","standardize chart typography","batch format word tables","automate chart styling","normalize document fonts"]}}