Generate a study guide document on epithelialtissue classification and functions and

Asking for Preferences
Reading File
Reading File
Finding Sources
Finding Sources
Finding Sources
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Reading File
Running Command

mkdir -p /home/daytona/workspace/epithelial-study-guide && ls /home/daytona/workspace/epithelial-study-guide

Writing File

~/epithelial-study-guide/generate_guide.py

#!/usr/bin/env python3
"""
Epithelial Tissue Classification & Functions - Medical School Study Guide
Generated from: Junqueira's Basic Histology (17e) and Histology: A Text and Atlas (Ross & Pawlina)
"""

from reportlab.lib.pagesizes import letter
from reportlab.lib import colors
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
from reportlab.lib.units import inch
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    HRFlowable, PageBreak, KeepTogether
)
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY

# ── Color palette ────────────────────────────────────────────────────────────
NAVY      = colors.HexColor('#1A3A5C')
TEAL      = colors.HexColor('#2E7D8A')
GOLD      = colors.HexColor('#D4A017')
LIGHT_BG  = colors.HexColor('#EEF4F7')
PINK_BG   = colors.HexColor('#FFF3F3')
GREEN_BG  = colors.HexColor('#F0FFF4')
YELLOW_BG = colors.HexColor('#FFFDE7')
MED_GRAY  = colors.HexColor('#5A6475')
BORDER    = colors.HexColor('#B0C4D8')

OUTPUT = '/home/daytona/workspace/epithelial-study-guide/Epithelial_Tissue_Study_Guide.pdf'

# ── Document setup ───────────────────────────────────────────────────────────
doc = SimpleDocTemplate(
    OUTPUT,
    pagesize=letter,
    leftMargin=0.85*inch, rightMargin=0.85*inch,
    topMargin=1.0*inch,   bottomMargin=0.85*inch,
    title='Epithelial Tissue – Classification & Functions',
    author='Orris Medical Library'
)

# ── Styles ───────────────────────────────────────────────────────────────────
base = getSampleStyleSheet()

def S(name, **kw):
    s = ParagraphStyle(name=name, **kw)
    return s

cover_title = S('cover_title',
    fontName='Helvetica-Bold', fontSize=28, textColor=colors.white,
    alignment=TA_CENTER, spaceAfter=8, leading=34)
cover_subtitle = S('cover_subtitle',
    fontName='Helvetica', fontSize=14, textColor=colors.HexColor('#D0E8F5'),
    alignment=TA_CENTER, spaceAfter=6, leading=18)
cover_source = S('cover_source',
    fontName='Helvetica-Oblique', fontSize=10, textColor=colors.HexColor('#A8C8E0'),
    alignment=TA_CENTER, spaceAfter=4, leading=14)

h1 = S('h1',
    fontName='Helvetica-Bold', fontSize=16, textColor=colors.white,
    backColor=NAVY, spaceBefore=18, spaceAfter=10, leading=20,
    leftIndent=-6, rightIndent=-6, borderPad=6)
h2 = S('h2',
    fontName='Helvetica-Bold', fontSize=13, textColor=NAVY,
    spaceBefore=14, spaceAfter=6, leading=17,
    borderPadding=(4, 0, 4, 8))
h3 = S('h3',
    fontName='Helvetica-Bold', fontSize=11, textColor=TEAL,
    spaceBefore=10, spaceAfter=4, leading=15)

body = S('body',
    fontName='Helvetica', fontSize=10, textColor=colors.HexColor('#2C2C2C'),
    spaceBefore=3, spaceAfter=5, leading=15, alignment=TA_JUSTIFY)
bullet = S('bullet',
    fontName='Helvetica', fontSize=10, textColor=colors.HexColor('#2C2C2C'),
    spaceBefore=2, spaceAfter=2, leading=14, leftIndent=18,
    bulletIndent=6, bulletFontName='Helvetica', bulletFontSize=10)
sub_bullet = S('sub_bullet',
    fontName='Helvetica', fontSize=9.5, textColor=MED_GRAY,
    spaceBefore=1, spaceAfter=1, leading=13, leftIndent=34,
    bulletIndent=22)

highlight_style = S('highlight',
    fontName='Helvetica', fontSize=10, textColor=colors.HexColor('#2C2C2C'),
    spaceBefore=4, spaceAfter=4, leading=14, alignment=TA_JUSTIFY,
    leftIndent=8, rightIndent=8, borderPad=8,
    backColor=LIGHT_BG)
clinical_style = S('clinical',
    fontName='Helvetica-Oblique', fontSize=9.5, textColor=colors.HexColor('#8B0000'),
    spaceBefore=3, spaceAfter=3, leading=13, alignment=TA_JUSTIFY,
    leftIndent=8, rightIndent=8)
mnemonic_style = S('mnemonic',
    fontName='Helvetica-Bold', fontSize=10.5, textColor=colors.HexColor('#1A5C2A'),
    spaceBefore=3, spaceAfter=3, leading=15, alignment=TA_CENTER)
footnote = S('footnote',
    fontName='Helvetica-Oblique', fontSize=8, textColor=MED_GRAY,
    spaceBefore=2, spaceAfter=2, leading=11, alignment=TA_CENTER)

# ── Helper functions ─────────────────────────────────────────────────────────
def rule(color=TEAL, thickness=1.5):
    return HRFlowable(width='100%', thickness=thickness, color=color,
                      spaceAfter=4, spaceBefore=2)

def section_header(text):
    return [
        Spacer(1, 0.1*inch),
        Table([[Paragraph(text, h1)]],
              colWidths=[6.3*inch],
              style=TableStyle([
                  ('BACKGROUND', (0,0), (-1,-1), NAVY),
                  ('TOPPADDING',    (0,0), (-1,-1), 7),
                  ('BOTTOMPADDING', (0,0), (-1,-1), 7),
                  ('LEFTPADDING',   (0,0), (-1,-1), 10),
              ])),
        Spacer(1, 0.05*inch),
    ]

def sub_header(text):
    return [
        Spacer(1, 0.06*inch),
        Table([[Paragraph(text, h2)]],
              colWidths=[6.3*inch],
              style=TableStyle([
                  ('BACKGROUND', (0,0), (-1,-1), LIGHT_BG),
                  ('LINEBELOW',  (0,0), (-1,-1), 1.5, TEAL),
                  ('TOPPADDING',    (0,0), (-1,-1), 5),
                  ('BOTTOMPADDING', (0,0), (-1,-1), 5),
                  ('LEFTPADDING',   (0,0), (-1,-1), 8),
              ])),
        Spacer(1, 0.03*inch),
    ]

def box(paragraphs, bg=LIGHT_BG, border=BORDER):
    """Wrap paragraphs in a colored box."""
    content = [[p] for p in paragraphs]
    flat = [[paragraphs[0]]] if len(paragraphs) == 1 else [[Paragraph('<br/>'.join(
        [p.text if hasattr(p,'text') else '' for p in paragraphs]), body)]]
    return Table(
        [['\n'.join(['' for p in paragraphs])]],  # placeholder, build properly
        colWidths=[6.3*inch]
    )

