> ## 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.

# LaTeX Commands Reference

> Comprehensive reference guide for LaTeX commands. Find syntax, usage examples, and options for all essential LaTeX commands.

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>;
};

This reference provides a comprehensive guide to LaTeX commands organized by category. Each command includes syntax, options, and practical examples.

<Info>
  **Quick tip**: Use Ctrl/Cmd + F to search for specific commands. Commands are organized alphabetically within each category.
</Info>

## Document Structure Commands

### Document Class and Packages

<LatexSource filename="document-setup.tex" source={"% Document class\n\\documentclass[options]{class}\n\\documentclass[12pt,a4paper]{article}\n\\documentclass[11pt,twoside]{report}\n\\documentclass[letterpaper,draft]{book}\n\n% Package loading\n\\usepackage[options]{package}\n\\usepackage{amsmath}\n\\usepackage[utf8]{inputenc}\n\\usepackage[margin=1in]{geometry}"} />

<RenderedOutput title="Expected effect">
  <Info>
    This is setup or structural LaTeX code. It changes available commands or document behavior, but it does not produce meaningful standalone page content by itself.
  </Info>
</RenderedOutput>

### Sectioning Commands

| Command            | Level | Numbered | Example                         |
| ------------------ | ----- | -------- | ------------------------------- |
| `\part{}`          | -1    | Yes      | `\part{Part Title}`             |
| `\chapter{}`       | 0     | Yes      | `\chapter{Chapter Title}`       |
| `\section{}`       | 1     | Yes      | `\section{Section Title}`       |
| `\subsection{}`    | 2     | Yes      | `\subsection{Subsection}`       |
| `\subsubsection{}` | 3     | Yes      | `\subsubsection{Subsubsection}` |
| `\paragraph{}`     | 4     | No\*     | `\paragraph{Paragraph}`         |
| `\subparagraph{}`  | 5     | No\*     | `\subparagraph{Subparagraph}`   |

\*Can be numbered by adjusting `secnumdepth`

<LatexSource filename="sectioning-examples.tex" source={"% Unnumbered sections\n\\section*{Introduction}\n\\subsection*{Background}\n\n% With short title for TOC\n\\section[Short Title]{Long Descriptive Title for the Document}\n\n% Adjusting numbering depth\n\\setcounter{secnumdepth}{3} % Number up to subsubsection\n\\setcounter{tocdepth}{2}    % TOC up to subsection"} />

<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=learn_reference_commands">
  <LatexPreview src="/images/rendered/learn-reference-commands-02/page-1.svg" alt="Compiled PDF page 1 from sectioning-examples.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>

### Document Parts

<LatexSource filename="document-parts.tex" source={"% Title commands\n\\title{Document Title}\n\\author{Author Name \\and Second Author}\n\\date{\\today} % or specific date\n\\maketitle\n\n% Abstract\n\\begin{abstract}\nAbstract content...\n\\end{abstract}\n\n% Table of contents\n\\tableofcontents\n\\listoffigures\n\\listoftables\n\n% Appendix\n\\appendix\n\\chapter{First Appendix}\n\n% Bibliography\n\\bibliographystyle{plain}\n\\bibliography{references}\n% or with biblatex\n\\printbibliography"} />

<RenderedOutput title="Expected effect">
  <Info>
    This excerpt depends on project files such as images, bibliography data, or included TeX sources that are not part of this standalone code box. Its exact output is project-specific, so no fabricated preview is shown.
  </Info>
</RenderedOutput>

## Text Formatting Commands

### Font Styles

| Command     | Effect      | Example                 | Alternative        |
| ----------- | ----------- | ----------------------- | ------------------ |
| `\textbf{}` | **Bold**    | `\textbf{bold text}`    | `{\bfseries text}` |
| `\textit{}` | *Italic*    | `\textit{italic text}`  | `{\itshape text}`  |
| `\textsl{}` | *Slanted*   | `\textsl{slanted text}` | `{\slshape text}`  |
| `\textsc{}` | Small Caps  | `\textsc{small caps}`   | `{\scshape text}`  |
| `\texttt{}` | `Monospace` | `\texttt{monospace}`    | `{\ttfamily text}` |
| `\textrm{}` | Roman       | `\textrm{roman text}`   | `{\rmfamily text}` |
| `\textsf{}` | Sans Serif  | `\textsf{sans serif}`   | `{\sffamily text}` |
| `\emph{}`   | Emphasis    | `\emph{emphasized}`     | `{\em text}`       |

