~/muscles-ref-card/generate_pdf.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm
from reportlab.platypus import (
SimpleDocTemplate, Table, TableStyle, Paragraph, Spacer,
HRFlowable, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT
from reportlab.platypus import PageBreak
OUTPUT = "/home/daytona/workspace/muscles-ref-card/Muscles_Head_Neck_Face_QuickRef.pdf"
# ── Colour palette ────────────────────────────────────────────────
C_DARK_BLUE = colors.HexColor("#1a3a5c")
C_MID_BLUE = colors.HexColor("#2b6cb0")
C_LIGHT_BLUE = colors.HexColor("#ebf4ff")
C_ACCENT = colors.HexColor("#e53e3e")
C_GOLD = colors.HexColor("#d4a017")
C_SECTION_BG = [
colors.HexColor("#e8f0fe"), # blue-ish – face expression
colors.HexColor("#fef3e8"), # orange-ish – mastication
colors.HexColor("#e8fef0"), # green-ish – extraocular
colors.HexColor("#fde8f0"), # pink-ish – tongue
colors.HexColor("#f0e8fe"), # purple-ish – pharynx/palate
colors.HexColor("#e8fefe"), # teal-ish – neck
]
C_HDR = [
colors.HexColor("#1a3a5c"),
colors.HexColor("#7b3a10"),
colors.HexColor("#1a5c3a"),
colors.HexColor("#5c1a3a"),
colors.HexColor("#3a1a5c"),
colors.HexColor("#1a5c5c"),
]
C_WHITE = colors.white
doc = SimpleDocTemplate(
OUTPUT,
pagesize=A4,
leftMargin=10*mm, rightMargin=10*mm,
topMargin=12*mm, bottomMargin=12*mm,
title="Muscles of Head, Neck & Face – Quick Reference Card",
author="Orris Medical"
)
styles = getSampleStyleSheet()
# Custom styles
title_style = ParagraphStyle(
"CardTitle", fontSize=18, textColor=C_WHITE,
alignment=TA_CENTER, fontName="Helvetica-Bold", leading=22
)
subtitle_style = ParagraphStyle(
"CardSubtitle", fontSize=9, textColor=C_LIGHT_BLUE,
alignment=TA_CENTER, fontName="Helvetica", leading=12
)
section_style = ParagraphStyle(
"SectionTitle", fontSize=11, textColor=C_WHITE,
alignment=TA_LEFT, fontName="Helvetica-Bold", leading=14,
leftIndent=4
)
cell_bold = ParagraphStyle(
"CellBold", fontSize=7, fontName="Helvetica-Bold",
textColor=C_DARK_BLUE, leading=9, wordWrap='LTR'
)
cell_normal = ParagraphStyle(
"CellNormal", fontSize=6.5, fontName="Helvetica",
textColor=colors.HexColor("#222222"), leading=8.5, wordWrap='LTR'
)
cell_nerve = ParagraphStyle(
"CellNerve", fontSize=6.5, fontName="Helvetica-Bold",
textColor=C_ACCENT, leading=8.5, wordWrap='LTR'
)
note_style = ParagraphStyle(
"Note", fontSize=7, fontName="Helvetica-Oblique",
textColor=colors.HexColor("#555555"), leading=9
)
footer_style = ParagraphStyle(
"Footer", fontSize=7, fontName="Helvetica",
textColor=colors.HexColor("#888888"), alignment=TA_CENTER, leading=9
)
def B(text): return Paragraph(text, cell_bold)
def N(text): return Paragraph(text, cell_normal)
def NR(text): return Paragraph(text, cell_nerve)
def note(text): return Paragraph(text, note_style)
# ── Column widths for main table (A4 minus margins = 190mm) ───────
W = 190 * mm
COL = [32*mm, 35*mm, 35*mm, 40*mm, 28*mm] # muscle | origin | insertion | action | nerve
COL_HDR = ["Muscle", "Origin", "Insertion", "Action(s)", "Nerve Supply"]
def make_table(rows, bg, hdr_bg):
data = [[B(h) for h in COL_HDR]]
for r in rows:
data.append([
B(r[0]),
N(r[1]),
N(r[2]),
N(r[3]),
NR(r[4]),
])
t = Table(data, colWidths=COL, repeatRows=1)
style_cmds = [
("BACKGROUND", (0,0), (-1,0), hdr_bg),
("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
("FONTNAME", (0,0), (-1,0), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,0), 7.5),
("ROWBACKGROUNDS",(0,1), (-1,-1), [bg, C_WHITE]),
("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#cccccc")),
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
("LEFTPADDING", (0,0), (-1,-1), 3),
("RIGHTPADDING", (0,0), (-1,-1), 3),
]
t.setStyle(TableStyle(style_cmds))
return t
def section_header(text, bg):
data = [[Paragraph(text, section_style)]]
t = Table(data, colWidths=[W])
t.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), bg),
("TOPPADDING", (0,0), (-1,-1), 4),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
("LEFTPADDING", (0,0), (-1,-1), 6),
]))
return t
# ════════════════════════════════════════════════════════════════
# DATA
# ════════════════════════════════════════════════════════════════
sec1_facial = [
# scalp/forehead
("Frontalis",
"Galea aponeurotica (anterior)",
"Skin of forehead, eyebrows; blends with procerus & corrugator",
"Raises eyebrows; wrinkles forehead horizontally",
"CN VII – Temporal br."),
("Occipitalis",
"Superior nuchal line (lateral); mastoid process",
"Galea aponeurotica (posterior)",
"Pulls scalp backward",
"CN VII – Posterior auricular br."),
("Corrugator supercilii",
"Medial superciliary arch (frontal bone)",
"Skin of medial eyebrow",
"Draws brow medially & down; vertical glabellar lines ('scowl')",
"CN VII – Temporal br."),
("Procerus",
"Fascia over lower nasal bone & upper lateral nasal cartilage",
"Skin between eyebrows",
"Depresses medial brow; creates transverse nasal lines ('bunny lines')",
"CN VII – Zygomatic br."),
# eye
("Orbicularis oculi\n(orbital part)",
"Medial orbital margin; medial palpebral ligament; lacrimal bone",
"Encircles orbit; returns to origin",
"Forceful tight eye closure",
"CN VII – Temporal + Zygomatic br."),
("Orbicularis oculi\n(palpebral part)",
"Medial palpebral ligament",
"Lateral palpebral raphe",
"Gentle eye closure; blinking; aids tear drainage",
"CN VII – Temporal (upper) + Zygomatic (lower)"),
# nose
("Nasalis (alar part)",
"Maxilla (above lateral incisor)",
"Alar cartilage & skin of nose",
"Flares nostrils; dilates naris",
"CN VII – Zygomatic br."),
("Nasalis (transverse)",
"Maxilla (above canine)",
"Aponeurosis across nasal bridge",
"Compresses nostrils",
"CN VII – Buccal br."),
("Depressor septi nasi",
"Maxilla (above central incisor)",
"Nasal septum & alar cartilage",
"Pulls columella and nasal tip downward",
"CN VII – Buccal br."),
# mouth/cheek
("Zygomaticus major",
"Zygomatic bone (lateral surface)",
"Modiolus (angle of mouth)",
"Draws angle of mouth upward & laterally (smiling)",
"CN VII – Zygomatic + Buccal br."),
("Zygomaticus minor",
"Zygomatic bone (anterior surface)",
"Upper lip (lateral orbicularis)",
"Elevates upper lip; deepens nasolabial fold",
"CN VII – Buccal br."),
("Levator labii\nsuperioris",
"Infraorbital margin of maxilla",
"Upper lip (orbicularis oris)",
"Elevates upper lip; deepens nasolabial fold",
"CN VII – Buccal br."),
("Levator labii sup.\nalaeque nasi",
"Frontal process of maxilla",
"Upper lip & alar cartilage",
"Elevates upper lip; flares nostril",
"CN VII – Buccal br."),
("Levator anguli oris",
"Canine fossa of maxilla (below infra-orbital foramen)",
"Modiolus (angle of mouth)",
"Raises angle of mouth (smile)",
"CN VII – Zygomatic + Buccal br."),
("Buccinator",
"Alveolar processes of maxilla & mandible; pterygomandibular raphe",
"Modiolus; blends into orbicularis oris",
"Compresses cheek; keeps food between teeth; aids whistling/blowing",
"CN VII – Buccal br."),
("Risorius",
"Parotid fascia; platysma",
"Modiolus / skin at angle of mouth",
"Retracts angle of mouth laterally (forced grin/dimple)",
"CN VII – Buccal + Marginal mandibular br."),
("Orbicularis oris",
"Modiolus & maxilla/mandible near midline (no bony origin; mostly muscular)",
"Mucous membrane; skin of lips",
"Closes & purses lips; puckering; kissing; aids speech",
"CN VII – Buccal + Marginal mandibular br."),
# lower lip/chin
("Depressor labii\ninferioris",
"Mandible (between symphysis & mental foramen)",
"Skin and mucosa of lower lip",
"Depresses and everts lower lip",
"CN VII – Marginal mandibular br."),
("Depressor anguli\noris",
"Oblique line of mandible",
"Modiolus (angle of mouth)",
"Depresses corner of mouth (frowning)",
"CN VII – Marginal mandibular br."),
("Mentalis",
"Incisive fossa of mandible",
"Skin of chin",
"Everts lower lip; raises & wrinkles chin skin ('pouting')",
"CN VII – Marginal mandibular br."),
("Platysma",
"Fascia over pectoralis major & deltoid",
"Mandible (lower border); skin of cheek & mouth angle; blends with depressor anguli oris",
"Depresses mandible & lower lip; tenses neck skin; draws lower face downward",
"CN VII – Cervical br."),
]
sec2_mastication = [
("Masseter",
"Zygomatic arch (lower border & medial surface)",
"Lateral surface of mandibular ramus & angle",
"Elevates mandible (closes jaw); clenching; slight protrusion",
"CN V3 – Masseteric n."),
("Temporalis",
"Temporal fossa (floor) & temporal fascia",
"Coronoid process & anterior ramus of mandible",
"Elevates mandible; posterior fibers retract mandible",
"CN V3 – Deep temporal nn."),
("Medial pterygoid",
"Medial surface of lateral pterygoid plate; pterygoid fossa; pyramidal process of palatine bone",
"Medial surface of mandibular angle & ramus",
"Elevates mandible; assists in protrusion & lateral chewing movements",
"CN V3 – Medial pterygoid n."),
("Lateral pterygoid\n(superior head)",
"Infratemporal surface of greater wing of sphenoid",
"Articular disc & capsule of TMJ",
"Stabilises articular disc; involved in mouth opening & lateral jaw movements",
"CN V3 – Lateral pterygoid n."),
("Lateral pterygoid\n(inferior head)",
"Lateral surface of lateral pterygoid plate",
"Pterygoid fovea (neck of mandibular condyle)",
"Protrudes mandible; depresses (opens) jaw; lateral chewing",
"CN V3 – Lateral pterygoid n."),
]
sec3_extraocular = [
("Superior rectus",
"Common tendinous ring (annulus of Zinn)",
"Sclera (superior surface, anterior to equator)",
"Elevates eyeball; intorsion; adduction",
"CN III – Oculomotor (superior div.)"),
("Inferior rectus",
"Common tendinous ring",
"Sclera (inferior surface)",
"Depresses eyeball; extorsion; adduction",
"CN III – Oculomotor (inferior div.)"),
("Medial rectus",
"Common tendinous ring",
"Sclera (medial surface)",
"Adducts eyeball (moves toward nose)",
"CN III – Oculomotor (inferior div.)"),
("Lateral rectus",
"Common tendinous ring",
"Sclera (lateral surface)",
"Abducts eyeball (moves toward ear)",
"CN VI – Abducens n."),
("Superior oblique",
"Body of sphenoid (above optic canal)",
"Sclera (posterolateral, via trochlea pulley)",
"Depresses; intorts; abducts eyeball",
"CN IV – Trochlear n."),
("Inferior oblique",
"Orbital floor (lateral to nasolacrimal groove)",
"Sclera (posterolateral surface)",
"Elevates; extorts; abducts eyeball",
"CN III – Oculomotor (inferior div.)"),
("Levator palpebrae\nsuperioris",
"Lesser wing of sphenoid (above optic canal)",
"Tarsal plate of upper eyelid; skin of upper lid",
"Raises upper eyelid",
"CN III (main); Sympathetic n. (superior tarsal / Müller's m.)"),
]
sec4_tongue = [
("Genioglossus",
"Mental spine (superior genial tubercle) of mandible",
"Dorsum of tongue (fan-shaped); body of hyoid",
"Protrudes tongue; depresses centre; retracts tip",
"CN XII – Hypoglossal n."),
("Hyoglossus",
"Body & greater horn of hyoid bone",
"Lateral sides of tongue",
"Depresses and retracts tongue",
"CN XII – Hypoglossal n."),
("Styloglossus",
"Styloid process (anterior surface); stylohyoid ligament",
"Lateral tongue (merges with hyoglossus)",
"Retracts and elevates sides of tongue",
"CN XII – Hypoglossal n."),
("Palatoglossus",
"Palatine aponeurosis (soft palate undersurface)",
"Lateral tongue",
"Elevates tongue; narrows oropharyngeal isthmus",
"CN X via pharyngeal plexus"),
("Intrinsic muscles\n(superior & inferior longitudinal, transverse, vertical)",
"No bony attachments (within tongue substance)",
"Within tongue substance",
"Change shape: shorten/lengthen, widen/narrow, curl tip",
"CN XII – Hypoglossal n."),
]
sec5_pharynx = [
# constrictors
("Superior constrictor",
"Pterygoid hamulus; pterygomandibular raphe; mylohyoid line of mandible; side of tongue",
"Pharyngeal tubercle of occipital bone; pharyngeal raphe (posterior midline)",
"Constricts upper pharynx during swallowing",
"CN X + CN IX via pharyngeal plexus"),
("Middle constrictor",
"Greater & lesser horns of hyoid; stylohyoid ligament",
"Pharyngeal raphe (posterior midline)",
"Constricts mid-pharynx during swallowing",
"CN X via pharyngeal plexus"),
("Inferior constrictor",
"Oblique line of thyroid cartilage; lateral surface of cricoid cartilage",
"Pharyngeal raphe (posterior midline)",
"Constricts lower pharynx; cricopharyngeus acts as UES",
"CN X via pharyngeal plexus; RLN (cricopharyngeus)"),
("Stylopharyngeus",
"Styloid process (medial surface, base)",
"Posterior border of thyroid cartilage; blends with constrictors",
"Elevates and widens pharynx & larynx during swallowing",
"CN IX – Glossopharyngeal n. (unique!)"),
("Palatopharyngeus",
"Palatine aponeurosis (hard palate)",
"Posterior border of thyroid cartilage; pharyngeal wall",
"Elevates larynx & pharynx; closes oropharynx",
"CN X via pharyngeal plexus"),
# palate
("Levator veli palatini",
"Petrous part of temporal bone; medial auditory tube cartilage",
"Palatine aponeurosis",
"Elevates soft palate to close off nasopharynx during swallowing/speech",
"CN X via pharyngeal plexus"),
("Tensor veli palatini",
"Scaphoid fossa of sphenoid; lateral auditory tube cartilage",
"Palatine aponeurosis (hooks around pterygoid hamulus)",
"Tenses soft palate; opens Eustachian tube",
"CN V3 – Medial pterygoid n. (only palatal muscle NOT CN X)"),
("Musculus uvulae",
"Posterior nasal spine; palatine aponeurosis",
"Mucosa of uvula",
"Shortens and elevates uvula",
"CN X via pharyngeal plexus"),
]
sec6_neck = [
# superficial
("Sternocleidomastoid\n(SCM)",
"Sternal head: manubrium sterni (anterior surface)\nClavicular head: medial 1/3 of clavicle",
"Mastoid process; lateral superior nuchal line",
"Unilateral: ipsilateral neck tilt + contralateral face rotation. Bilateral: neck flexion; raises thorax in forced inspiration",
"CN XI – Accessory n. + C2–C3 (proprioception)"),
("Trapezius\n(upper fibers)",
"External occipital protuberance; medial superior nuchal line; ligamentum nuchae; C7–T12 spinous processes",
"Lateral 1/3 of clavicle; acromion; spine of scapula",
"Elevates & retracts scapula; extends & rotates head/neck to opposite side",
"CN XI – Accessory n. + C3–C4"),
# suprahyoid
("Digastric\n(anterior belly)",
"Digastric fossa of mandible (inner surface)",
"Intermediate tendon (attached to hyoid via fibrous sling)",
"Depresses mandible; elevates hyoid during swallowing",
"CN V3 – Mylohyoid n."),
("Digastric\n(posterior belly)",
"Mastoid notch (medial to mastoid process)",
"Intermediate tendon",
"Elevates and retracts hyoid; opens jaw",
"CN VII – Facial n. (digastric br.)"),
("Mylohyoid",
"Mylohyoid line of mandible",
"Hyoid bone (body); median raphe meeting partner muscle",
"Elevates floor of mouth & tongue; elevates hyoid; depresses mandible",
"CN V3 – Mylohyoid n."),
("Geniohyoid",
"Inferior genial tubercle of mandible",
"Body of hyoid bone",
"Elevates & protracts hyoid; depresses mandible; widens pharynx",
"C1 via CN XII"),
("Stylohyoid",
"Styloid process (posterior surface)",
"Body of hyoid (at junction with greater horn)",
"Elevates and retracts hyoid",
"CN VII – Facial n. (stylohyoid br.)"),
# infrahyoid
("Sternohyoid",
"Manubrium sterni (posterior surface); medial clavicle",
"Body of hyoid bone (lower border)",
"Depresses hyoid after swallowing",
"Ansa cervicalis C1–C3"),
("Sternothyroid",
"Manubrium sterni (posterior surface; 1st costal cartilage)",
"Oblique line of thyroid cartilage",
"Depresses thyroid cartilage and larynx",
"Ansa cervicalis C1–C3"),
("Thyrohyoid",
"Oblique line of thyroid cartilage",
"Greater horn & body of hyoid",
"Depresses hyoid; elevates larynx when hyoid is fixed",
"C1 via CN XII"),
("Omohyoid\n(superior belly)",
"Intermediate tendon",
"Body of hyoid (lower border, lateral to sternohyoid)",
"Depresses, retracts, and steadies hyoid",
"Ansa cervicalis C1–C3"),
("Omohyoid\n(inferior belly)",
"Superior border of scapula (medial to suprascapular notch)",
"Intermediate tendon",
"Depresses, retracts, and steadies hyoid",
"Ansa cervicalis C1–C3"),
# deep anterior
("Longus capitis",
"Anterior tubercles of C3–C6 transverse processes",
"Basilar part of occipital bone",
"Flexes head; flexes upper cervical spine",
"C1–C4 anterior rami"),
("Longus colli",
"Vertebral bodies C3–T3; transverse processes C3–C6",
"Atlas anterior tubercle; vertebral bodies C2–C4; transverse processes C5–C6",
"Flexes and rotates cervical spine; anterior cervical stabiliser",
"C2–C6 anterior rami"),
("Rectus capitis\nanterior",
"Lateral mass of atlas (C1)",
"Basilar part of occipital bone (anterior to condyle)",
"Flexes head at atlanto-occipital joint",
"C1–C2 anterior rami"),
("Rectus capitis\nlateralis",
"Transverse process of atlas (C1)",
"Jugular process of occipital bone",
"Lateral flexion of head at atlanto-occipital joint",
"C1 anterior ramus"),
# scalenes
("Scalenus anterior",
"Anterior tubercles of C3–C6 transverse processes",
"Scalene tubercle on 1st rib",
"Elevates 1st rib (forced inspiration); flexes & laterally tilts neck; rotates to opposite side",
"C4–C6 anterior rami"),
("Scalenus medius",
"Posterior tubercles of C2–C7 transverse processes",
"1st rib (posterior to subclavian groove)",
"Elevates 1st rib; laterally flexes neck",
"C3–C8 anterior rami"),
("Scalenus posterior",
"Posterior tubercles of C4–C6 transverse processes",
"Outer surface of 2nd rib",
"Elevates 2nd rib; laterally flexes neck",
"C6–C8 anterior rami"),
# suboccipital
("Rectus capitis\nposterior major",
"Spinous process of axis (C2)",
"Lateral inferior nuchal line (occipital bone)",
"Extends head; rotates head to same side",
"Suboccipital n. (C1 posterior ramus)"),
("Rectus capitis\nposterior minor",
"Posterior tubercle of atlas (C1)",
"Medial inferior nuchal line (occipital bone)",
"Extends head at atlanto-occipital joint",
"Suboccipital n. (C1 posterior ramus)"),
("Obliquus capitis\nsuperior",
"Transverse process of atlas (C1)",
"Occipital bone (between nuchal lines, lateral)",
"Extends and laterally flexes head",
"Suboccipital n. (C1 posterior ramus)"),
("Obliquus capitis\ninferior",
"Spinous process of axis (C2)",
"Transverse process of atlas (C1)",
"Rotates atlas on axis (ipsilateral head rotation)",
"Suboccipital n. (C1 posterior ramus)"),
("Semispinalis capitis",
"Articular processes of C4–C6; transverse processes of C7–T7",
"Between superior & inferior nuchal lines (occipital bone)",
"Extends head and neck; contralateral rotation",
"C1–C5 dorsal rami"),
("Splenius capitis",
"Ligamentum nuchae; spinous processes of C7–T3",
"Mastoid process; lateral superior nuchal line",
"Extends head & neck; ipsilateral rotation & lateral flexion",
"C2–C3 dorsal rami"),
]
# ════════════════════════════════════════════════════════════════
# BUILD PDF
# ════════════════════════════════════════════════════════════════
story = []
# ── Title Banner ─────────────────────────────────────────────────
title_data = [[
Paragraph("MUSCLES OF HEAD, NECK & FACE", title_style),
]]
title_table = Table(title_data, colWidths=[W])
title_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_DARK_BLUE),
("TOPPADDING", (0,0), (-1,-1), 10),
("BOTTOMPADDING", (0,0), (-1,-1), 4),
]))
story.append(title_table)
subtitle_data = [[Paragraph("Quick Reference Card · Origins · Insertions · Actions · Nerve Supply", subtitle_style)]]
sub_table = Table(subtitle_data, colWidths=[W])
sub_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), C_MID_BLUE),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
]))
story.append(sub_table)
story.append(Spacer(1, 4*mm))
sections = [
("1. MUSCLES OF FACIAL EXPRESSION (CN VII – Facial Nerve)", sec1_facial, C_SECTION_BG[0], C_HDR[0]),
("2. MUSCLES OF MASTICATION (CN V3 – Mandibular Nerve)", sec2_mastication, C_SECTION_BG[1], C_HDR[1]),
("3. EXTRAOCULAR MUSCLES (CN III / IV / VI)", sec3_extraocular, C_SECTION_BG[2], C_HDR[2]),
("4. MUSCLES OF THE TONGUE (CN XII – Hypoglossal + CN X for palatoglossus)", sec4_tongue, C_SECTION_BG[3], C_HDR[3]),
("5. PHARYNGEAL & SOFT PALATE MUSCLES (CN X pharyngeal plexus, CN IX, CN V3)", sec5_pharynx, C_SECTION_BG[4], C_HDR[4]),
("6. MUSCLES OF THE NECK (CN XI, CN VII, CN V3, Ansa cervicalis, C1–C8)", sec6_neck, C_SECTION_BG[5], C_HDR[5]),
]
for title, rows, bg, hdr_bg in sections:
story.append(KeepTogether([
section_header(title, hdr_bg),
Spacer(1, 1.5*mm),
make_table(rows, bg, hdr_bg),
Spacer(1, 4*mm),
]))
# ── Nerve Supply Summary box ──────────────────────────────────────
story.append(Spacer(1, 2*mm))
nerve_summary_hdr = section_header("NERVE SUPPLY AT A GLANCE", C_DARK_BLUE)
nerve_rows = [
["CN V3 (Mandibular)", "Masseter, Temporalis, Medial & Lateral Pterygoids, Tensor veli palatini, Mylohyoid, Anterior Digastric"],
["CN VII (Facial)", "All muscles of facial expression, Posterior Digastric, Stylohyoid, Platysma"],
["CN IX (Glossopharyngeal)", "Stylopharyngeus (sole muscle – unique)"],
["CN X (Vagus)", "Pharyngeal constrictors, Palatopharyngeus, Levator veli palatini, Musculus uvulae, Palatoglossus, Salpingopharyngeus"],
["CN XI (Accessory)", "Sternocleidomastoid, Trapezius (+ C3–C4 proprioception)"],
["CN XII (Hypoglossal)", "All intrinsic tongue muscles; Genioglossus, Hyoglossus, Styloglossus"],
["CN III / IV / VI", "Extraocular muscles (LR₆SO₄ rest III)"],
["Ansa cervicalis (C1–C3)", "Sternohyoid, Sternothyroid, Omohyoid"],
["C1 via CN XII", "Thyrohyoid, Geniohyoid"],
["C1 post. ramus (Suboccipital n.)", "Rectus capitis post. major & minor, Obliquus capitis sup. & inf."],
["C2–C6 anterior rami", "Longus capitis, Longus colli, Scalenes (varying levels)"],
["C2–C3 dorsal rami", "Splenius capitis, Semispinalis capitis"],
]
ns_data = [
[Paragraph("<b>Nerve</b>", cell_bold), Paragraph("<b>Muscles Supplied</b>", cell_bold)]
] + [
[Paragraph(r[0], cell_nerve), Paragraph(r[1], cell_normal)] for r in nerve_rows
]
ns_table = Table(ns_data, colWidths=[55*mm, 135*mm])
ns_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,0), C_DARK_BLUE),
("TEXTCOLOR", (0,0), (-1,0), C_WHITE),
("ROWBACKGROUNDS",(0,1), (-1,-1), [C_LIGHT_BLUE, C_WHITE]),
("GRID", (0,0), (-1,-1), 0.3, colors.HexColor("#aaaaaa")),
("VALIGN", (0,0), (-1,-1), "TOP"),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
]))
story.append(nerve_summary_hdr)
story.append(Spacer(1, 1.5*mm))
story.append(ns_table)
# ── Footer note ───────────────────────────────────────────────────
story.append(Spacer(1, 4*mm))
story.append(Paragraph(
"Sources: Dermatology 2-Volume Set 5e | K.J. Lee's Essential Otolaryngology | THIEME Atlas of Anatomy | Netter's Atlas of Human Anatomy · Generated by Orris Medical AI",
footer_style
))
doc.build(story)
print("PDF generated:", OUTPUT)