def info_box(label, items, bg=LIGHT_BG, label_color=NAVY):
    """Info box with label and bullet items."""
    cell_content = [Paragraph(f'<b><font color="#{label_color.hexval()[1:]}">{label}</font></b>', 
                               ParagraphStyle('lbl', fontName='Helvetica-Bold', fontSize=11,
                                              textColor=label_color, leading=15, spaceAfter=4))]
    for item in items:
        cell_content.append(Paragraph(f'• {item}', bullet))
    t = Table([[cell_content]], colWidths=[6.3*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), bg),
        ('BOX',        (0,0), (-1,-1), 1, border),
        ('TOPPADDING',    (0,0), (-1,-1), 8),
        ('BOTTOMPADDING', (0,0), (-1,-1), 8),
        ('LEFTPADDING',   (0,0), (-1,-1), 10),
        ('RIGHTPADDING',  (0,0), (-1,-1), 10),
    ]))
    return t

def clinical_box(text):
    t = Table([[Paragraph(f'<b>🩺 Clinical Correlation:</b> {text}', clinical_style)]],
              colWidths=[6.3*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), PINK_BG),
        ('BOX',        (0,0), (-1,-1), 1, colors.HexColor('#E8A0A0')),
        ('TOPPADDING',    (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('LEFTPADDING',   (0,0), (-1,-1), 10),
        ('RIGHTPADDING',  (0,0), (-1,-1), 10),
        ('LINERIGHT', (0,0), (0,-1), 4, colors.HexColor('#CC0000')),
    ]))
    return t

def key_point_box(text):
    t = Table([[Paragraph(f'<b>Key Point:</b> {text}', 
                          ParagraphStyle('kp', fontName='Helvetica', fontSize=10,
                                         textColor=colors.HexColor('#1A3A5C'), leading=14,
                                         alignment=TA_JUSTIFY))]],
              colWidths=[6.3*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), YELLOW_BG),
        ('BOX',        (0,0), (-1,-1), 1, GOLD),
        ('TOPPADDING',    (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('LEFTPADDING',   (0,0), (-1,-1), 10),
        ('RIGHTPADDING',  (0,0), (-1,-1), 10),
        ('LINELEFT', (0,0), (0,-1), 4, GOLD),
    ]))
    return t

# ── Build the document ───────────────────────────────────────────────────────
story = []

# ═══════════════════════════════════════════════════════════════════════
# COVER PAGE
# ═══════════════════════════════════════════════════════════════════════
cover_table = Table(
    [[
        Paragraph('EPITHELIAL TISSUE', cover_title),
        Paragraph('Classification, Structure &amp; Functions', cover_subtitle),
        Paragraph('Medical School Study Guide', cover_subtitle),
        Spacer(1, 0.15*inch),
        Paragraph('Sources: Junqueira\'s Basic Histology, 17e  |  Ross &amp; Pawlina: Histology: A Text and Atlas', cover_source),
        Paragraph('Histology | Year 1–2 Medical Sciences', cover_source),
    ]],
    colWidths=[6.3*inch]
)
cover_table.setStyle(TableStyle([
    ('BACKGROUND',    (0,0), (-1,-1), NAVY),
    ('TOPPADDING',    (0,0), (-1,-1), 50),
    ('BOTTOMPADDING', (0,0), (-1,-1), 50),
    ('LEFTPADDING',   (0,0), (-1,-1), 30),
    ('RIGHTPADDING',  (0,0), (-1,-1), 30),
    ('BOX',           (0,0), (-1,-1), 3, GOLD),
]))
story.append(cover_table)
story.append(Spacer(1, 0.3*inch))

# Table of Contents
toc_data = [
    ['#', 'Section', 'Topic'],
    ['1', 'Overview', 'Definition, Properties & Embryonic Origin'],
    ['2', 'Classification', 'Simple, Stratified, Pseudo & Transitional'],
    ['3', 'Surface Specializations', 'Microvilli, Stereocilia, Cilia'],
    ['4', 'Cell Junctions', 'Tight, Gap, Adherens, Desmosomes'],
    ['5', 'Basement Membrane', 'Structure & Functions'],
    ['6', 'Glands', 'Exocrine & Endocrine Classification'],
    ['7', 'Cell Renewal', 'Stem Cells, Metaplasia, Clinical'],
    ['8', 'Quick Reference', 'Tables, Mnemonics, Review Questions'],
]
toc_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,0), 10),
    ('ALIGN',      (0,0), (-1,-1), 'LEFT'),
    ('FONTNAME',   (0,1), (-1,-1), 'Helvetica'),
    ('FONTSIZE',   (0,1), (-1,-1), 10),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), TEAL),
])
toc = Table(toc_data, colWidths=[0.4*inch, 1.0*inch, 4.9*inch])
toc.setStyle(toc_style)
story.append(Paragraph('Table of Contents', 
    ParagraphStyle('toc_h', fontName='Helvetica-Bold', fontSize=13, 
                   textColor=NAVY, spaceAfter=8, spaceBefore=10)))
story.append(toc)
story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 1 – OVERVIEW
# ═══════════════════════════════════════════════════════════════════════
story += section_header('1. Overview of Epithelial Tissue')

story.append(Paragraph(
    'Epithelial tissues are composed of closely aggregated polyhedral cells adhering strongly '
    'to one another and to a thin layer of extracellular matrix (ECM), forming cellular sheets '
    'that line the cavities of organs and cover the body surface. All substances that enter or '
    'leave an organ must cross this tissue type.',
    body))

story.append(Spacer(1, 0.08*inch))

story += sub_header('1.1 Defining Characteristics')

