What is headache explain types and cure in details
types of headache classification causes treatment 2024
"headache" AND "classification" AND "treatment"

| Category | Definition | Examples |
|---|---|---|
| Primary | Headache IS the disorder; no underlying cause | Tension-type, Migraine, Cluster |
| Secondary | Headache is a symptom of another condition | Meningitis, SAH, tumor, hypertension |
| Approach | Options |
|---|---|
| Mild/acute | Acetaminophen (paracetamol), NSAIDs (ibuprofen, naproxen, aspirin) |
| Non-pharmacologic | Muscle relaxation techniques, massage, moist heat, biofeedback, cognitive behavioral therapy |
| Chronic prevention | Tricyclic antidepressants (amitriptyline 10-25 mg at night, up to 1 mg/kg) |
| Lifestyle | Regular sleep, regular meals, regular exercise (150 min/week moderate aerobic activity), stress management |
Note: Frequent use of over-the-counter analgesics (more than 10-15 days/month) leads to medication overuse headache (MOH), a major complication.
| Subtype | Key Feature |
|---|---|
| Migraine without aura ("common migraine") | Most common (80% of migraines); meets above criteria |
| Migraine with aura ("classic migraine") | Preceded by reversible focal neurologic symptoms (aura) developing over 5-20 min, lasting <60 min; occurs in ~20% of migraineurs; most commonly visual (fortification spectra, scotomata) |
| Chronic migraine | ≥15 headache days/month, with migraine features on ≥8 days/month |
| Hemiplegic migraine | Motor weakness as part of aura |
| Brainstem aura migraine | Dysarthria, vertigo, tinnitus, diplopia |
| Severity | First-line Options |
|---|---|
| Mild-moderate | NSAIDs (ibuprofen, naproxen, aspirin), caffeine-containing combination analgesics (e.g., Excedrin) |
| Moderate-severe | Triptans (5-HT1B/D agonists): sumatriptan, rizatriptan, zolmitriptan, eletriptan - take at headache onset |
| Severe/refractory | Ergotamine/dihydroergotamine (DHE), CGRP antagonists ("gepants": ubrogepant, rimegepant), ditans (lasmiditan - 5-HT1F agonist) |
| With nausea/vomiting | Metoclopramide IV (also treats headache directly); prochlorperazine as second-line; dopamine blockers |
| Quiet environment | Rest in dark, quiet room is effective for milder attacks |
| Drug Class | Examples |
|---|---|
| Beta-blockers | Propranolol, metoprolol |
| Calcium channel blockers | Flunarizine, verapamil |
| Antiepileptics | Topiramate, valproate |
| Tricyclic antidepressants | Amitriptyline, nortriptyline |
| CGRP monoclonal antibodies (newest) | Erenumab, fremanezumab, galcanezumab - effective and well-tolerated in chronic migraine |
| CGRP receptor antagonists (gepants) | Atogepant (oral, daily) |
| Candesartan (ARB) | Emerging evidence |
| Botulinum toxin (Botox) | For chronic migraine (≥15 days/month) |
| Approach | Options |
|---|---|
| Acute abortion | 100% oxygen at 7-12 L/min via non-rebreather mask for 15-20 min (effective in ~70%) |
| Acute | Subcutaneous sumatriptan 6 mg (fastest onset), intranasal zolmitriptan or sumatriptan |
| Prevention during cluster period | Verapamil (first-line), oral corticosteroids (short bridge), lithium, topiramate, melatonin |
| Refractory | Greater occipital nerve block (GONB), sphenopalatine ganglion (SPG) stimulation |
| Type | Key Features | Treatment |
|---|---|---|
| Hemicrania continua | Continuous moderate unilateral headache for ≥3 months; autonomic features; periods of exacerbation | Indomethacin (diagnostic and therapeutic) |
| Ice pick headache (primary stabbing) | Brief, intense stabs lasting seconds; "ice pick" in the eye | Indomethacin for prevention |
| Thunderclap headache (primary) | Sudden maximal headache within <1 min; diagnosis of exclusion after ruling out SAH | Exclude secondary causes first (CT urgently); nimodipine for RCVS |
| Hypnic headache | Awakens from sleep ("alarm clock headache"); elderly; bilateral | Caffeine before bed, lithium |
| Exertional headache | Triggered by physical activity | Indomethacin, propranolol |
| Coital headache | Sudden severe headache at orgasm | Exclude SAH; propranolol for prevention |
| Warning Sign | Concern |
|---|---|
| Sudden-onset / "worst headache of life" / thunderclap | Subarachnoid hemorrhage (SAH) |
| First severe headache ever | SAH, meningitis |
| Fever + stiff neck + altered consciousness | Meningitis, encephalitis |
| Progressive worsening over days/weeks | Tumor, subdural hematoma |
| New headache in cancer patient / HIV | Brain metastasis, CNS infection |
| Onset after age 55 | Giant cell arteritis, tumor |
| Vomiting preceding headache | Raised intracranial pressure |
| Pain worsens on bending/coughing/Valsalva | Raised ICP, Chiari malformation |
| Abnormal neurologic exam | Any structural lesion |
| Pain over temporal artery (tender) in elderly | Giant cell arteritis |
| Feature | Tension-Type | Migraine | Cluster |
|---|---|---|---|
| Prevalence | 69% | 16% | 0.1% |
| Sex | Equal | F > M (3:1) | M > F (4:1) |
| Location | Bilateral | Unilateral (often) | Unilateral, periorbital |
| Quality | Pressing, tightening | Throbbing, pulsating | Boring, stabbing |
| Severity | Mild-moderate | Moderate-severe | Severe (worst possible) |
| Duration | 30 min - days | 4-72 hours | 15-180 min |
| Nausea | No | Yes | Uncommon |
| Autonomic features | No | Sometimes | YES (defining) |
| Activity | Not worsened | Worsened | Restlessness, pacing |
| Acute treatment | NSAIDs, acetaminophen | Triptans, NSAIDs, gepants | O2, subcutaneous sumatriptan |
| Prevention | Amitriptyline | Beta-blockers, topiramate, CGRP mAbs | Verapamil |
Create a PDF quick reference guide for distinguishing migraine from tension headache
mkdir -p /home/daytona/workspace/headache-guide && ls /home/daytona/workspace/
~/headache-guide/create_headache_guide.py
from reportlab.lib.pagesizes import A4
from reportlab.lib import colors
from reportlab.lib.units import mm, cm
from reportlab.platypus import (
SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
HRFlowable, KeepTogether
)
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import BaseDocTemplate, PageTemplate, Frame
from reportlab.lib.colors import HexColor
# ── Colour palette ──────────────────────────────────────────────────────────
MIGRAINE_DARK = HexColor("#6B21A8") # deep purple
MIGRAINE_MID = HexColor("#9333EA") # purple
MIGRAINE_LIGHT = HexColor("#EDE9FE") # lavender tint
TENSION_DARK = HexColor("#0369A1") # deep blue
TENSION_MID = HexColor("#0EA5E9") # sky blue
TENSION_LIGHT = HexColor("#E0F2FE") # light blue tint
HEADER_BG = HexColor("#1E1B4B") # dark indigo
ACCENT_RED = HexColor("#DC2626") # red for warnings
ACCENT_ORANGE = HexColor("#EA580C") # orange for caution
GREEN_DARK = HexColor("#166534")
GREEN_LIGHT = HexColor("#DCFCE7")
GREY_LIGHT = HexColor("#F8FAFC")
GREY_MID = HexColor("#E2E8F0")
GREY_DARK = HexColor("#475569")
WHITE = colors.white
BLACK = colors.black
# ── Page setup ───────────────────────────────────────────────────────────────
PAGE_W, PAGE_H = A4
MARGIN = 18 * mm
def build_styles():
base = getSampleStyleSheet()
styles = {
"title": ParagraphStyle(
"title",
fontName="Helvetica-Bold",
fontSize=22,
textColor=WHITE,
alignment=TA_CENTER,
spaceAfter=2,
),
"subtitle": ParagraphStyle(
"subtitle",
fontName="Helvetica",
fontSize=11,
textColor=HexColor("#C4B5FD"),
alignment=TA_CENTER,
spaceAfter=0,
),
"section_header": ParagraphStyle(
"section_header",
fontName="Helvetica-Bold",
fontSize=10,
textColor=WHITE,
alignment=TA_CENTER,
spaceAfter=0,
leading=14,
),
"migraine_col": ParagraphStyle(
"migraine_col",
fontName="Helvetica-Bold",
fontSize=10,
textColor=MIGRAINE_DARK,
alignment=TA_CENTER,
),
"tension_col": ParagraphStyle(
"tension_col",
fontName="Helvetica-Bold",
fontSize=10,
textColor=TENSION_DARK,
alignment=TA_CENTER,
),
"feature_label": ParagraphStyle(
"feature_label",
fontName="Helvetica-Bold",
fontSize=8.5,
textColor=HexColor("#1E293B"),
alignment=TA_LEFT,
),
"cell_text": ParagraphStyle(
"cell_text",
fontName="Helvetica",
fontSize=8,
textColor=HexColor("#1E293B"),
alignment=TA_LEFT,
leading=11,
),
"cell_text_c": ParagraphStyle(
"cell_text_c",
fontName="Helvetica",
fontSize=8,
textColor=HexColor("#1E293B"),
alignment=TA_CENTER,
leading=11,
),
"warn_title": ParagraphStyle(
"warn_title",
fontName="Helvetica-Bold",
fontSize=9,
textColor=ACCENT_RED,
alignment=TA_LEFT,
),
"warn_body": ParagraphStyle(
"warn_body",
fontName="Helvetica",
fontSize=8,
textColor=HexColor("#7F1D1D"),
alignment=TA_LEFT,
leading=12,
),
"box_title": ParagraphStyle(
"box_title",
fontName="Helvetica-Bold",
fontSize=9,
textColor=HEADER_BG,
alignment=TA_LEFT,
spaceAfter=2,
),
"box_body": ParagraphStyle(
"box_body",
fontName="Helvetica",
fontSize=8,
textColor=HexColor("#1E293B"),
alignment=TA_LEFT,
leading=12,
),
"footer": ParagraphStyle(
"footer",
fontName="Helvetica",
fontSize=7,
textColor=GREY_DARK,
alignment=TA_CENTER,
),
"green_title": ParagraphStyle(
"green_title",
fontName="Helvetica-Bold",
fontSize=9,
textColor=GREEN_DARK,
alignment=TA_LEFT,
spaceAfter=2,
),
"green_body": ParagraphStyle(
"green_body",
fontName="Helvetica",
fontSize=8,
textColor=HexColor("#14532D"),
alignment=TA_LEFT,
leading=12,
),
"orange_title": ParagraphStyle(
"orange_title",
fontName="Helvetica-Bold",
fontSize=9,
textColor=ACCENT_ORANGE,
alignment=TA_LEFT,
spaceAfter=2,
),
"orange_body": ParagraphStyle(
"orange_body",
fontName="Helvetica",
fontSize=8,
textColor=HexColor("#431407"),
alignment=TA_LEFT,
leading=12,
),
"pin_title": ParagraphStyle(
"pin_title",
fontName="Helvetica-Bold",
fontSize=9,
textColor=MIGRAINE_DARK,
alignment=TA_CENTER,
),
"pin_big": ParagraphStyle(
"pin_big",
fontName="Helvetica-Bold",
fontSize=20,
textColor=MIGRAINE_MID,
alignment=TA_CENTER,
leading=24,
),
"pin_body": ParagraphStyle(
"pin_body",
fontName="Helvetica",
fontSize=8,
textColor=MIGRAINE_DARK,
alignment=TA_CENTER,
leading=12,
),
}
return styles
# ── Helper: draw page border & header background via canvas ─────────────────
def draw_page_background(canvas, doc):
canvas.saveState()
# Header background band
canvas.setFillColor(HEADER_BG)
canvas.rect(0, PAGE_H - 42*mm, PAGE_W, 42*mm, fill=1, stroke=0)
# Decorative accent line under header
canvas.setStrokeColor(MIGRAINE_MID)
canvas.setLineWidth(3)
canvas.line(MARGIN, PAGE_H - 42*mm, PAGE_W - MARGIN, PAGE_H - 42*mm)
# Footer
canvas.setFillColor(GREY_LIGHT)
canvas.rect(0, 0, PAGE_W, 12*mm, fill=1, stroke=0)
canvas.setStrokeColor(GREY_MID)
canvas.setLineWidth(0.5)
canvas.line(MARGIN, 12*mm, PAGE_W - MARGIN, 12*mm)
canvas.setFont("Helvetica", 7)
canvas.setFillColor(GREY_DARK)
canvas.drawCentredString(
PAGE_W/2, 4.5*mm,
"Quick Reference Guide | Migraine vs Tension-Type Headache | "
"Sources: Harrison's 22E, Neuroanatomy Through Clinical Cases 3rd Ed., ICHD-3"
)
canvas.restoreState()
def make_pdf(output_path):
S = build_styles()
doc = BaseDocTemplate(
output_path,
pagesize=A4,
leftMargin=MARGIN, rightMargin=MARGIN,
topMargin=44*mm, bottomMargin=14*mm,
)
frame = Frame(MARGIN, 14*mm, PAGE_W - 2*MARGIN, PAGE_H - 58*mm, id="main")
template = PageTemplate(id="main_page", frames=[frame], onPage=draw_page_background)
doc.addPageTemplates([template])
story = []
usable_w = PAGE_W - 2*MARGIN
# ── TITLE (drawn on canvas, so we just add a spacer to shift content down) ──
# The header band is drawn by draw_page_background; put title text there via canvas
# We'll overlay it using a transparent table at the top of the frame
header_table = Table(
[[
Paragraph("MIGRAINE vs TENSION-TYPE HEADACHE", S["title"]),
]],
colWidths=[usable_w],
rowHeights=[12*mm],
)
header_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), colors.transparent),
("BOX", (0,0), (-1,-1), 0, colors.transparent),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING", (0,0), (-1,-1), 0),
]))
subtitle_table = Table(
[[Paragraph("Clinical Quick Reference Guide | Differential Diagnosis & Management", S["subtitle"])]],
colWidths=[usable_w],
rowHeights=[7*mm],
)
subtitle_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), colors.transparent),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
]))
story.append(header_table)
story.append(subtitle_table)
story.append(Spacer(1, 3*mm))
# ── Section: OVERVIEW COMPARISON TABLE ──────────────────────────────────
col_feat = 38*mm
col_mig = (usable_w - col_feat) / 2
col_ten = col_mig
# Column headers
headers = [
Paragraph("FEATURE", S["section_header"]),
Paragraph("MIGRAINE", S["section_header"]),
Paragraph("TENSION-TYPE", S["section_header"]),
]
header_row = Table(
[headers],
colWidths=[col_feat, col_mig, col_ten],
rowHeights=[8*mm],
)
header_row.setStyle(TableStyle([
("BACKGROUND", (0,0), (0,0), GREY_DARK),
("BACKGROUND", (1,0), (1,0), MIGRAINE_DARK),
("BACKGROUND", (2,0), (2,0), TENSION_DARK),
("TEXTCOLOR", (0,0), (-1,-1), WHITE),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("ALIGN", (0,0), (-1,-1), "CENTER"),
("FONTNAME", (0,0), (-1,-1), "Helvetica-Bold"),
("FONTSIZE", (0,0), (-1,-1), 9),
("TOPPADDING", (0,0), (-1,-1), 2),
("BOTTOMPADDING", (0,0), (-1,-1), 2),
]))
story.append(header_row)
# Comparison rows: (feature, migraine text, tension text, mig_bg, ten_bg)
rows = [
("Prevalence",
"~16% of all headaches",
"~69% of all headaches (most common)",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Sex ratio",
"Female : Male = 3:1",
"Roughly equal (F slightly > M)",
WHITE, WHITE),
("Location",
"Unilateral (60–70%)\nCan be bilateral",
"Bilateral — always\n'Band around head'",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Quality / Character",
"Throbbing, pulsating\nPounding",
"Pressing, tightening\nNon-pulsating, dull ache",
WHITE, WHITE),
("Severity",
"Moderate to severe\nOften incapacitating",
"Mild to moderate\nRarely stops daily activity",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Duration",
"4 – 72 hours\n(untreated / inadequately treated)",
"30 min – several days",
WHITE, WHITE),
("Nausea / Vomiting",
"YES — characteristic\n(nausea in ~80%, vomiting in ~30%)",
"NO (or very mild nausea in chronic type)",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Photophobia",
"YES — prominent feature",
"Mild, if present at all",
WHITE, WHITE),
("Phonophobia",
"YES — prominent feature",
"Mild, if present at all",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Aura",
"Present in ~20% (classic migraine)\nVisual most common; lasts 5–60 min",
"ABSENT",
WHITE, WHITE),
("Effect of activity",
"WORSENED by routine\nphysical activity (e.g. walking)",
"NOT worsened by activity",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Prodrome",
"YES — yawning, mood changes,\nneck stiffness, food cravings (hrs before)",
"Uncommon",
WHITE, WHITE),
("Autonomic features",
"Sometimes: photophobia,\nphonophobia, osmophobia",
"None",
MIGRAINE_LIGHT, TENSION_LIGHT),
("Associated factors",
"Hormonal (menstrual), sleep changes,\nstress, certain foods, weather, odours",
"Stress, poor posture,\nfatigue, eye strain, hunger",
WHITE, WHITE),
("Pathophysiology",
"Brain disorder — trigeminovascular\nactivation, cortical spreading depression",
"Pericranial muscle tenderness,\ncentral sensitisation",
MIGRAINE_LIGHT, TENSION_LIGHT),
]
comp_data = []
comp_styles_list = [
("GRID", (0,0), (-1,-1), 0.3, GREY_MID),
("VALIGN", (0,0), (-1,-1), "MIDDLE"),
("TOPPADDING", (0,0), (-1,-1), 3),
("BOTTOMPADDING", (0,0), (-1,-1), 3),
("LEFTPADDING", (0,0), (-1,-1), 4),
("RIGHTPADDING", (0,0), (-1,-1), 4),
]
for i, (feat, mig, ten, mig_bg, ten_bg) in enumerate(rows):
feat_bg = HexColor("#F1F5F9") if i % 2 == 0 else WHITE
comp_data.append([
Paragraph(feat, S["feature_label"]),
Paragraph(mig.replace("\n", "<br/>"), S["cell_text"]),
Paragraph(ten.replace("\n", "<br/>"), S["cell_text"]),
])
comp_styles_list.append(("BACKGROUND", (0,i), (0,i), feat_bg))
comp_styles_list.append(("BACKGROUND", (1,i), (1,i), mig_bg))
comp_styles_list.append(("BACKGROUND", (2,i), (2,i), ten_bg))
comp_table = Table(comp_data, colWidths=[col_feat, col_mig, col_ten])
comp_table.setStyle(TableStyle(comp_styles_list))
story.append(comp_table)
story.append(Spacer(1, 4*mm))
# ── Three bottom boxes: PIN mnemonic | Red Flags | Treatment ─────────────
box_w = (usable_w - 4*mm) / 3
# -- PIN Mnemonic box
pin_content = [
Paragraph("PIN MNEMONIC", S["pin_title"]),
Spacer(1, 1*mm),
Paragraph("P · I · N", S["pin_big"]),
Spacer(1, 1*mm),
Paragraph(
"<b>P</b>hotosensitivity<br/>"
"<b>I</b>ncapacitation<br/>"
"<b>N</b>ausea",
S["pin_body"]
),
Spacer(1, 1*mm),
Paragraph(
"2 of 3 features = 93% PPV for Migraine",
S["pin_body"]
),
Spacer(1, 1*mm),
Paragraph(
"<i>(Neuroanatomy Through Clinical Cases, 3rd Ed.)</i>",
S["pin_body"]
),
]
pin_table = Table(
[[pin_content]],
colWidths=[box_w],
)
pin_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), MIGRAINE_LIGHT),
("BOX", (0,0), (-1,-1), 1.5, MIGRAINE_MID),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
# -- Red Flags box
red_flags = [
Paragraph("⚠ RED FLAGS — Investigate Urgently", S["warn_title"]),
Spacer(1, 2*mm),
Paragraph(
"• Sudden-onset / 'thunderclap' headache<br/>"
"• Worst headache of life<br/>"
"• Fever + stiff neck (meningism)<br/>"
"• New headache after age 50<br/>"
"• Progressive worsening over days/weeks<br/>"
"• Vomiting before headache begins<br/>"
"• Pain worsened by bending / coughing<br/>"
"• Wakes patient from sleep<br/>"
"• Neurological deficit / papilloedema<br/>"
"• Temporal artery tenderness (elderly)<br/>"
"• New headache in cancer / HIV patient",
S["warn_body"]
),
]
red_table = Table(
[[red_flags]],
colWidths=[box_w],
)
red_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), HexColor("#FEF2F2")),
("BOX", (0,0), (-1,-1), 1.5, ACCENT_RED),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
# -- Treatment box
treat_content = [
Paragraph("TREATMENT SUMMARY", S["box_title"]),
Spacer(1, 1*mm),
Paragraph("<b><font color='#6B21A8'>MIGRAINE — Acute</font></b>", S["box_body"]),
Paragraph(
"Mild-mod: NSAIDs + caffeine combinations<br/>"
"Mod-severe: Triptans (sumatriptan, rizatriptan)<br/>"
"With nausea: add metoclopramide IV/IM<br/>"
"Newer: Gepants (ubrogepant, rimegepant)<br/>"
"Ditans: Lasmiditan (5-HT1F agonist)",
S["box_body"]
),
Spacer(1, 1.5*mm),
Paragraph("<b><font color='#6B21A8'>MIGRAINE — Prevention</font></b>", S["box_body"]),
Paragraph(
"Beta-blockers (propranolol, metoprolol)<br/>"
"TCAs (amitriptyline 10–25 mg nightly)<br/>"
"Antiepilpetics (topiramate, valproate)<br/>"
"CGRP mAbs (erenumab, fremanezumab)<br/>"
"Ca-channel blockers (flunarizine)",
S["box_body"]
),
Spacer(1, 1.5*mm),
Paragraph("<b><font color='#0369A1'>TENSION — Acute</font></b>", S["box_body"]),
Paragraph(
"Acetaminophen or NSAIDs (first-line)<br/>"
"Moist heat, massage, relaxation",
S["box_body"]
),
Spacer(1, 1.5*mm),
Paragraph("<b><font color='#0369A1'>TENSION — Prevention</font></b>", S["box_body"]),
Paragraph(
"Amitriptyline / nortriptyline<br/>"
"Biofeedback, CBT, exercise<br/>"
"Avoid medication overuse (>15 days/mo)",
S["box_body"]
),
]
treat_table = Table(
[[treat_content]],
colWidths=[box_w],
)
treat_table.setStyle(TableStyle([
("BACKGROUND", (0,0), (-1,-1), GREY_LIGHT),
("BOX", (0,0), (-1,-1), 1.5, GREY_MID),
("TOPPADDING", (0,0), (-1,-1), 5),
("BOTTOMPADDING", (0,0), (-1,-1), 5),
("LEFTPADDING", (0,0), (-1,-1), 6),
("RIGHTPADDING", (0,0), (-1,-1), 6),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
# Assemble three boxes side by side
bottom_row = Table(
[[pin_table, treat_table, red_table]],
colWidths=[box_w, box_w, box_w],
spaceBefore=0,
)
bottom_row.setStyle(TableStyle([
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("ALIGN", (0,0), (-1,-1), "CENTER"),
("VALIGN", (0,0), (-1,-1), "TOP"),
("COLPADDING", (0,0), (-1,-1), 2),
]))
# Use a wrapper to add spacing between columns
three_cols_data = [[pin_table, Spacer(2*mm, 1), treat_table, Spacer(2*mm, 1), red_table]]
three_cols = Table(
three_cols_data,
colWidths=[box_w, 2*mm, box_w, 2*mm, box_w],
)
three_cols.setStyle(TableStyle([
("LEFTPADDING", (0,0), (-1,-1), 0),
("RIGHTPADDING", (0,0), (-1,-1), 0),
("TOPPADDING", (0,0), (-1,-1), 0),
("BOTTOMPADDING",(0,0), (-1,-1), 0),
("VALIGN", (0,0), (-1,-1), "TOP"),
]))
story.append(KeepTogether(three_cols))
doc.build(story)
print(f"PDF created: {output_path}")
if __name__ == "__main__":
out = "/home/daytona/workspace/headache-guide/Migraine_vs_Tension_Headache_QuickRef.pdf"
make_pdf(out)
cd /home/daytona/workspace/headache-guide && python create_headache_guide.py 2>&1
ls -lh /home/daytona/workspace/headache-guide/
Migraine vs Tension Headache QuickRef
PDF Document · PDF