> ## Documentation Index
> Fetch the complete documentation index at: https://resources.latex-cloud-studio.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Write Beautiful Math in LaTeX - Complete Guide

> Master LaTeX math typesetting with this comprehensive guide. Learn equations, symbols, matrices, and advanced formatting to create publication-quality mathematical documents.

export const RenderedOutput = ({title = "Rendered output", ctaHref, ctaLabel = "Open LaTeX Cloud Studio", children}) => {
  const [isExpanded, setIsExpanded] = useState(false);
  const trackEditorCta = () => {
    const target = new URL(ctaHref, window.location.href);
    globalThis.posthog?.capture?.("docs_app_cta_clicked", {
      source_page: window.location.pathname,
      source_section: "rendered_output",
      cta_variant: "first_compiled_example",
      target_url: target.toString(),
      target_utm_source: target.searchParams.get("utm_source"),
      target_utm_medium: target.searchParams.get("utm_medium"),
      target_utm_campaign: target.searchParams.get("utm_campaign"),
      target_utm_content: target.searchParams.get("utm_content")
    }, {
      transport: "sendBeacon",
      send_instantly: true
    });
  };
  return <details className="rendered-output" onToggle={event => setIsExpanded(event.currentTarget.open)}>
      <summary className="rendered-output__summary">
        <span className="rendered-output__title">{title}</span>
        <span className="rendered-output__hint" aria-hidden="true">View compiled result</span>
      </summary>
      {isExpanded && <div className="rendered-output__content">
          {children}
          {ctaHref && <aside className="rendered-output__cta" aria-label="Continue in the LaTeX editor">
              <span>
                <strong>Ready to use this syntax?</strong>
                Continue in the browser editor when you want to adapt the example in a real project.
              </span>
              <a href={ctaHref} onClick={trackEditorCta}>{ctaLabel}<span aria-hidden="true"> →</span></a>
            </aside>}
        </div>}
    </details>;
};

export const LatexSource = ({filename, source}) => {
  const [copyStatus, setCopyStatus] = useState("Copy");
  const copySource = async () => {
    try {
      await navigator.clipboard.writeText(source);
      setCopyStatus("Copied");
    } catch {
      setCopyStatus("Select and copy");
    }
  };
  return <figure className="latex-source">
      <figcaption className="latex-source__header">
        <span className="latex-source__filename">{filename}</span>
        <button type="button" className="latex-source__copy" onClick={copySource} aria-live="polite">
          {copyStatus}
        </button>
      </figcaption>
      <pre className="latex-source__pre" aria-label={`LaTeX source: ${filename}`} tabIndex="0">
        <code className="language-latex">{source}</code>
      </pre>
    </figure>;
};