char_data = [
    ['Characteristic', 'Description'],
    ['Cell apposition', 'Cells closely packed with minimal ECM between them'],
    ['Location', 'Free (apical) surface always faces a space, cavity, or lumen'],
    ['Polarity', 'Apical, lateral, and basal domains differ structurally and functionally'],
    ['Avascular', 'No blood vessels; nutrients diffuse via basement membrane from connective tissue'],
    ['Innervated', 'Nerve fibers penetrate the basement membrane (pain, sensation)'],
    ['High turnover', 'Continuous renewal by mitosis from stem cell populations'],
    ['Basal lamina', 'All epithelia rest on a basement membrane secreted jointly by epithelium and CT'],
]
char_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 9.5),
    ('ALIGN',      (0,0), (-1,-1), 'LEFT'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
char_t = Table(char_data, colWidths=[1.8*inch, 4.5*inch])
char_t.setStyle(char_style)
story.append(char_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('1.2 Principal Functions')

func_data = [
    ['Function', 'Example', 'Epithelial Type'],
    ['Protection', 'Skin epidermis against abrasion, UV, pathogens', 'Stratified squamous keratinized'],
    ['Absorption', 'Nutrient uptake in small intestine', 'Simple columnar with microvilli'],
    ['Secretion', 'Digestive enzymes, mucus, hormones', 'Glandular / goblet cells'],
    ['Filtration', 'Glomerular filtration in kidney', 'Simple squamous (Bowman\'s capsule)'],
    ['Exchange', 'Gas exchange in alveoli', 'Simple squamous'],
    ['Lubrication', 'Pleural, pericardial, peritoneal cavities', 'Simple squamous (mesothelium)'],
    ['Sensory reception', 'Olfactory epithelium, taste buds', 'Specialized columnar'],
    ['Contractile', 'Myoepithelial cells around acini/ducts', 'Myoepithelial cells'],
]
func_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 9),
    ('ALIGN',      (0,0), (-1,-1), 'LEFT'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
    ('LEFTPADDING',   (0,0), (-1,-1), 7),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
func_t = Table(func_data, colWidths=[1.5*inch, 2.8*inch, 2.0*inch])
func_t.setStyle(func_style)
story.append(func_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('1.3 Embryonic Origin')
story.append(Paragraph(
    'Epithelia derive from all three germ layers. Knowing the origin is important for '
    'understanding pathology (metaplasia, carcinoma types):', body))
story.append(Spacer(1, 0.06*inch))

origin_data = [
    ['Germ Layer', 'Derived Epithelia'],
    ['Ectoderm\n(surface)', 'Epidermis and its derivatives (hair follicles, sweat glands, sebaceous glands)\n'
     'Cornea and lens epithelia • Enamel of teeth • Adenohypophysis\n'
     'Mucosa of oral cavity and lower anal canal'],
    ['Ectoderm\n(neuro)', 'Neural tube → CNS ependyma, choroid plexus\nNeural crest → various cells'],
    ['Mesoderm', 'Mesothelium (pleura, pericardium, peritoneum)\n'
     'Endothelium of blood & lymphatic vessels\nKidney tubular epithelium • Gonads'],
    ['Endoderm', 'GI tract epithelium (esophagus → rectum)\nLiver, pancreas, gallbladder parenchyma\n'
     'Respiratory epithelium • Thyroid, parathyroid, thymus\nUrinary bladder and most of urethra'],
]
origin_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 9),
    ('ALIGN',      (0,0), (0,-1), 'CENTER'),
    ('ALIGN',      (1,0), (1,-1), 'LEFT'),
    ('VALIGN',     (0,0), (-1,-1), 'MIDDLE'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), TEAL),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 6),
    ('BOTTOMPADDING', (0,0), (-1,-1), 6),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
])
origin_t = Table(origin_data, colWidths=[1.1*inch, 5.2*inch])
origin_t.setStyle(origin_style)
story.append(origin_t)
story.append(Spacer(1, 0.1*inch))

story.append(key_point_box(
    'Carcinomas (malignant tumors of epithelial origin) can arise from any of the three germ '
    'layers. Adenocarcinomas (from glandular epithelium) are the most common carcinomas in '
    'adults after age 45. — Junqueira\'s Basic Histology, 17e'))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 2 – CLASSIFICATION
# ═══════════════════════════════════════════════════════════════════════
story += section_header('2. Classification of Epithelium')

story.append(Paragraph(
    'Epithelium is classified descriptively based on <b>two primary criteria</b>: '
    '(1) the <b>number of cell layers</b> and (2) the <b>shape of the surface cells</b>. '
    'Optionally, a third criterion—specialization of the apical surface—may be added '
    '(e.g., ciliated, keratinized).', body))

story.append(Spacer(1, 0.08*inch))

story += sub_header('2.1 Cell Layer Terminology')
layer_data = [
    ['Term', 'Definition'],
    ['Simple', 'Single cell layer; every cell contacts the basement membrane'],
    ['Stratified', 'Two or more cell layers; only basal layer contacts basement membrane'],
    ['Pseudostratified', 'Appears multilayered but ALL cells contact the basement membrane;\nnuclei at varying heights create a false "stratified" appearance'],
    ['Transitional\n(Urothelium)', 'Specialized stratified epithelium of the urinary tract;\ncells alter shape with distension'],
]
lt_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 9.5),
    ('ALIGN',      (0,0), (0,-1), 'CENTER'),
    ('VALIGN',     (0,0), (-1,-1), 'MIDDLE'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 6),
    ('BOTTOMPADDING', (0,0), (-1,-1), 6),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
])
lt_t = Table(layer_data, colWidths=[1.5*inch, 4.8*inch])
lt_t.setStyle(lt_style)
story.append(lt_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('2.2 Cell Shape Terminology')
shape_data = [
    ['Shape', 'Description', 'Nuclear Shape'],
    ['Squamous', 'Width > Height; flat, scale-like cells', 'Flattened, disc-like'],
    ['Cuboidal', 'Width ≈ Height ≈ Depth; roughly equal dimensions', 'Spherical, central'],
    ['Columnar', 'Height >> Width; tall cells', 'Oval/elongated, basal or central'],
    ['Low columnar', 'Height only slightly exceeds width', 'Slightly oval'],
]
shape_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 9.5),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
    ('VALIGN',     (0,0), (-1,-1), 'MIDDLE'),
])
shape_t = Table(shape_data, colWidths=[1.3*inch, 3.0*inch, 2.0*inch])
shape_t.setStyle(shape_style)
story.append(shape_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('2.3 Master Classification Table')
story.append(Paragraph(
    'In stratified epithelia, <b>only the surface layer shape</b> determines the classification. '
    'For example, stratified squamous = multiple layers, surface cells are flat.', body))
story.append(Spacer(1, 0.06*inch))

master_data = [
    ['Type', 'Layers', 'Locations', 'Key Functions'],
    ['Simple\nSquamous', '1', 'Endothelium (blood/lymph vessels)\nMesothelium (pleura, peritoneum, pericardium)\nBowman\'s capsule glomerulus\nAlveoli of lung\nThin loop of Henle',
     'Exchange (gas, nutrients)\nLubrication\nFiltration\nTranscytosis (pinocytosis)'],
    ['Simple\nCuboidal', '1', 'Kidney tubules (proximal, distal, collecting)\nThyroid follicles\nSmall ducts of exocrine glands\nOvarian surface epithelium\nRetinal pigment epithelium',
     'Absorption\nSecretion\nProtection'],
    ['Simple\nColumnar', '1', 'GI tract (stomach to rectum)\nGallbladder\nLarge excretory ducts\nSome regions of uterus',
     'Absorption\nSecretion\nProtection\nMucus secretion (goblet cells)'],
    ['Simple Columnar\nCiliated', '1', 'Uterine (Fallopian) tubes\nSmall bronchioles\nCentral canal of spinal cord',
     'Movement of substances\n(egg transport, mucus clearance)'],
    ['Pseudostratified\nColumnar Ciliated', '1 (appears multi)', 'Trachea and bronchi (respiratory tract)\nMost of upper respiratory tract\nMale epididymis (non-ciliated)',
     'Mucus secretion (goblet cells)\nMucociliary escalator\nSperm maturation (epididymis)'],
    ['Stratified\nSquamous\nKeratinized', 'Many', 'Epidermis (skin)\nExternal auditory canal\nEsophagus (humans – non-keratinized)\nOral mucosa (palate – keratinized)',
     'Mechanical protection\nWaterproofing\nBarrier against pathogens'],
    ['Stratified\nSquamous\nNon-keratinized', 'Many', 'Esophagus\nOral cavity (most)\nVagina\nExocervix\nCornea',
     'Protection with flexibility\nWithstand friction\nStays moist'],
    ['Stratified\nCuboidal', '2', 'Sweat gland ducts\nLarger excretory ducts\nAnus (transitional zone)',
     'Protection\nLimited secretion'],
    ['Stratified\nColumnar', 'Multi (columnar surface)', 'Conjunctiva of eye\nLarynx\nAnal canal transition zone\nLarge excretory ducts (rare)',
     'Protection\nSecretion'],
    ['Transitional\n(Urothelium)', 'Multi (variable)', 'Renal calyces and pelvis\nUreter\nUrinary bladder\nProximal urethra',
     'Distensibility\nBarrier against hypertonic urine\nProtection'],
]
master_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 8.5),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), TEAL),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 6),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
    ('ALIGN',      (1,0), (1,-1), 'CENTER'),
])
master_t = Table(master_data, colWidths=[1.15*inch, 0.5*inch, 2.5*inch, 2.15*inch])
master_t.setStyle(master_style)
story.append(master_t)
story.append(Spacer(1, 0.1*inch))