### Font Sizes

<LatexSource filename="font-sizes.tex" source={"{\\tiny tiny text}\n{\\scriptsize scriptsize text}\n{\\footnotesize footnotesize text}\n{\\small small text}\n{\\normalsize normalsize text}\n{\\large large text}\n{\\Large Large text}\n{\\LARGE LARGE text}\n{\\huge huge text}\n{\\Huge Huge text}\n\n% As commands\n\\tiny\nThis text is tiny\n\\normalsize\nBack to normal"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-04/page-1.svg" alt="Compiled PDF page 1 from font-sizes.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>

### Text Alignment

<LatexSource filename="text-alignment.tex" source={"% Environments\n\\begin{center}\nCentered text\n\\end{center}\n\n\\begin{flushleft}\nLeft-aligned text\n\\end{flushleft}\n\n\\begin{flushright}\nRight-aligned text\n\\end{flushright}\n\n% Commands\n\\centering\nCentered paragraph\n\n\\raggedright\nLeft-aligned paragraph\n\n\\raggedleft\nRight-aligned paragraph"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-05/page-1.svg" alt="Compiled PDF page 1 from text-alignment.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>

## Spacing Commands

### Horizontal Spacing

| Command           | Space Type          | Width          |
| ----------------- | ------------------- | -------------- |
| `~`               | Non-breaking space  | Normal space   |
| `\,`              | Thin space          | 3/18 em        |
| `\:`              | Medium space        | 4/18 em        |
| `\;`              | Thick space         | 5/18 em        |
| `\!`              | Negative thin space | -3/18 em       |
| `\ `              | Normal space        | Normal space   |
| `\quad`           | Em space            | 1 em           |
| `\qquad`          | 2 em space          | 2 em           |
| `\hspace{length}` | Custom space        | Specified      |
| `\hfill`          | Stretchable space   | Fill available |

### Vertical Spacing

<LatexSource filename="vertical-spacing.tex" source={"% Fixed vertical space\n\\vspace{1cm}\n\\vspace*{1cm} % Not removed at page breaks\n\n% Relative vertical space\n\\smallskip  % About 3pt\n\\medskip    % About 6pt\n\\bigskip    % About 12pt\n\n% Fill vertical space\n\\vfill\n\n% Page breaks\n\\newpage    % Start new page\n\\clearpage  % Clear floats and start new page\n\\cleardoublepage % For two-sided documents\n\n% Line breaks\n\\\\\\\\ % New line\n\\\\\\\\[1cm] % New line with extra space\n\\\\linebreak % Suggests line break\n\\\\newline % Forces new line"} />

<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>

### Paragraph Formatting

<LatexSource filename="paragraph-formatting.tex" source={"% Paragraph indentation\n\\setlength{\\parindent}{0pt} % No indent\n\\setlength{\\parindent}{1cm} % 1cm indent\n\\noindent % No indent for one paragraph\n\n% Paragraph spacing\n\\setlength{\\parskip}{1em}\n\n% Line spacing\n\\usepackage{setspace}\n\\singlespacing\n\\onehalfspacing\n\\doublespacing\n\\setstretch{1.5} % Custom\n\n% Manual spacing\n\\par % End paragraph\n\\indent % Force indent"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-07/page-1.svg" alt="Compiled PDF page 1 from paragraph-formatting.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>

## List Commands

### Itemize, Enumerate, Description

<LatexSource filename="list-commands.tex" source={"% Itemize (bullets)\n\\begin{itemize}\n  \\item First item\n  \\item Second item\n  \\item[$\\diamond$] Custom bullet\n\\end{itemize}\n\n% Enumerate (numbered)\n\\begin{enumerate}\n  \\item First item\n  \\item Second item\n  \\item[3a.] Custom label\n\\end{enumerate}\n\n% Description\n\\begin{description}\n  \\item[Term] Description of term\n  \\item[Another term] Its description\n\\end{description}\n\n% Nested lists\n\\begin{enumerate}\n  \\item First level\n  \\begin{enumerate}\n    \\item Second level\n    \\begin{enumerate}\n      \\item Third level\n    \\end{enumerate}\n  \\end{enumerate}\n\\end{enumerate}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-08/page-1.svg" alt="Compiled PDF page 1 from list-commands.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>

### List Customization

<LatexSource filename="list-customization.tex" source={"\\usepackage{enumitem}\n\n% Customize itemize\n\\begin{itemize}[label=$\\star$, itemsep=0pt]\n  \\item Starred item\n\\end{itemize}\n\n% Customize enumerate\n\\begin{enumerate}[label=\\alph*), start=5]\n  \\item Fifth item (labeled 'e)')\n\\end{enumerate}\n\n% Inline lists\n\\begin{itemize*}[label=\\textbullet]\n  \\item One \\item Two \\item Three\n\\end{itemize*}\n\n% Resume numbering\n\\begin{enumerate}[resume]\n  \\item Continues from before\n\\end{enumerate}"} />

<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>

## Math Commands

### Math Environments

<LatexSource filename="math-environments.tex" source={"% Inline math\n$E = mc^2$\n\\(E = mc^2\\)\n\\begin{math}E = mc^2\\end{math}\n\n% Display math\n$$E = mc^2$$\n\\[E = mc^2\\]\n\\begin{displaymath}E = mc^2\\end{displaymath}\n\n% Numbered equation\n\\begin{equation}\n  E = mc^2\n\\end{equation}\n\n% Aligned equations\n\\begin{align}\n  a &= b + c \\\\\n  d &= e + f\n\\end{align}\n\n% Cases\n\\begin{cases}\n  x, & \\text{if } x \\geq 0 \\\\\n  -x, & \\text{if } x < 0\n\\end{cases}"} />

<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>

### Common Math Commands

| Command           | Output  | Usage       |
| ----------------- | ------- | ----------- |
| `\frac{a}{b}`     | a/b     | Fractions   |
| `\sqrt{x}`        | √x      | Square root |
| `\sqrt[n]{x}`     | ⁿ√x     | nth root    |
| `x^{2}`           | x²      | Superscript |
| `x_{i}`           | xᵢ      | Subscript   |
| `\sum_{i=1}^{n}`  | ∑ᵢ₌₁ⁿ   | Summation   |
| `\int_{a}^{b}`    | ∫ₐᵇ     | Integral    |
| `\lim_{x \to 0}`  | lim x→0 | Limit       |
| `\prod_{i=1}^{n}` | ∏ᵢ₌₁ⁿ   | Product     |

### Greek Letters

<LatexSource filename="greek-letters.tex" source={"% Lowercase\n\\alpha \\beta \\gamma \\delta \\epsilon \\zeta \\eta \\theta\n\\iota \\kappa \\lambda \\mu \\nu \\xi \\pi \\rho\n\\sigma \\tau \\upsilon \\phi \\chi \\psi \\omega\n\n% Uppercase\n\\Gamma \\Delta \\Theta \\Lambda \\Xi \\Pi\n\\Sigma \\Upsilon \\Phi \\Psi \\Omega\n\n% Variants\n\\varepsilon \\vartheta \\varpi \\varrho \\varsigma \\varphi"} />

<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>

## Table Commands

### Basic Tables

<LatexSource filename="table-basics.tex" source={"% Tabular\n\\begin{tabular}{lcr}\nLeft & Center & Right \\\\\n1 & 2 & 3 \\\\\n\\end{tabular}\n\n% Table float\n\\begin{table}[htbp]\n  \\centering\n  \\caption{Table caption}\n  \\label{tab:label}\n  \\begin{tabular}{|l|c|r|}\n    \\hline\n    A & B & C \\\\\n    \\hline\n    1 & 2 & 3 \\\\\n    \\hline\n  \\end{tabular}\n\\end{table}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-12/page-1.svg" alt="Compiled PDF page 1 from table-basics.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>

### Table Commands

| Command                        | Purpose          | Example                        |
| ------------------------------ | ---------------- | ------------------------------ |
| `&`                            | Column separator | `A & B & C`                    |
| `\\`                           | Row end          | `A & B & C \\`                 |
| `\hline`                       | Horizontal line  | Full width                     |
| `\cline{i-j}`                  | Partial line     | `\cline{2-3}`                  |
| `\multicolumn{n}{align}{text}` | Span columns     | `\multicolumn{2}{c}{Centered}` |
| `\multirow{n}{width}{text}`    | Span rows        | `\multirow{2}{*}{Text}`        |

## Figure Commands

### Including Graphics

<LatexSource filename="figure-commands.tex" source={"% Basic inclusion\n\\includegraphics{image}\n\\includegraphics[width=5cm]{image}\n\\includegraphics[height=3cm]{image}\n\\includegraphics[scale=0.5]{image}\n\n% Figure environment\n\\begin{figure}[htbp]\n  \\centering\n  \\includegraphics[width=0.8\\textwidth]{image}\n  \\caption{Figure caption}\n  \\label{fig:label}\n\\end{figure}\n\n% Subfigures\n\\usepackage{subcaption}\n\\begin{figure}\n  \\begin{subfigure}{0.45\\textwidth}\n    \\includegraphics[width=\\textwidth]{image1}\n    \\caption{First}\n  \\end{subfigure}\n  \\hfill\n  \\begin{subfigure}{0.45\\textwidth}\n    \\includegraphics[width=\\textwidth]{image2}\n    \\caption{Second}\n  \\end{subfigure}\n  \\caption{Main caption}\n\\end{figure}"} />

<RenderedOutput title="Expected effect">
  <Info>
    This excerpt depends on project files such as images, bibliography data, or included TeX sources that are not part of this standalone code box. Its exact output is project-specific, so no fabricated preview is shown.
  </Info>
</RenderedOutput>

## Reference Commands

### Labels and References

<LatexSource filename="references.tex" source={"% Creating labels\n\\label{sec:intro}\n\\label{fig:diagram}\n\\label{tab:results}\n\\label{eq:einstein}\n\n% Basic references\n\\ref{sec:intro}     % 1.1\n\\pageref{sec:intro} % 5\n\n% With packages\n\\usepackage{hyperref}\n\\autoref{sec:intro} % Section 1.1\n\n\\usepackage{cleveref}\n\\cref{sec:intro}    % section 1.1\n\\Cref{sec:intro}    % Section 1.1\n\\cref{fig:a,fig:b}  % figures 1 and 2"} />

<RenderedOutput title="Expected effect">
  <Info>
    This excerpt is part of a multi-pass cross-reference or bibliography workflow. A trustworthy final page requires the surrounding project and its auxiliary files, so this standalone code box documents the workflow without claiming a complete rendered result.
  </Info>
</RenderedOutput>

### Citations

<LatexSource filename="citations.tex" source={"% With natbib\n\\cite{key}          % [1]\n\\citep{key}         % (Author, Year)\n\\citet{key}         % Author (Year)\n\\citeauthor{key}    % Author\n\\citeyear{key}      % Year\n\n% With biblatex\n\\cite{key}\n\\parencite{key}\n\\textcite{key}\n\\footcite{key}\n\\fullcite{key}\n\n% Multiple citations\n\\cite{key1,key2,key3}"} />

<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>

## Special Characters

### Escaped Characters

| Character | Command            | Output |
| --------- | ------------------ | ------ |
| `#`       | `\#`               | #      |
| `$`       | `\$`               | \$     |
| `%`       | `\%`               | %      |
| `&`       | `\&`               | &      |
| `_`       | `\_`               | \_     |
| `{`       | `\{`               | \{     |
| `}`       | `\}`               | }      |
| `~`       | `\textasciitilde`  | \~     |
| `^`       | `\textasciicircum` | ^      |
| `\`       | `\textbackslash`   | \\     |

### Quotes and Dashes

<LatexSource filename="quotes-dashes.tex" source={"% Quotes\n`single quotes'\n``double quotes''\n\\textquoteleft text\\textquoteright\n\\textquotedblleft text\\textquotedblright\n\n% Dashes\n- % Hyphen\n-- % En dash (ranges)\n--- % Em dash (punctuation)\n\n% Special spaces\nNon~breaking~space\nThin\\,space"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-16/page-1.svg" alt="Compiled PDF page 1 from quotes-dashes.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>

## Box Commands

### Text Boxes

<LatexSource filename="box-commands.tex" source={"% Horizontal boxes\n\\mbox{unbreakable text}\n\\makebox[5cm][c]{centered in 5cm}\n\\fbox{framed text}\n\\framebox[5cm][r]{right-aligned frame}\n\n% Vertical boxes\n\\parbox{5cm}{Paragraph in 5cm box}\n\\parbox[t]{5cm}{Top-aligned}\n\\parbox[b]{5cm}{Bottom-aligned}\n\n% Minipage\n\\begin{minipage}{0.5\\textwidth}\nContent in half-width box\n\\end{minipage}\n\n% Save boxes\n\\newsavebox{\\mybox}\n\\savebox{\\mybox}{Saved content}\n\\usebox{\\mybox}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-17/page-1.svg" alt="Compiled PDF page 1 from box-commands.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>

## Color Commands

### Using Colors

<LatexSource filename="color-commands.tex" source={"\\usepackage{xcolor}\n\n% Text color\n\\textcolor{red}{Red text}\n\\textcolor{blue}{Blue text}\n\\textcolor[RGB]{255,128,0}{Orange text}\n\n% Background color\n\\colorbox{yellow}{Highlighted}\n\\fcolorbox{red}{yellow}{Framed}\n\n% Define colors\n\\definecolor{myblue}{RGB}{0,114,189}\n\\definecolor{mygreen}{HTML}{00A86B}\n\n% Page/text color\n{\\color{blue} Blue paragraph}\n\\pagecolor{gray!10}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-18/page-1.svg" alt="Compiled PDF page 1 from color-commands.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>

## Length Commands

### Setting Lengths

<LatexSource filename="length-commands.tex" source={"% Define new length\n\\newlength{\\mylength}\n\\setlength{\\mylength}{2cm}\n\\addtolength{\\mylength}{1cm}\n\n% Common lengths\n\\setlength{\\parindent}{0pt}\n\\setlength{\\parskip}{1em}\n\\setlength{\\textwidth}{15cm}\n\\setlength{\\textheight}{25cm}\n\n% Calculations\n\\setlength{\\mylength}{0.5\\textwidth}\n\\setlength{\\mylength}{\\textwidth-2cm}\n\n% Using calc package\n\\usepackage{calc}\n\\setlength{\\mylength}{\\widthof{Sample text}+1cm}"} />

<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>

## Counter Commands

### Using Counters

<LatexSource filename="counter-commands.tex" source={"% New counter\n\\newcounter{mycounter}\n\\setcounter{mycounter}{0}\n\\stepcounter{mycounter}\n\\addtocounter{mycounter}{5}\n\n% Display counter\n\\arabic{mycounter}    % 1, 2, 3\n\\roman{mycounter}     % i, ii, iii\n\\Roman{mycounter}     % I, II, III\n\\alph{mycounter}      % a, b, c\n\\Alph{mycounter}      % A, B, C\n\n% Page numbering\n\\pagenumbering{roman}\n\\setcounter{page}{1}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-reference-commands-20/page-1.svg" alt="Compiled PDF page 1 from counter-commands.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>

## Environment Commands

### Custom Environments

<LatexSource filename="custom-environments.tex" source={"% Define environment\n\\newenvironment{myenv}\n  {\\begin{center}\\bfseries}  % Begin\n  {\\end{center}}             % End\n\n% Usage\n\\begin{myenv}\nBold centered text\n\\end{myenv}\n\n% With arguments\n\\newenvironment{mybox}[1]\n  {\\begin{center}\\fbox{\\begin{minipage}{#1}}}\n  {\\end{minipage}}\\end{center}}\n\n\\begin{mybox}{5cm}\nContent in 5cm box\n\\end{mybox}"} />

<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>

## Useful Macros

### Common Custom Commands

<LatexSource filename="custom-commands.tex" source={"% Simple macros\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\vect}[1]{\\mathbf{#1}}\n\\newcommand{\\norm}[1]{\\left\\|#1\\right\\|}\n\n% With optional arguments\n\\newcommand{\\myitem}[1][\\textbullet]{#1~}\n\n% Renewing commands\n\\renewcommand{\\thesection}{\\Roman{section}}\n\\renewcommand{\\arraystretch}{1.5}\n\n% Conditional commands\n\\newcommand{\\ie}{\\textit{i.e.}}\n\\newcommand{\\eg}{\\textit{e.g.}}"} />

<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>

## Quick Reference Card

### Essential Commands

| Category       | Commands                              |
| -------------- | ------------------------------------- |
| **Structure**  | `\section`, `\subsection`, `\chapter` |
| **Formatting** | `\textbf`, `\textit`, `\emph`         |
| **Math**       | `$...$`, `\[...\]`, `\frac`, `\sqrt`  |
| **Lists**      | `itemize`, `enumerate`, `description` |
| **References** | `\label`, `\ref`, `\cite`             |
| **Spacing**    | `\\`, `\vspace`, `\hspace`            |
| **Special**    | `\%`, `\&`, `\_`, `\#`                |

***

<Info>
  **Next**: Explore essential [LaTeX packages](/learn/reference/packages) to extend functionality and add features to your documents.
</Info>