export const LatexPreview = ({src, alt, caption, width, height}) => {
  const minZoom = 1;
  const maxZoom = 3;
  const zoomStep = 0.5;
  const measureSvgContent = async (assetSrc, pageWidth, pageHeight) => {
    const cacheKey = "__latexCloudSvgContentBoxCache";
    const contentBoxCache = globalThis[cacheKey] ?? new Map();
    globalThis[cacheKey] = contentBoxCache;
    if (contentBoxCache.has(assetSrc)) return contentBoxCache.get(assetSrc);
    const measurement = (async () => {
      const assetUrl = new URL(assetSrc, window.location.href);
      if (assetUrl.origin !== window.location.origin) {
        throw new Error("Rendered output must use a same-origin SVG asset.");
      }
      const response = await fetch(assetUrl, {
        credentials: "same-origin"
      });
      if (!response.ok) throw new Error(`Rendered output request failed with ${response.status}.`);
      const source = await response.text();
      const documentNode = new DOMParser().parseFromString(source, "image/svg+xml");
      if (documentNode.querySelector("parsererror")) throw new Error("Rendered output is not valid SVG.");
      const sourceSvg = documentNode.documentElement;
      sourceSvg.querySelectorAll("script, foreignObject").forEach(node => node.remove());
      [sourceSvg, ...sourceSvg.querySelectorAll("*")].forEach(node => {
        [...node.attributes].forEach(attribute => {
          if ((/^on/i).test(attribute.name)) node.removeAttribute(attribute.name);
          if ((attribute.name === "href" || attribute.name === "xlink:href") && !attribute.value.startsWith("#")) {
            node.removeAttribute(attribute.name);
          }
        });
      });
      const measurementHost = document.createElement("div");
      measurementHost.className = "latex-preview__measurement-host";
      const measuredSvg = document.importNode(sourceSvg, true);
      measuredSvg.setAttribute("aria-hidden", "true");
      measurementHost.appendChild(measuredSvg);
      document.body.appendChild(measurementHost);
      try {
        const measuredElements = [...measuredSvg.children].filter(node => !["defs", "desc", "metadata", "style", "title"].includes(node.tagName.toLowerCase()));
        const elementBounds = measuredElements.map(node => node.getBBox()).filter(box => [box.x, box.y, box.width, box.height].every(Number.isFinite) && box.width > 0 && box.height > 0);
        if (elementBounds.length === 0) {
          throw new Error("Rendered output has no measurable visible content.");
        }
        const sortedBounds = [...elementBounds].sort((left, right) => left.y - right.y);
        const clusterGap = pageHeight * 0.045;
        const clusters = [];
        sortedBounds.forEach(box => {
          const current = clusters[clusters.length - 1];
          if (!current || box.y - current.bottom > clusterGap) {
            clusters.push({
              boxes: [box],
              bottom: box.y + box.height
            });
            return;
          }
          current.boxes.push(box);
          current.bottom = Math.max(current.bottom, box.y + box.height);
        });
        const contentClusters = clusters.filter(cluster => {
          const clusterBox = cluster.boxes.reduce((combined, box) => {
            const right = Math.max(combined.x + combined.width, box.x + box.width);
            const bottom = Math.max(combined.y + combined.height, box.y + box.height);
            const x = Math.min(combined.x, box.x);
            const y = Math.min(combined.y, box.y);
            return {
              x,
              y,
              width: right - x,
              height: bottom - y
            };
          });
          const centerY = clusterBox.y + clusterBox.height / 2;
          const isMarginFurniture = cluster.boxes.length <= 2 && clusterBox.width < pageWidth * 0.2 && clusterBox.height < pageHeight * 0.04 && (centerY < pageHeight * 0.08 || centerY > pageHeight * 0.8);
          return !isMarginFurniture;
        });
        const visibleBounds = (contentClusters.length > 0 ? contentClusters : clusters).flatMap(cluster => cluster.boxes);
        const bounds = visibleBounds.reduce((combined, box) => {
          const right = Math.max(combined.x + combined.width, box.x + box.width);
          const bottom = Math.max(combined.y + combined.height, box.y + box.height);
          const x = Math.min(combined.x, box.x);
          const y = Math.min(combined.y, box.y);
          return {
            x,
            y,
            width: right - x,
            height: bottom - y
          };
        });
        const clampValue = (value, minimum, maximum) => Math.min(maximum, Math.max(minimum, value));
        const padding = Math.max(8, Math.min(pageWidth, pageHeight) * 0.025);
        const x = clampValue(bounds.x - padding, 0, pageWidth);
        const y = clampValue(bounds.y - padding, 0, pageHeight);
        const right = clampValue(bounds.x + bounds.width + padding, 0, pageWidth);
        const bottom = clampValue(bounds.y + bounds.height + padding, 0, pageHeight);
        return {
          x,
          y,
          width: right - x,
          height: bottom - y
        };
      } finally {
        measurementHost.remove();
      }
    })();
    contentBoxCache.set(assetSrc, measurement);
    measurement.catch(() => contentBoxCache.delete(assetSrc));
    return measurement;
  };
  const renderPreviewAsset = ({contentBox: assetContentBox, loading}) => {
    if (!assetContentBox) {
      return <img className="latex-preview__asset" src={src} alt={alt} width={width} height={height} loading={loading} draggable="false" />;
    }
    return <svg className="latex-preview__asset" viewBox={`${assetContentBox.x} ${assetContentBox.y} ${assetContentBox.width} ${assetContentBox.height}`} preserveAspectRatio="xMidYMid meet" role="img" aria-label={alt}>
        <image href={src} x="0" y="0" width={width} height={height} />
      </svg>;
  };
  const [isOpen, setIsOpen] = useState(false);
  const [frameMode, setFrameMode] = useState("content");
  const [viewMode, setViewMode] = useState("fit");
  const [zoom, setZoom] = useState(minZoom);
  const [contentBox, setContentBox] = useState(null);
  const [measurementStatus, setMeasurementStatus] = useState("loading");
  const dialogRef = useRef(null);
  const closeButtonRef = useRef(null);
  const viewportRef = useRef(null);
  const previousFocusRef = useRef(null);
  const dragRef = useRef(null);
  useEffect(() => {
    let isCurrent = true;
    setMeasurementStatus("loading");
    measureSvgContent(src, width, height).then(box => {
      if (!isCurrent) return;
      setContentBox(box);
      setMeasurementStatus("ready");
    }).catch(() => {
      if (!isCurrent) return;
      setContentBox(null);
      setFrameMode("page");
      setMeasurementStatus("error");
    });
    return () => {
      isCurrent = false;
    };
  }, [height, src, width]);
  const closeViewer = useCallback(() => {
    setIsOpen(false);
  }, []);
  const openViewer = () => {
    previousFocusRef.current = document.activeElement;
    setFrameMode(contentBox ? "content" : "page");
    setViewMode("fit");
    setZoom(minZoom);
    setIsOpen(true);
  };
  const applyZoom = useCallback(nextZoom => {
    const boundedZoom = Math.min(maxZoom, Math.max(minZoom, nextZoom));
    setViewMode("custom");
    setZoom(boundedZoom);
  }, []);
  const zoomIn = useCallback(() => {
    applyZoom(viewMode === "fit" ? minZoom + zoomStep : zoom + zoomStep);
  }, [applyZoom, viewMode, zoom]);
  const zoomOut = useCallback(() => {
    applyZoom(viewMode === "fit" ? minZoom : zoom - zoomStep);
  }, [applyZoom, viewMode, zoom]);
  useEffect(() => {
    if (!isOpen) return undefined;
    const previousOverflow = document.body.style.overflow;
    document.body.style.overflow = "hidden";
    closeButtonRef.current?.focus();
    return () => {
      document.body.style.overflow = previousOverflow;
      previousFocusRef.current?.focus?.();
    };
  }, [isOpen]);
  useEffect(() => {
    if (!isOpen) return undefined;
    const handleKeyDown = event => {
      if (event.key === "Escape") {
        event.preventDefault();
        closeViewer();
        return;
      }
      if ((event.key === "+" || event.key === "=") && !event.metaKey && !event.ctrlKey) {
        event.preventDefault();
        zoomIn();
        return;
      }
      if (event.key === "-" && !event.metaKey && !event.ctrlKey) {
        event.preventDefault();
        zoomOut();
        return;
      }
      if (event.key !== "Tab" || !dialogRef.current) return;
      const focusable = [...dialogRef.current.querySelectorAll('button:not([disabled]), a[href], [tabindex]:not([tabindex="-1"])')];
      if (focusable.length === 0) return;
      const first = focusable[0];
      const last = focusable[focusable.length - 1];
      if (event.shiftKey && document.activeElement === first) {
        event.preventDefault();
        last.focus();
      } else if (!event.shiftKey && document.activeElement === last) {
        event.preventDefault();
        first.focus();
      }
    };
    window.addEventListener("keydown", handleKeyDown);
    return () => {
      window.removeEventListener("keydown", handleKeyDown);
    };
  }, [closeViewer, isOpen, zoomIn, zoomOut]);
  const startDrag = event => {
    if (event.button !== 0 || !viewportRef.current) return;
    const viewport = viewportRef.current;
    dragRef.current = {
      pointerId: event.pointerId,
      x: event.clientX,
      y: event.clientY,
      scrollLeft: viewport.scrollLeft,
      scrollTop: viewport.scrollTop
    };
    viewport.setPointerCapture(event.pointerId);
    viewport.dataset.dragging = "true";
  };
  const continueDrag = event => {
    const drag = dragRef.current;
    const viewport = viewportRef.current;
    if (!drag || !viewport || drag.pointerId !== event.pointerId) return;
    viewport.scrollLeft = drag.scrollLeft - (event.clientX - drag.x);
    viewport.scrollTop = drag.scrollTop - (event.clientY - drag.y);
  };
  const stopDrag = event => {
    const viewport = viewportRef.current;
    if (viewport?.hasPointerCapture(event.pointerId)) viewport.releasePointerCapture(event.pointerId);
    if (viewport) delete viewport.dataset.dragging;
    dragRef.current = null;
  };
  const activeContentBox = frameMode === "content" ? contentBox : null;
  const activeWidth = activeContentBox?.width ?? width;
  const activeHeight = activeContentBox?.height ?? height;
  const activeRatio = activeWidth / activeHeight;
  const inlineContentBox = measurementStatus === "ready" ? contentBox : null;
  const inlineWidth = inlineContentBox?.width ?? width;
  const inlineHeight = inlineContentBox?.height ?? height;
  const inlineGeometry = {
    aspectRatio: `${inlineWidth} / ${inlineHeight}`,
    maxWidth: `${30 * inlineWidth / inlineHeight}rem`
  };
  const imageStyle = viewMode === "fit" ? {
    aspectRatio: `${activeWidth} / ${activeHeight}`,
    width: "100%",
    maxWidth: `${Math.max(16, activeRatio * 78)}dvh`
  } : {
    aspectRatio: `${activeWidth} / ${activeHeight}`,
    width: `${zoom * 100}%`,
    maxWidth: "none"
  };
  const zoomLabel = viewMode === "fit" ? frameMode === "content" ? "Fit content" : "Full page" : `${Math.round(zoom * 100)}%`;
  return <figure className="latex-preview">
      <button type="button" className="latex-preview__trigger" onClick={openViewer} aria-haspopup="dialog" aria-label={`Open zoomable preview: ${alt}`}>
        <span className="latex-preview__page" style={inlineGeometry}>
          {measurementStatus === "loading" ? <span className="latex-preview__loading" role="status">Preparing compiled output…</span> : renderPreviewAsset({
    src,
    alt,
    width,
    height,
    contentBox: inlineContentBox,
    loading: "lazy"
  })}
        </span>
        <span className="latex-preview__trigger-label" aria-hidden="true">
          <span className="latex-preview__trigger-icon">⌕</span>
          Open viewer
        </span>
      </button>
      <figcaption className="latex-preview__caption">
        <span>
          {caption}
          {measurementStatus === "error" && <span className="latex-preview__status" role="status"> Content fit is unavailable; the complete vector page is shown.</span>}
        </span>
        <a href={src} target="_blank" rel="noreferrer" className="latex-preview__source-link">Open SVG</a>
      </figcaption>

      {isOpen && <div className="latex-preview__backdrop" onMouseDown={event => {
    if (event.target === event.currentTarget) closeViewer();
  }}>
          <section ref={dialogRef} className="latex-preview__dialog" role="dialog" aria-modal="true" aria-label={`Rendered LaTeX viewer: ${alt}`}>
            <header className="latex-preview__toolbar">
              <div className="latex-preview__identity">
                <span className="latex-preview__eyebrow">Compiled LaTeX</span>
                <span className="latex-preview__filename">{alt}</span>
              </div>
              <div className="latex-preview__controls" aria-label="Preview controls">
                <button type="button" className={frameMode === "content" && viewMode === "fit" ? "is-active" : undefined} disabled={!contentBox} onClick={() => {
    setFrameMode("content");
    setViewMode("fit");
    setZoom(minZoom);
  }}>
                  Fit content
                </button>
                <button type="button" className={frameMode === "page" && viewMode === "fit" ? "is-active" : undefined} onClick={() => {
    setFrameMode("page");
    setViewMode("fit");
    setZoom(minZoom);
  }}>
                  Full page
                </button>
                <span className="latex-preview__zoom-group">
                  <button type="button" onClick={zoomOut} disabled={viewMode === "fit" || zoom <= minZoom} aria-label="Zoom out">−</button>
                  <output aria-live="polite" aria-label="Current zoom">{zoomLabel}</output>
                  <button type="button" onClick={zoomIn} disabled={viewMode !== "fit" && zoom >= maxZoom} aria-label="Zoom in">+</button>
                </span>
                <a href={src} target="_blank" rel="noreferrer">Open SVG</a>
                <button ref={closeButtonRef} type="button" className="latex-preview__close" onClick={closeViewer} aria-label="Close rendered LaTeX viewer">
                  Close
                </button>
              </div>
            </header>
            <div ref={viewportRef} className="latex-preview__viewport" data-view-mode={viewMode} onPointerDown={startDrag} onPointerMove={continueDrag} onPointerUp={stopDrag} onPointerCancel={stopDrag}>
              <span className="latex-preview__dialog-page" style={imageStyle}>
                {renderPreviewAsset({
    src,
    alt,
    width,
    height,
    contentBox: activeContentBox
  })}
              </span>
            </div>
            <footer className="latex-preview__viewer-note">
              Compiler-generated vector output · Use +/− to zoom · Drag to pan · Esc to close
            </footer>
          </section>
        </div>}
    </figure>;
};