story.append(clinical_box(
    'Vitamin A deficiency causes squamous metaplasia of the respiratory epithelium (pseudostratified '
    'columnar → stratified squamous), impairing mucociliary clearance and increasing infection risk. '
    'Similarly, chronic cigarette smoking causes bronchial epithelium to undergo metaplasia to '
    'stratified squamous epithelium — an early precancerous change. (Junqueira\'s 17e, p. 228–230)'))

story.append(Spacer(1, 0.08*inch))

story += sub_header('2.4 Pseudostratified Epithelium — Detail')
story.append(Paragraph(
    'Pseudostratified columnar epithelium (PCE) is a <b>simple epithelium</b> in which '
    'the cells vary in height and have nuclei at different levels, creating a false '
    'impression of multiple layers. Key features:', body))
pce_items = [
    '<b>All cells touch the basement membrane</b> — this distinguishes it from true stratified',
    'Not all cells reach the free surface (short cells, goblet cells, basal cells stay low)',
    'Nuclei appear at multiple heights → "stratified" appearance under H&amp;E staining',
    '<b>Respiratory tract distribution:</b> nasal cavity, nasopharynx, trachea, bronchi — heavily ciliated',
    '<b>Reproductive:</b> male epididymis and vas deferens — non-ciliated, with stereocilia',
    'Goblet cells intercalated throughout → continuous mucus layer over cilia',
]
for item in pce_items:
    story.append(Paragraph(f'• {item}', bullet))
story.append(Spacer(1, 0.06*inch))

story.append(clinical_box(
    'In chronic bronchitis (e.g., habitual smokers), goblet cell hyperplasia in the '
    'pseudostratified epithelium produces excess mucus that overwhelms the ciliary escalator, '
    'causing airway obstruction. Progressive transformation to stratified squamous epithelium '
    'by metaplasia further impairs mucociliary function. (Junqueira\'s 17e, p. 230)'))

story.append(Spacer(1, 0.08*inch))

story += sub_header('2.5 Transitional Epithelium (Urothelium) — Detail')
story.append(Paragraph(
    'Urothelium is a specialized stratified epithelium unique to the lower urinary tract. '
    'It has three to six cell layers depending on the degree of distension:', body))
uro_items = [
    '<b>Umbrella cells (superficial):</b> large, rounded or dome-shaped; form a critical permeability barrier; connected by tight junctions',
    '<b>Unique asymmetric unit membranes (AUMs):</b> specialized thickened plaques of uroplakins in apical plasma membrane resist hypertonic urine',
    '<b>Distension response:</b> when bladder fills, cells flatten and the epithelium thins; AUM plaques unfold to accommodate increased surface area',
    'Intermediate and basal layers provide structural support',
    'Basal cells rest on the basement membrane and serve as a stem cell reservoir',
]
for item in uro_items:
    story.append(Paragraph(f'• {item}', bullet))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 3 – SURFACE SPECIALIZATIONS
# ═══════════════════════════════════════════════════════════════════════
story += section_header('3. Apical Surface Specializations')

story.append(Paragraph(
    'The apical surface of many epithelia carries structural modifications that expand '
    'functional capacity — particularly for absorption and the movement of substances '
    'over the epithelial surface.', body))

story.append(Spacer(1, 0.08*inch))

surf_data = [
    ['Feature', 'Microvilli', 'Stereocilia', 'Cilia (Motile)', 'Primary Cilia (Non-motile)'],
    ['Structure', 'Short, finger-like projections\n~1–3 μm long, 0.1 μm wide', 'Very long, irregular microvilli\nUp to 120 μm', 'Tall, hair-like\n~10 μm long, 0.25 μm wide', 'Single per cell\n~9–10 μm long'],
    ['Core', 'Actin filaments (villin, fimbrin)', 'Actin filaments (fimbrin, espin, ezrin)', 'Axoneme: 9+2 microtubule doublets + dynein arms', 'Axoneme: 9+0 (no central pair)'],
    ['Motility', 'Non-motile', 'Non-motile', 'Motile (beat ~10–20 Hz)', 'Non-motile (sensors)'],
    ['Terminal web', 'Yes — actin-spectrin network', 'Yes — α-actinin', 'Basal body (modified centriole)', 'Basal body'],
    ['Locations', 'Intestinal brush border\nKidney proximal tubule', 'Epididymis, vas deferens\nInner ear hair cells (mechanoreceptors)', 'Respiratory tract\nFallopian tubes\nEpendyma of brain ventricles', 'Kidney tubules\nAlmost every cell type has 1'],
    ['Main function', 'Greatly increase surface area\nfor absorption (×30 increase)', 'Sperm maturation\nSound transduction (ear)', 'Mucociliary escalator\nOvum transport', 'Mechanosensation\nFlow sensing (kidney)\nLeft-right axis in embryo'],
]
surf_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('BACKGROUND', (0,1), (0,-1), LIGHT_BG),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('FONTSIZE',   (0,0), (-1,-1), 8.5),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 5),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, colors.HexColor('#F5FAFD')]),
])
surf_t = Table(surf_data, colWidths=[1.0*inch, 1.3*inch, 1.3*inch, 1.4*inch, 1.3*inch])
surf_t.setStyle(surf_style)
story.append(surf_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('3.1 Microvilli (Brush Border)')
mv_items = [
    'Composed of ~20–30 parallel actin filaments cross-linked by <b>villin</b> and <b>fimbrin</b>',
    'Filament barbed (+) ends point toward the tips; pointed (–) ends anchor in the <b>terminal web</b>',
    'Terminal web is a meshwork of actin and spectrin just below the microvilli',
    'In the intestine, microvilli increase absorptive surface area by approximately <b>30-fold</b>',
    'Intestinal microvilli are coated by a <b>glycocalyx</b> (carbohydrate-rich coat) that participates in digestion and protection',
]
for item in mv_items:
    story.append(Paragraph(f'• {item}', bullet))

story += sub_header('3.2 Cilia (9+2 Motile)')
cilia_items = [
    'Axoneme structure: <b>9 peripheral doublets (A + B tubules) + 2 central singlets</b> = "9+2"',
    '<b>Dynein arms</b> (ATPases on A tubule) generate sliding force between doublets → bending motion',
    '<b>Nexin links</b> between doublets limit sliding to produce coordinated bending',
    '<b>Radial spokes</b> connect doublets to central sheath — regulate beat pattern',
    'Arise from a <b>basal body</b> (modified centriole, 9+0 triplets) anchored in the apical cytoplasm',
    'Beat in coordinated metachronal waves in respiratory epithelium; move ~20 mm of mucus/minute',
]
for item in cilia_items:
    story.append(Paragraph(f'• {item}', bullet))

story.append(clinical_box(
    '<b>Primary Ciliary Dyskinesia (PCD) / Kartagener Syndrome:</b> Mutations in dynein arm proteins '
    'cause immotile cilia. Clinically: bronchiectasis + chronic sinusitis + situs inversus (50%) '
    'due to failure of nodal cilia to establish L-R asymmetry in embryogenesis. Infertility is common '
    '(non-motile sperm flagella, impaired egg transport). (Ross &amp; Pawlina, p. 348–349)'))

story += sub_header('3.3 Primary Cilia (9+0 Sensory)')
pc_items = [
    'Virtually every mammalian cell bears a single primary cilium on its surface',
    'Axoneme: <b>9+0 pattern</b> — 9 doublets, NO central pair, NO dynein arms = non-motile',
    '<b>Function as cellular antennae</b> — sense chemical and mechanical signals from the environment',
    '<b>Kidney:</b> primary cilia of tubular cells sense urine flow; bending opens <b>polycystin-1/2</b> Ca²⁺ channels',
    '<b>Nodal cilia (embryo):</b> a special motile 9+0 type that rotates to generate leftward nodal flow, determining organ situs',
]
for item in pc_items:
    story.append(Paragraph(f'• {item}', bullet))

story.append(clinical_box(
    '<b>Autosomal Dominant Polycystic Kidney Disease (ADPKD):</b> Mutations in polycystin-1 or '
    'polycystin-2 (the Ca²⁺ channel sensed by primary cilia) leads to failure of flow-sensing. '
    'Affects 1:500–1,000 individuals; expanding renal cysts ultimately cause renal failure. '
    'Extra-renal manifestations include hepatic/pancreatic cysts, intracranial aneurysms, and '
    'mitral valve prolapse. (Ross &amp; Pawlina, p. 757–759)'))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 4 – CELL JUNCTIONS
# ═══════════════════════════════════════════════════════════════════════
story += section_header('4. Cell Junctions')

story.append(Paragraph(
    'Epithelial cells are held together and communicate through specialized junctional complexes. '
    'In columnar epithelia, the <b>junctional complex</b> consists of three structures from apex to base: '
    'zonula occludens → zonula adherens → macula adherens (desmosome). Gap junctions and '
    'hemidesmosomes provide additional connectivity.', body))

story.append(Spacer(1, 0.08*inch))

jx_data = [
    ['Junction', 'Also Called', 'Proteins', 'Structure/Anchoring', 'Function'],
    ['Tight Junction\n(Zonula Occludens)', 'TJ, ZO', 'Claudins, Occludins, JAMs\nZO-1, ZO-2 (cytoplasmic)', 'Fused transmembrane strands\nSeal intercellular space\nAcrosome',
     'Paracellular barrier\nMaintain cell polarity\nPrevent membrane protein mixing\nbetween apical and basolateral'],
    ['Adherens Junction\n(Zonula Adherens)', 'ZA, AJ', 'E-cadherin (transmembrane)\nα-, β-, p120-catenin (cytoplasmic)', 'Belt-like band around entire cell circumference; anchors to actin filaments',
     'Cell-cell adhesion\nSignal transduction (β-catenin/Wnt)\nMaintain tissue architecture'],
    ['Desmosome\n(Macula Adherens)', 'Spot desmosome', 'Desmoglein, Desmocollin (cadherins)\nDesmoplakin, Plakophilin, Plakoglobin',
     'Disc/rivet-shaped; anchors to intermediate filaments (cytokeratin → desmin in muscle)',
     'Resist mechanical stress\nTension distribution\nStrong adhesion (skin, cardiac)'],
    ['Gap Junction', 'Nexus', 'Connexins (6 form a connexon)\nConnexon pairs between cells',
     'Plaques of aligned connexon channels (1.5 nm pore)',
     'Intercellular communication\nPass ions, cAMP, IP3 (<1.5 nm)\nCoordinate cardiac/smooth muscle'],
    ['Hemidesmosome', 'HD', 'Integrins (α6β4)\nPlectin, BP230 (BPAG1)\nBP180 (BPAG2)',
     'Half-desmosome at basal surface; links intermediate filaments to laminin in basal lamina',
     'Anchor epithelium to basement membrane / connective tissue'],
]
jx_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('BACKGROUND', (0,1), (0,-1), LIGHT_BG),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('FONTSIZE',   (0,0), (-1,-1), 8),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 5),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
])
jx_t = Table(jx_data, colWidths=[1.15*inch, 0.9*inch, 1.35*inch, 1.55*inch, 1.35*inch])
jx_t.setStyle(jx_style)
story.append(jx_t)
story.append(Spacer(1, 0.1*inch))

story.append(clinical_box(
    '<b>Pemphigus vulgaris:</b> Autoantibodies against desmoglein-3 (and desmoglein-1) destroy '
    'desmosomes in the epidermis and oral mucosa, causing suprabasal acantholysis — blisters '
    'form within the epidermis (intraepidermal). Contrast with bullous pemphigoid, where '
    'antibodies target BP180/BP230 of hemidesmosomes → subepidermal blisters. '
    'The Nikolsky sign (skin slides off with lateral pressure) is positive in pemphigus. '))

story.append(Spacer(1, 0.06*inch))

story.append(clinical_box(
    '<b>β-catenin and cancer:</b> β-catenin, the cytoplasmic partner of E-cadherin in adherens '
    'junctions, also functions in the Wnt signaling pathway. Mutations that stabilize free '
    'β-catenin (e.g., loss of APC in colorectal cancer) lead to nuclear translocation, activate '
    'transcription factors (TCF/LEF), and drive cell proliferation — a key cancer mechanism.'))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 5 – BASEMENT MEMBRANE
# ═══════════════════════════════════════════════════════════════════════
story += section_header('5. Basement Membrane')

story.append(Paragraph(
    'The basement membrane (BM) is a specialized extracellular matrix sheet underlying all '
    'epithelial cells. It is a <b>semipermeable filter</b> and structural scaffold jointly '
    'secreted by epithelial cells and connective tissue fibroblasts.', body))

story.append(Spacer(1, 0.08*inch))

story += sub_header('5.1 Structural Layers')
bm_layers = [
    ['Layer', 'Components', 'Notes'],
    ['Lamina lucida\n(lamina rara)', 'Laminin, entactin/nidogen', 'Electron-lucent by TEM; ≈20–40 nm thick'],
    ['Lamina densa\n(basal lamina proper)', 'Type IV collagen (network), laminin, perlecan (heparan sulfate PG)', 'Electron-dense; forms the filter; ~50 nm thick'],
    ['Lamina reticularis\n(reticular lamina)', 'Type III collagen (reticular fibers), fibronectin', 'Connective tissue contribution; visible by silver stain; NOT in BM of capillaries'],
]
bm_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTSIZE',   (0,0), (-1,-1), 9),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
bm_t = Table(bm_layers, colWidths=[1.3*inch, 2.3*inch, 2.7*inch])
bm_t.setStyle(bm_style)
story.append(bm_t)
story.append(Spacer(1, 0.08*inch))