LaTeX produces the world's most beautiful mathematical typography. From simple equations to complex multi-line derivations, this guide teaches you to create publication-quality mathematics.

## Getting Started with Math Mode

LaTeX has two main math modes:

### Inline Math

Use `$...$` for math within text:

<LatexSource filename="example.tex" source={"The equation $E = mc^2$ revolutionized physics."} />

<RenderedOutput title="Rendered output" ctaHref="https://app.latex-cloud-studio.com/?utm_source=resources&utm_medium=rendered_output&utm_campaign=docs_open_app&utm_content=blog_beautiful_math_latex">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-01/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

**Output:** The equation *E = mc²* revolutionized physics.

### Display Math

Use `\[...\]` for centered, standalone equations:

<LatexSource filename="example.tex" source={"The quadratic formula is:\n\\[\n    x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-02/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

<Tip>
  **Essential package:** Add `\usepackage{amsmath}` to your preamble for access to advanced math features.
</Tip>

## Essential Setup

<LatexSource filename="example.tex" source={"\\documentclass{article}\n\n% Math packages\n\\usepackage{amsmath}   % Essential math features\n\\usepackage{amssymb}   % Extra symbols\n\\usepackage{amsthm}    % Theorem environments\n\\usepackage{mathtools} % Extensions to amsmath\n\n\\begin{document}\n% Your math here\n\\end{document}"} />

<RenderedOutput title="Expected effect">
  <Info>
    This code is a contextual or intentionally partial LaTeX excerpt, not a self-contained compilable document. Its visible result depends on the surrounding document, so the documentation shows the expected role without inventing a standalone preview.
  </Info>
</RenderedOutput>

***

## Basic Mathematical Notation

### Superscripts and Subscripts

<LatexSource filename="example.tex" source={"% Superscripts (powers)\n$x^2$           % x squared\n$x^{10}$        % x to the 10th (use braces for multi-digit)\n$e^{i\\pi}$      % e to the i*pi\n\n% Subscripts\n$x_1$           % x sub 1\n$x_{n+1}$       % x sub (n+1)\n$a_{ij}$        % a sub ij\n\n% Combined\n$x_1^2$         % x sub 1, squared\n$a_{i}^{n}$     % a sub i, to the n\n${x^2}^3$       % (x²)³ - nested powers"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-04/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Fractions

<LatexSource filename="example.tex" source={"% Inline fractions\n$\\frac{1}{2}$           % Half\n$\\frac{a+b}{c+d}$       % Complex fraction\n$\\frac{\\partial f}{\\partial x}$  % Partial derivative\n\n% Display fractions (larger)\n\\[\n    \\frac{a}{b} \\quad \\dfrac{a}{b}\n\\]\n\n% Continued fractions\n\\[\n    \\cfrac{1}{1+\\cfrac{1}{1+\\cfrac{1}{1+x}}}\n\\]\n\n% Small fractions in text\nUse $\\tfrac{1}{2}$ for compact fractions."} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-05/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Roots

<LatexSource filename="example.tex" source={"$\\sqrt{x}$          % Square root\n$\\sqrt[3]{x}$       % Cube root\n$\\sqrt[n]{x}$       % nth root\n$\\sqrt{a^2 + b^2}$  % Pythagorean"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-06/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Greek Letters

### Lowercase Greek

| Letter | Command    | Letter | Command    |
| ------ | ---------- | ------ | ---------- |
| α      | `\alpha`   | ν      | `\nu`      |
| β      | `\beta`    | ξ      | `\xi`      |
| γ      | `\gamma`   | π      | `\pi`      |
| δ      | `\delta`   | ρ      | `\rho`     |
| ε      | `\epsilon` | σ      | `\sigma`   |
| ζ      | `\zeta`    | τ      | `\tau`     |
| η      | `\eta`     | υ      | `\upsilon` |
| θ      | `\theta`   | φ      | `\phi`     |
| ι      | `\iota`    | χ      | `\chi`     |
| κ      | `\kappa`   | ψ      | `\psi`     |
| λ      | `\lambda`  | ω      | `\omega`   |
| μ      | `\mu`      |        |            |

### Uppercase Greek

<LatexSource filename="example.tex" source={"$\\Gamma$    $\\Delta$    $\\Theta$    $\\Lambda$\n$\\Xi$       $\\Pi$       $\\Sigma$    $\\Upsilon$\n$\\Phi$      $\\Psi$      $\\Omega$"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-07/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Variant Forms

<LatexSource filename="example.tex" source={"$\\varepsilon$  % ε variant (common in analysis)\n$\\varphi$      % φ variant (common in physics)\n$\\vartheta$    % θ variant\n$\\varrho$      % ρ variant\n$\\varsigma$    % ς (final sigma)"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-08/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Operators and Relations

### Arithmetic Operators

<LatexSource filename="example.tex" source={"$a + b$         % Addition\n$a - b$         % Subtraction\n$a \\times b$    % Multiplication (×)\n$a \\cdot b$     % Multiplication (·)\n$a \\div b$      % Division\n$a / b$         % Fraction bar\n$\\pm$           % Plus or minus\n$\\mp$           % Minus or plus"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-09/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Comparison Relations

<LatexSource filename="example.tex" source={"$a = b$         % Equals\n$a \\neq b$      % Not equal\n$a < b$         % Less than\n$a > b$         % Greater than\n$a \\leq b$      % Less than or equal\n$a \\geq b$      % Greater than or equal\n$a \\ll b$       % Much less than\n$a \\gg b$       % Much greater than\n$a \\approx b$   % Approximately equal\n$a \\sim b$      % Similar to\n$a \\equiv b$    % Equivalent/identical\n$a \\propto b$   % Proportional to"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-10/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Set Operations

<LatexSource filename="example.tex" source={"$A \\cup B$      % Union\n$A \\cap B$      % Intersection\n$A \\setminus B$ % Set difference\n$A \\subset B$   % Proper subset\n$A \\subseteq B$ % Subset or equal\n$A \\supset B$   % Proper superset\n$x \\in A$       % Element of\n$x \\notin A$    % Not element of\n$\\emptyset$     % Empty set\n$\\varnothing$   % Empty set (variant)"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-11/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Logic Symbols

<LatexSource filename="example.tex" source={"$\\forall$       % For all\n$\\exists$       % There exists\n$\\nexists$      % Does not exist (amssymb)\n$\\neg$          % Negation\n$\\land$         % Logical and\n$\\lor$          % Logical or\n$\\implies$      % Implies\n$\\iff$          % If and only if\n$\\therefore$    % Therefore\n$\\because$      % Because"} />

<RenderedOutput title="Expected effect">
  <Info>
    This code is a contextual or intentionally partial LaTeX excerpt, not a self-contained compilable document. Its visible result depends on the surrounding document, so the documentation shows the expected role without inventing a standalone preview.
  </Info>
</RenderedOutput>

***

## Large Operators

### Sums and Products

<LatexSource filename="example.tex" source={"% Sums\n$\\sum_{i=1}^{n} x_i$                    % Inline sum\n\\[\n    \\sum_{i=1}^{n} x_i                  % Display sum\n\\]\n\n% Products\n$\\prod_{i=1}^{n} x_i$                   % Inline product\n\\[\n    \\prod_{k=0}^{\\infty} (1+x^{2^k})    % Display product\n\\]\n\n% Co-product\n$\\coprod_{i \\in I} G_i$"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-13/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Integrals

<LatexSource filename="example.tex" source={"% Single integrals\n$\\int_a^b f(x) \\, dx$                   % Definite integral\n$\\int f(x) \\, dx$                       % Indefinite integral\n\n% Multiple integrals\n$\\iint_D f(x,y) \\, dA$                  % Double integral\n$\\iiint_V f(x,y,z) \\, dV$               % Triple integral\n$\\oint_C \\mathbf{F} \\cdot d\\mathbf{r}$  % Contour integral\n\n% Display style\n\\[\n    \\int_{-\\infty}^{\\infty} e^{-x^2} dx = \\sqrt{\\pi}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-14/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

<Tip>
  **Spacing tip:** Use `\,` before `dx` for proper spacing: `\int f(x) \, dx`
</Tip>

### Limits

<LatexSource filename="example.tex" source={"% Limits\n$\\lim_{x \\to \\infty} f(x)$\n$\\lim_{n \\to \\infty} a_n$\n$\\lim_{x \\to 0^+} \\frac{1}{x}$\n\n% Display style limits\n\\[\n    \\lim_{x \\to 0} \\frac{\\sin x}{x} = 1\n\\]\n\n% Other limit-like operators\n$\\limsup_{n \\to \\infty} a_n$\n$\\liminf_{n \\to \\infty} a_n$\n$\\sup_{x \\in A} f(x)$\n$\\inf_{x \\in A} f(x)$\n$\\max_{x} f(x)$\n$\\min_{x} f(x)$"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-15/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Matrices and Arrays

### Basic Matrices

<LatexSource filename="example.tex" source={"% Parentheses matrix\n\\[\n    \\begin{pmatrix}\n        a & b \\\\\n        c & d\n    \\end{pmatrix}\n\\]\n\n% Bracket matrix\n\\[\n    \\begin{bmatrix}\n        1 & 2 & 3 \\\\\n        4 & 5 & 6 \\\\\n        7 & 8 & 9\n    \\end{bmatrix}\n\\]\n\n% Determinant\n\\[\n    \\begin{vmatrix}\n        a & b \\\\\n        c & d\n    \\end{vmatrix} = ad - bc\n\\]\n\n% Curly braces\n\\[\n    \\begin{Bmatrix}\n        x \\\\ y \\\\ z\n    \\end{Bmatrix}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-16/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Matrix Types Quick Reference

| Type         | Command   | Delimiters |
| ------------ | --------- | ---------- |
| Plain        | `matrix`  | None       |
| Parentheses  | `pmatrix` | ( )        |
| Brackets     | `bmatrix` | \[ ]       |
| Braces       | `Bmatrix` | { }        |
| Pipes        | `vmatrix` | \| \|      |
| Double pipes | `Vmatrix` | ‖ ‖        |

### Special Matrices

<LatexSource filename="example.tex" source={"% Identity matrix\n\\[\n    I_3 = \\begin{pmatrix}\n        1 & 0 & 0 \\\\\n        0 & 1 & 0 \\\\\n        0 & 0 & 1\n    \\end{pmatrix}\n\\]\n\n% Diagonal matrix\n\\[\n    \\text{diag}(\\lambda_1, \\lambda_2, \\lambda_3) =\n    \\begin{pmatrix}\n        \\lambda_1 & 0 & 0 \\\\\n        0 & \\lambda_2 & 0 \\\\\n        0 & 0 & \\lambda_3\n    \\end{pmatrix}\n\\]\n\n% Large matrix with dots\n\\[\n    \\begin{pmatrix}\n        a_{11} & a_{12} & \\cdots & a_{1n} \\\\\n        a_{21} & a_{22} & \\cdots & a_{2n} \\\\\n        \\vdots & \\vdots & \\ddots & \\vdots \\\\\n        a_{m1} & a_{m2} & \\cdots & a_{mn}\n    \\end{pmatrix}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-17/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Inline Matrices

<LatexSource filename="example.tex" source={"% Small inline matrix\nThe matrix $\\bigl(\\begin{smallmatrix} a & b \\\\ c & d \\end{smallmatrix}\\bigr)$\nis invertible when $ad - bc \\neq 0$."} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-18/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Multi-line Equations

### The align Environment

<LatexSource filename="example.tex" source={"\\begin{align}\n    f(x) &= x^2 + 2x + 1 \\\\\n         &= (x + 1)^2\n\\end{align}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-19/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

The `&` marks the alignment point (usually before `=`).

### Multiple Alignment Points

<LatexSource filename="example.tex" source={"\\begin{align}\n    x + y &= 10 & 2x - y &= 5 \\\\\n    3x + 2y &= 20 & x + 3y &= 15\n\\end{align}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-20/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Unnumbered Equations

<LatexSource filename="example.tex" source={"% Single unnumbered\n\\begin{equation*}\n    E = mc^2\n\\end{equation*}\n\n% Or simply\n\\[\n    E = mc^2\n\\]\n\n% Align without numbers\n\\begin{align*}\n    a &= b + c \\\\\n    d &= e + f\n\\end{align*}\n\n% Selectively remove numbers\n\\begin{align}\n    a &= b \\nonumber \\\\\n    c &= d\n\\end{align}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-21/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Gathered Equations (Centered)

<LatexSource filename="example.tex" source={"\\begin{gather}\n    x + y = z \\\\\n    a + b = c \\\\\n    1 + 2 = 3\n\\end{gather}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-22/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Split Long Equations

<LatexSource filename="example.tex" source={"\\begin{equation}\n\\begin{split}\n    f(x) &= a + b + c + d \\\\\n         &\\quad + e + f + g \\\\\n         &\\quad + h + i + j\n\\end{split}\n\\end{equation}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-23/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Cases (Piecewise Functions)

<LatexSource filename="example.tex" source={"\\[\n    |x| = \\begin{cases}\n        x  & \\text{if } x \\geq 0 \\\\\n        -x & \\text{if } x < 0\n    \\end{cases}\n\\]\n\n% More complex\n\\[\n    f(x) = \\begin{cases}\n        0 & x < 0 \\\\\n        \\frac{1}{2} & x = 0 \\\\\n        1 & x > 0\n    \\end{cases}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-24/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Brackets and Delimiters

### Auto-sizing Delimiters

<LatexSource filename="example.tex" source={"% Automatic sizing - highly recommended!\n\\[\n    \\left( \\frac{a}{b} \\right)\n\\]\n\n\\[\n    \\left[ \\sum_{i=1}^{n} x_i \\right]\n\\]\n\n\\[\n    \\left\\{ \\int_0^1 f(x) \\, dx \\right\\}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-25/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### All Delimiter Types

<LatexSource filename="example.tex" source={"\\left( ... \\right)      % Parentheses\n\\left[ ... \\right]      % Square brackets\n\\left\\{ ... \\right\\}    % Curly braces\n\\left| ... \\right|      % Absolute value\n\\left\\| ... \\right\\|    % Norm\n\\left\\langle ... \\right\\rangle  % Angle brackets\n\\left\\lfloor ... \\right\\rfloor  % Floor\n\\left\\lceil ... \\right\\rceil    % Ceiling"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-26/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Manual Sizing

<LatexSource filename="example.tex" source={"% When auto-sizing isn't quite right\n\\big( \\Big( \\bigg( \\Bigg(\n\n% Example\n\\[\n    \\Bigg( \\bigg( \\Big( \\big( x \\big) \\Big) \\bigg) \\Bigg)\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-27/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Mixed Delimiters

<LatexSource filename="example.tex" source={"% Half-open interval\n\\[\n    \\left[ 0, 1 \\right)\n\\]\n\n% Using \\left. and \\right. for \"invisible\" delimiter\n\\[\n    \\left. \\frac{dy}{dx} \\right|_{x=0}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-28/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Formatting and Spacing

### Text in Math Mode

<LatexSource filename="example.tex" source={"% Wrong - letters are italicized as variables\n$if x > 0 then y = 1$\n\n% Correct\n$\\text{if } x > 0 \\text{ then } y = 1$\n\n% For function names\n$\\sin(x)$, $\\cos(x)$, $\\log(x)$, $\\ln(x)$\n$\\max(a,b)$, $\\min(a,b)$, $\\gcd(a,b)$\n\n% Custom operators\n\\DeclareMathOperator{\\argmax}{arg\\,max}\n\\DeclareMathOperator{\\Tr}{Tr}\n$\\argmax_x f(x)$\n$\\Tr(A)$"} />

<RenderedOutput title="Expected effect">
  <Info>
    This is document setup or preamble code. It changes the behavior of a containing document but does not produce an honest standalone page by itself.
  </Info>
</RenderedOutput>

### Mathematical Fonts

<LatexSource filename="example.tex" source={"% Bold\n$\\mathbf{x}$        % Bold (upright) - for vectors\n$\\boldsymbol{x}$    % Bold (italic) - for bold greek/symbols\n\n% Calligraphic\n$\\mathcal{L}$       % Lagrangian, loss function\n\n% Blackboard bold\n$\\mathbb{R}$        % Real numbers\n$\\mathbb{C}$        % Complex numbers\n$\\mathbb{Z}$        % Integers\n$\\mathbb{N}$        % Natural numbers\n$\\mathbb{Q}$        % Rationals\n\n% Fraktur\n$\\mathfrak{g}$      % Lie algebras\n\n% Roman (upright)\n$\\mathrm{d}x$       % Differential d"} />

<RenderedOutput title="Expected effect">
  <Info>
    This code is a contextual or intentionally partial LaTeX excerpt, not a self-contained compilable document. Its visible result depends on the surrounding document, so the documentation shows the expected role without inventing a standalone preview.
  </Info>
</RenderedOutput>

### Spacing Commands

<LatexSource filename="example.tex" source={"% Add space\n$a \\, b$        % Thin space (3/18 em)\n$a \\: b$        % Medium space (4/18 em)\n$a \\; b$        % Thick space (5/18 em)\n$a \\quad b$     % Quad space (1 em)\n$a \\qquad b$    % Double quad (2 em)\n\n% Remove space\n$a \\! b$        % Negative thin space\n\n% Common usage\n$\\int f(x) \\, dx$       % Space before dx\n$\\sqrt{2} \\, x$         % Space after root\n$dx \\, dy \\, dz$        % Spaces between differentials"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-31/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Common Patterns and Examples

### Calculus

<LatexSource filename="example.tex" source={"% Derivatives\n\\[\n    \\frac{d}{dx} x^n = nx^{n-1}\n\\]\n\n\\[\n    \\frac{\\partial f}{\\partial x} \\quad\n    \\frac{\\partial^2 f}{\\partial x^2} \\quad\n    \\frac{\\partial^2 f}{\\partial x \\partial y}\n\\]\n\n% Integrals\n\\[\n    \\int_0^\\infty e^{-x} \\, dx = 1\n\\]\n\n\\[\n    \\iint_D (x^2 + y^2) \\, dA = \\int_0^{2\\pi} \\int_0^R r^3 \\, dr \\, d\\theta\n\\]\n\n% Taylor series\n\\[\n    e^x = \\sum_{n=0}^{\\infty} \\frac{x^n}{n!} = 1 + x + \\frac{x^2}{2!} + \\frac{x^3}{3!} + \\cdots\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-32/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Linear Algebra

<LatexSource filename="example.tex" source={"% Matrix multiplication\n\\[\n    AB = \\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}\n         \\begin{pmatrix} e & f \\\\ g & h \\end{pmatrix}\n       = \\begin{pmatrix} ae+bg & af+bh \\\\ ce+dg & cf+dh \\end{pmatrix}\n\\]\n\n% Eigenvalue equation\n\\[\n    A\\mathbf{v} = \\lambda\\mathbf{v}\n\\]\n\n% Determinant\n\\[\n    \\det(A) = \\begin{vmatrix} a & b \\\\ c & d \\end{vmatrix} = ad - bc\n\\]\n\n% Inner product\n\\[\n    \\langle \\mathbf{u}, \\mathbf{v} \\rangle = \\sum_{i=1}^{n} u_i v_i\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-33/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Statistics and Probability

<LatexSource filename="example.tex" source={"% Expected value and variance\n\\[\n    \\mathbb{E}[X] = \\int_{-\\infty}^{\\infty} x f(x) \\, dx\n\\]\n\n\\[\n    \\text{Var}(X) = \\mathbb{E}[X^2] - (\\mathbb{E}[X])^2\n\\]\n\n% Normal distribution\n\\[\n    f(x) = \\frac{1}{\\sigma\\sqrt{2\\pi}} e^{-\\frac{(x-\\mu)^2}{2\\sigma^2}}\n\\]\n\n% Probability\n\\[\n    P(A|B) = \\frac{P(B|A) P(A)}{P(B)}\n\\]\n\n% Binomial coefficient\n\\[\n    \\binom{n}{k} = \\frac{n!}{k!(n-k)!}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-34/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Physics

<LatexSource filename="example.tex" source={"% Maxwell's equations\n\\begin{align}\n    \\nabla \\cdot \\mathbf{E} &= \\frac{\\rho}{\\epsilon_0} \\\\\n    \\nabla \\cdot \\mathbf{B} &= 0 \\\\\n    \\nabla \\times \\mathbf{E} &= -\\frac{\\partial \\mathbf{B}}{\\partial t} \\\\\n    \\nabla \\times \\mathbf{B} &= \\mu_0 \\mathbf{J} + \\mu_0 \\epsilon_0 \\frac{\\partial \\mathbf{E}}{\\partial t}\n\\end{align}\n\n% Schrödinger equation\n\\[\n    i\\hbar \\frac{\\partial}{\\partial t} \\Psi = \\hat{H} \\Psi\n\\]\n\n% Einstein field equations\n\\[\n    R_{\\mu\\nu} - \\frac{1}{2}R g_{\\mu\\nu} + \\Lambda g_{\\mu\\nu} = \\frac{8\\pi G}{c^4} T_{\\mu\\nu}\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-35/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Advanced Techniques

### Colored Math

<LatexSource filename="example.tex" source={"\\usepackage{xcolor}\n\n\\[\n    f(x) = \\textcolor{blue}{a}x^2 + \\textcolor{red}{b}x + \\textcolor{green}{c}\n\\]\n\n% With colored boxes\n\\[\n    \\boxed{E = mc^2}\n\\]\n\n\\[\n    \\colorbox{yellow}{$\\displaystyle \\int_0^1 x^2 \\, dx$}\n\\]"} />

<RenderedOutput title="Expected effect">
  <Info>
    This code is a contextual or intentionally partial LaTeX excerpt, not a self-contained compilable document. Its visible result depends on the surrounding document, so the documentation shows the expected role without inventing a standalone preview.
  </Info>
</RenderedOutput>

### Annotated Equations

<LatexSource filename="example.tex" source={"\\usepackage{mathtools}\n\n% Overbrace/underbrace with labels\n\\[\n    \\overbrace{a + b + c}^{\\text{sum}} = \\underbrace{x + y}_{\\text{total}}\n\\]\n\n% Arrows with text\n\\[\n    A \\xrightarrow{\\text{transform}} B\n\\]\n\n\\[\n    A \\xleftarrow[\\text{below}]{\\text{above}} B\n\\]"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-37/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={612} height={792} />
</RenderedOutput>

### Numbered Subequations

<LatexSource filename="example.tex" source={"\\begin{subequations}\n\\begin{align}\n    x + y &= 1 \\label{eq:first} \\\\\n    x - y &= 0 \\label{eq:second}\n\\end{align}\n\\end{subequations}\n\n% Produces (1a) and (1b)"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-38/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### Custom Delimiters

<LatexSource filename="example.tex" source={"\\usepackage{mathtools}\n\n% Paired delimiters with auto-sizing\n\\DeclarePairedDelimiter{\\abs}{\\lvert}{\\rvert}\n\\DeclarePairedDelimiter{\\norm}{\\lVert}{\\rVert}\n\\DeclarePairedDelimiter{\\inner}{\\langle}{\\rangle}\n\n% Usage\n$\\abs{x}$           % |x|\n$\\abs*{\\frac{a}{b}}$  % Auto-sized\n$\\norm{v}$          % ||v||\n$\\inner{u,v}$       % <u,v>"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-39/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={612} height={792} />
</RenderedOutput>

***

## Quick Reference Table

### Most Used Commands

| Description   | Command          | Output |
| ------------- | ---------------- | ------ |
| Fraction      | `\frac{a}{b}`    | a/b    |
| Square root   | `\sqrt{x}`       | √x     |
| Power         | `x^2`            | x²     |
| Subscript     | `x_i`            | xᵢ     |
| Sum           | `\sum_{i=1}^{n}` | Σ      |
| Integral      | `\int_a^b`       | ∫      |
| Infinity      | `\infty`         | ∞      |
| Not equal     | `\neq`           | ≠      |
| Less/equal    | `\leq`           | ≤      |
| Approximately | `\approx`        | ≈      |
| Times         | `\times`         | ×      |
| Dot product   | `\cdot`          | ·      |
| Arrow         | `\rightarrow`    | →      |
| Partial       | `\partial`       | ∂      |

***

## Common Mistakes to Avoid

### 1. Forgetting Math Mode

<LatexSource filename="example.tex" source={"% Wrong\nThe value of x^2 is 4.\n\n% Correct\nThe value of $x^2$ is 4."} />

<RenderedOutput title="Expected effect">
  <Info>
    This code is a contextual or intentionally partial LaTeX excerpt, not a self-contained compilable document. Its visible result depends on the surrounding document, so the documentation shows the expected role without inventing a standalone preview.
  </Info>
</RenderedOutput>

### 2. Wrong Function Names

<LatexSource filename="example.tex" source={"% Wrong (italicized like variables)\n$sin(x)$, $log(x)$\n\n% Correct (upright, proper spacing)\n$\\sin(x)$, $\\log(x)$"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-41/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### 3. Missing Braces

<LatexSource filename="example.tex" source={"% Wrong\n$x^10$    % Produces x¹0\n\n% Correct\n$x^{10}$  % Produces x¹⁰"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-42/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

### 4. Inconsistent Sizing

<LatexSource filename="example.tex" source={"% Wrong - delimiters don't scale\n$(\\frac{a}{b})$\n\n% Correct\n$\\left(\\frac{a}{b}\\right)$"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/blog-beautiful-math-latex-43/page-1.svg" alt="Compiled PDF page 1 from example.tex" caption="Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment. The visible fragment is compiled inside the documented minimal article wrapper." width={595.276} height={841.89} />
</RenderedOutput>

***

## Next Steps

Now that you've mastered LaTeX math, explore:

* **Deep dive**: [Mathematical expressions reference](/learn/latex/mathematics/mathematical-expressions)
* **Practice**: Try our [math-heavy templates](/templates/article)
* **Advanced**: [TikZ for mathematical diagrams](/blog/mastering-tikz-diagrams)
* **Academic**: [LaTeX for academic writing](/blog/latex-academic-writing-guide)

<Info>
  **LaTeX Cloud Studio tip:** Our editor provides real-time math preview, so you can see your equations as you type. Try it at [latex-cloud-studio.com](https://www.latex-cloud-studio.com).
</Info>