story += sub_header('5.2 Functions')
bm_funcs = [
    '<b>Structural support:</b> Anchors epithelium to underlying connective tissue',
    '<b>Filtration:</b> Selectively permeable to macromolecules (highly developed in glomerular BM)',
    '<b>Cell behavior regulation:</b> Binds growth factors (FGF, TGF-β); influences proliferation, differentiation, migration',
    '<b>Barrier to cancer invasion:</b> Malignant cells must breach the BM to become invasive carcinoma (vs. carcinoma in situ)',
    '<b>Wound healing scaffold:</b> Guides epithelial cell migration during repair',
]
for item in bm_funcs:
    story.append(Paragraph(f'• {item}', bullet))

story.append(Spacer(1, 0.06*inch))
story.append(clinical_box(
    '<b>Goodpasture syndrome:</b> Autoantibodies against the α3 chain of type IV collagen attack '
    'glomerular and alveolar basement membranes → rapidly progressive glomerulonephritis and '
    'pulmonary hemorrhage. Diagnosis: linear IgG deposits along the GBM on immunofluorescence. '
    'Treatment: plasmapheresis + immunosuppression.'))

story.append(clinical_box(
    '<b>Alport syndrome:</b> X-linked (COL4A5 mutation) or AR (COL4A3/4) defect in type IV '
    'collagen → abnormal glomerular BM → hematuria, progressive renal failure, sensorineural '
    'hearing loss, ocular defects. The "basketweave" pattern of GBM on EM is pathognomonic.'))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 6 – GLANDS
# ═══════════════════════════════════════════════════════════════════════
story += section_header('6. Secretory Epithelia & Glands')

story.append(Paragraph(
    'Glands develop embryologically from surface epithelia by invagination into underlying '
    'connective tissue, followed by differentiation. <b>Exocrine glands</b> retain a duct '
    'connection; <b>endocrine glands</b> lose it.', body))

story.append(Spacer(1, 0.08*inch))

story += sub_header('6.1 Exocrine vs. Endocrine')
endo_exo_data = [
    ['Feature', 'Exocrine Glands', 'Endocrine Glands'],
    ['Duct', 'Present — delivers secretion to surface or specific organ', 'Absent — secretion released into bloodstream'],
    ['Product delivery', 'Directly to epithelial surface / lumen', 'Via blood to distant target organs'],
    ['Product type', 'Enzymes, mucus, sweat, sebum, milk, saliva', 'Hormones (proteins, steroids, amines)'],
    ['Vascularity', 'Moderate', 'Richly vascularized (capillary network)'],
    ['Examples', 'Salivary glands, pancreas (exocrine), sweat glands, liver', 'Thyroid, adrenal cortex, anterior pituitary, islets of Langerhans, ovary'],
]
endo_exo_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('BACKGROUND', (0,1), (0,-1), LIGHT_BG),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('FONTSIZE',   (0,0), (-1,-1), 9),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 8),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
endo_exo_t = Table(endo_exo_data, colWidths=[1.2*inch, 2.55*inch, 2.55*inch])
endo_exo_t.setStyle(endo_exo_style)
story.append(endo_exo_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('6.2 Classification of Exocrine Glands')
story.append(Paragraph(
    'Exocrine glands are classified by: (A) number of cells, (B) duct structure, '
    '(C) secretory unit shape, and (D) secretion mechanism.', body))
story.append(Spacer(1, 0.06*inch))

# Table: Secretion mechanisms
mech_data = [
    ['Mechanism', 'How', 'Products', 'Examples'],
    ['Merocrine\n(Eccrine)', 'Exocytosis of secretory vesicles;\ncell remains intact',
     'Proteins, polysaccharides\nenzymes, mucus',
     'Pancreatic acinar cells\nMost salivary glands\nEccrine sweat glands'],
    ['Apocrine', 'Apical cytoplasm buds off\nwith secretory product',
     'Lipids (fatty acids, steroids)\nsome proteins',
     'Mammary glands (lipid)\nApocrine sweat glands (axilla)'],
    ['Holocrine', 'Entire cell disintegrates\ninto secretion',
     'Lipids + dead cell debris\n(sebum)',
     'Sebaceous glands of skin'],
]
mech_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('FONTSIZE',   (0,0), (-1,-1), 9),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 7),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
mech_t = Table(mech_data, colWidths=[1.1*inch, 1.7*inch, 1.7*inch, 1.8*inch])
mech_t.setStyle(mech_style)
story.append(mech_t)
story.append(Spacer(1, 0.08*inch))

# Duct structure classification
story.append(Paragraph('<b>Duct &amp; Secretory Unit Classification of Exocrine Glands:</b>', h3))
duct_data = [
    ['Category', 'Types', 'Examples'],
    ['By number of cells', 'Unicellular — single secretory cell (e.g., goblet cell)\nMulticellular — gland with multiple cells', 'Goblet cells in GI/respiratory\nAll named glands'],
    ['By duct branching', 'Simple — single, unbranched duct\nCompound — branched duct system', 'Intestinal crypts, sweat glands\nPancreas, parotid, submandibular'],
    ['By secretory unit shape', 'Tubular — cylindrical, elongated secretory units\nAcinar/Alveolar — rounded, flask-shaped secretory units\nTubuloalveolar — both types present', 'Gastric glands, colon crypts\nPancreas, parotid (serous)\nSubmandibular, sublingual, mammary'],
    ['By secretion type', 'Serous — watery, protein-rich secretion; dark-staining nuclei, zymogen granules, RER-rich\nMucous — thick, carbohydrate-rich; pale-staining nuclei compressed to base\nSeromucous (mixed) — both cell types', 'Parotid (purely serous)\nSublingual (mainly mucous)\nSubmandibular (mixed)'],
]
duct_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), TEAL),
    ('FONTSIZE',   (0,0), (-1,-1), 8.5),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 7),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
duct_t = Table(duct_data, colWidths=[1.2*inch, 2.5*inch, 2.6*inch])
duct_t.setStyle(duct_style)
story.append(duct_t)
story.append(Spacer(1, 0.08*inch))

story.append(key_point_box(
    'Serous cells have a round, basal nucleus; abundant RER (basophilic cytoplasm); apical '
    'zymogen granules (acidophilic). Mucous cells have a flattened, basal nucleus; pale '
    'cytoplasm (mucin dissolved in routine H&amp;E); best seen with PAS stain (purple). '
    'In mixed glands, serous cells cap mucous acini as "serous demilunes."'))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 7 – CELL RENEWAL & CLINICAL
# ═══════════════════════════════════════════════════════════════════════
story += section_header('7. Cell Renewal, Metaplasia & Clinical Correlations')

story += sub_header('7.1 Epithelial Cell Renewal')
story.append(Paragraph(
    'Epithelial cells are among the most metabolically active and rapidly replaced cells in '
    'the body. Renewal rates vary dramatically by tissue:', body))

renewal_data = [
    ['Epithelium', 'Renewal Rate', 'Stem Cell Location'],
    ['Intestinal epithelium', '~5–7 days', 'Crypts of Lieberkühn (crypt base columnar cells)'],
    ['Epidermis (skin)', '~2–4 weeks (stratum basale → stratum corneum)', 'Stratum basale + hair follicle bulge'],
    ['Cornea', '~7–10 days (surface)', 'Limbal stem cells at corneoscleral junction'],
    ['Respiratory epithelium', 'Weeks to months', 'Basal cells on basement membrane'],
    ['Large glands (liver)', 'Slow normally; rapid after injury', 'Hepatocytes + portal tract progenitors'],
    ['Urothelium', 'Weeks–months', 'Basal cells'],
]
ren_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), TEAL),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('FONTSIZE',   (0,0), (-1,-1), 9),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, LIGHT_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 7),
    ('VALIGN',     (0,0), (-1,-1), 'MIDDLE'),
])
ren_t = Table(renewal_data, colWidths=[1.6*inch, 1.9*inch, 2.8*inch])
ren_t.setStyle(ren_style)
story.append(ren_t)
story.append(Spacer(1, 0.08*inch))

story += sub_header('7.2 Metaplasia')
story.append(Paragraph(
    '<b>Metaplasia</b> is the reversible transformation of one differentiated epithelial '
    'type into another. It is an adaptive response, usually to chronic irritation, and '
    'is a pre-neoplastic risk:', body))

meta_data = [
    ['Metaplasia', 'Stimulus', 'Normal → Changed', 'Risk'],
    ["Barrett's esophagus", 'Chronic GERD (acid reflux)', 'Stratified squamous → Simple columnar intestinal (goblet cells)', 'Adenocarcinoma of esophagus'],
    ['Bronchial squamous metaplasia', 'Cigarette smoke', 'Pseudostratified ciliated columnar → Stratified squamous', 'Squamous cell carcinoma lung'],
    ['Cervical squamous metaplasia', 'HPV, hormonal (puberty)', 'Columnar endocervical → Squamous (transformation zone)', 'Cervical squamous cell carcinoma'],
    ['Bladder squamous metaplasia', 'Schistosoma haematobium, stones', 'Urothelium → Stratified squamous', 'Squamous cell carcinoma bladder'],
    ['Vitamin A deficiency', 'Hypovitaminosis A', 'Respiratory/bladder epithelium → Stratified squamous', 'Infection risk, impaired function'],
]
meta_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), colors.HexColor('#8B0000')),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), colors.HexColor('#8B0000')),
    ('FONTSIZE',   (0,0), (-1,-1), 8.5),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, PINK_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, colors.HexColor('#E8A0A0')),
    ('TOPPADDING',    (0,0), (-1,-1), 5),
    ('BOTTOMPADDING', (0,0), (-1,-1), 5),
    ('LEFTPADDING',   (0,0), (-1,-1), 7),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
meta_t = Table(meta_data, colWidths=[1.2*inch, 1.1*inch, 2.2*inch, 1.8*inch])
meta_t.setStyle(meta_style)
story.append(meta_t)
story.append(Spacer(1, 0.08*inch))

story += sub_header('7.3 Dysplasia and Carcinoma')
dysp_items = [
    '<b>Dysplasia:</b> Abnormal growth with disordered maturation and nuclear atypia; potentially reversible; precancerous',
    '<b>Carcinoma in situ (CIS):</b> Full-thickness dysplasia; malignant cytology; basement membrane <b>intact</b>',
    '<b>Invasive carcinoma:</b> Malignant cells breach the basement membrane; metastasis now possible',
    'Carcinomas are named by origin: squamous cell carcinoma, adenocarcinoma (glandular origin), transitional cell (urothelial) carcinoma',
    '<b>Adenocarcinomas are the most common carcinomas in adults after age 45</b> (Junqueira\'s 17e)',
]
for item in dysp_items:
    story.append(Paragraph(f'• {item}', bullet))

story.append(PageBreak())

# ═══════════════════════════════════════════════════════════════════════
# SECTION 8 – QUICK REFERENCE
# ═══════════════════════════════════════════════════════════════════════
story += section_header('8. Quick Reference, Mnemonics & Review Questions')

story += sub_header('8.1 Mnemonics')

mnem_items = [
    ('Simple epithelia — "SAFE": ', 'S = Simple Squamous (exchange), A = Alveoli, F = Filtration (glomerulus), E = Endothelium'),
    ('Secretion modes — "MAH":', 'M = Merocrine (most glands — vesicle exocytosis), A = Apocrine (mammary — buds off), H = Holocrine (sebaceous — whole cell)'),
    ('Junctional complex (apical to basal):', '"TaD" = Tight (Zonula Occludens) → adherens (Zonula Adherens) → Desmosome (Macula Adherens)'),
    ('Ciliary axoneme 9+2 vs 9+0:', '"Two for motion, zero for sensor" — 9+2 = motile; 9+0 = primary (sensory); except nodal cilia (9+0 but motile)'),
    ('Serous vs Mucous cells:', '"Serous = Dark base, apical granules (basophilic RER); Mucous = Pale cytoplasm, flattened base nucleus"'),
]
for label, content in mnem_items:
    t = Table([[Paragraph(f'<b>{label}</b> {content}', 
                          ParagraphStyle('mn', fontName='Helvetica', fontSize=10,
                                         textColor=colors.HexColor('#1A5C2A'), leading=14))]],
              colWidths=[6.3*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), GREEN_BG),
        ('BOX',        (0,0), (-1,-1), 1, colors.HexColor('#4CAF50')),
        ('TOPPADDING',    (0,0), (-1,-1), 6),
        ('BOTTOMPADDING', (0,0), (-1,-1), 6),
        ('LEFTPADDING',   (0,0), (-1,-1), 10),
        ('LINELEFT', (0,0), (0,-1), 4, colors.HexColor('#2E7D32')),
    ]))
    story.append(t)
    story.append(Spacer(1, 0.05*inch))

story.append(Spacer(1, 0.08*inch))

story += sub_header('8.2 High-Yield Facts for Exams')

hy_data = [
    ['Fact', 'Detail'],
    ['Most common adult carcinoma type', 'Adenocarcinoma (from glandular epithelium)'],
    ['Kartagener syndrome triad', 'Bronchiectasis + sinusitis + situs inversus (50%)\nCause: dynein arm mutation → immotile cilia'],
    ['Bowman\'s capsule epithelium', 'Simple squamous (parietal layer); permits filtration'],
    ['Proximal tubule brush border', 'Simple cuboidal with abundant microvilli; reabsorption of 65% of filtrate'],
    ['Goblet cells — location & stain', 'GI tract and respiratory; PAS-positive (mucin); single unicellular gland'],
    ['Transitional epithelium unique feature', 'Uroplakin-containing asymmetric unit membranes (AUMs); distension capacity'],
    ['Barrett\'s esophagus risk', 'Columnar metaplasia due to GERD → adenocarcinoma risk'],
    ['Sebaceous gland secretion mode', 'Holocrine — entire cell disintegrates into sebum'],
    ['Mammary gland lipid secretion mode', 'Apocrine — apical cytoplasm buds off carrying lipid droplets'],
    ['Stratum basale function', 'Only proliferating layer; contains stem cells; rests on BM'],
    ['Tight junction key proteins', 'Claudins and occludins; maintain paracellular barrier and cell polarity'],
    ['Desmosome link to cytoskeleton', 'Cytokeratin intermediate filaments (not actin)'],
    ['Gap junction channel size', '~1.5 nm; passes ions, cAMP, IP3; coordinates cardiac rhythm'],
    ['Hemidesmosome vs desmosome', 'HD: integrin + laminin (cell to BM); desmosome: cadherin + cadherin (cell to cell)'],
    ['Pemphigus vulgaris target', 'Desmoglein-3/1 → intraepidermal blisters; Nikolsky sign (+)'],
    ['Goodpasture target', 'Type IV collagen (α3 chain) in glomerular + alveolar BM'],
    ['Alport syndrome', 'COL4A5 mutation (X-linked) → abnormal GBM → hematuria, renal failure, deafness, ocular'],
]
hy_style = TableStyle([
    ('BACKGROUND', (0,0), (-1,0), NAVY),
    ('TEXTCOLOR',  (0,0), (-1,0), colors.white),
    ('FONTNAME',   (0,0), (-1,0), 'Helvetica-Bold'),
    ('FONTNAME',   (0,1), (0,-1), 'Helvetica-Bold'),
    ('TEXTCOLOR',  (0,1), (0,-1), NAVY),
    ('FONTSIZE',   (0,0), (-1,-1), 8.5),
    ('ROWBACKGROUNDS', (0,1), (-1,-1), [colors.white, YELLOW_BG]),
    ('GRID',       (0,0), (-1,-1), 0.5, BORDER),
    ('TOPPADDING',    (0,0), (-1,-1), 4),
    ('BOTTOMPADDING', (0,0), (-1,-1), 4),
    ('LEFTPADDING',   (0,0), (-1,-1), 7),
    ('VALIGN',     (0,0), (-1,-1), 'TOP'),
])
hy_t = Table(hy_data, colWidths=[2.2*inch, 4.1*inch])
hy_t.setStyle(hy_style)
story.append(hy_t)
story.append(Spacer(1, 0.1*inch))

story += sub_header('8.3 Practice Review Questions')
story.append(Paragraph('<i>Answers at the end of each question (in parentheses).</i>', footnote))
story.append(Spacer(1, 0.04*inch))

questions = [
    ('1.', 'A 35-year-old male presents with chronic sinusitis, bronchiectasis, and infertility. '
           'Semen analysis shows non-motile sperm. Which ultrastructural defect best explains this?',
     'Absent/defective dynein arms in the axoneme (9+2 pattern) → Primary Ciliary Dyskinesia. '
     'Kartagener syndrome if situs inversus present.'),
    ('2.', 'On H&amp;E staining of a section from the upper respiratory tract, you see cells at '
           'various nuclear heights all appearing to contact a basement membrane, with some cells '
           'bearing cilia and others being flask-shaped. What epithelial type is this?',
     'Pseudostratified ciliated columnar epithelium with goblet cells (respiratory/tracheal lining).'),
    ('3.', 'A patient with GERD undergoes endoscopy. Biopsy of the lower esophagus shows columnar '
           'cells with goblet cells. What process has occurred and what is the cancer risk?',
     'Squamous → columnar (intestinal) metaplasia = Barrett\'s esophagus. Risk: esophageal adenocarcinoma.'),
    ('4.', 'Which junction type is responsible for maintaining epithelial cell polarity and forming '
           'the paracellular permeability barrier?',
     'Tight junction (zonula occludens) — claudins and occludins fuse membranes; prevent mixing of '
     'apical and basolateral membrane proteins.'),
    ('5.', 'Autoantibodies against desmoglein-3 cause which disease, and what is the histological finding?',
     'Pemphigus vulgaris — suprabasal acantholysis; intraepidermal blister; Nikolsky sign positive.'),
    ('6.', 'A kidney biopsy shows linear IgG deposition along the glomerular basement membrane. '
           'The patient also has pulmonary hemorrhage. What is the diagnosis and molecular target?',
     'Goodpasture syndrome — autoantibodies against the α3 chain of type IV collagen in the GBM and alveolar BM.'),
    ('7.', 'The sebaceous gland secretes sebum by which secretory mechanism?',
     'Holocrine secretion — entire cell disintegrates; sebum = lipid + cell debris. Contrast: '
     'eccrine sweat = merocrine; mammary lipid = apocrine.'),
    ('8.', 'Compare serous and mucous acinar cells under H&amp;E staining.',
     'Serous: round basal nucleus, basophilic cytoplasm (RER-rich), apical eosinophilic zymogen granules. '
     'Mucous: flattened basal nucleus, pale/clear cytoplasm (mucin dissolved), PAS-positive.'),
]
q_style = ParagraphStyle('q', fontName='Helvetica-Bold', fontSize=10, textColor=NAVY, leading=14, spaceBefore=5)
a_style = ParagraphStyle('a', fontName='Helvetica-Oblique', fontSize=9.5, textColor=MED_GRAY, leading=13,
                          leftIndent=20, spaceAfter=8)
for num, q, a in questions:
    story.append(Paragraph(f'{num} {q}', q_style))
    story.append(Paragraph(f'▶ {a}', a_style))
    story.append(rule(BORDER, 0.5))

story.append(Spacer(1, 0.12*inch))

# Footer / Sources
story.append(rule(NAVY, 1.5))
story.append(Paragraph(
    'Sources: Junqueira\'s Basic Histology: Text and Atlas, 17th Edition (McGraw-Hill) | '
    'Ross &amp; Pawlina: Histology: A Text and Atlas with Correlated Cell and Molecular Biology '
    '(Wolters Kluwer) | Generated by Orris Medical Library, June 2026',
    footnote))

# ── Build ─────────────────────────────────────────────────────────────────────
doc.build(story)
print(f'PDF successfully created: {OUTPUT}')
Running Command

cd /home/daytona/workspace/epithelial-study-guide && python3 generate_guide.py 2>&1

Running Command

ls -lh /home/daytona/workspace/epithelial-study-guide/Epithelial_Tissue_Study_Guide.pdf

Your study guide is ready:

Epithelial Tissue Study Guide

PDF Document · PDF


Here's what's inside (8 sections, sourced directly from Junqueira's Basic Histology 17e and Ross & Pawlina's Histology: A Text and Atlas):
SectionContents
1. OverviewDefinition, defining characteristics, principal functions, embryonic origins by germ layer
2. ClassificationFull master table of all epithelial types - layers, locations, functions; cell shape terminology; pseudostratified and urothelium detail
3. Surface SpecializationsMicrovilli (brush border), stereocilia, motile cilia (9+2), primary cilia (9+0) - structure, molecular components, functions
4. Cell JunctionsTight, adherens, desmosome, gap junction, hemidesmosome - proteins, anchoring filaments, functions
5. Basement MembraneThree-layer structure (lamina lucida, densa, reticularis), molecular components, functions
6. GlandsExocrine vs. endocrine; merocrine/apocrine/holocrine; simple vs. compound; serous vs. mucous
7. Cell Renewal & MetaplasiaRenewal rates by tissue, stem cell locations, metaplasia table with cancer risks
8. Quick ReferenceMnemonics, 17 high-yield exam facts, 8 clinical vignette-style review questions with answers
Clinical correlations throughout include: Kartagener syndrome, ADPKD, Barrett's esophagus, Pemphigus vulgaris, Goodpasture syndrome, Alport syndrome, chronic bronchitis, and vitamin A deficiency.
This is a shared conversation. Sign in to Orris to start your own chat.