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

# Creating Your First LaTeX Project

> Complete step-by-step guide to creating your first LaTeX project. Learn project setup, document structure, compilation, and best practices for beginners.

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 guide walks you through the fastest reliable way to create your first LaTeX project. It covers project setup, package choices, document structure, and the minimum workflow needed to get a clean PDF without guesswork.

<Info>
  **Time to complete**: 15-20 minutes\
  **Prerequisites**: Access to LaTeX Cloud Studio or a LaTeX installation\
  **Outcome**: A complete, well-structured LaTeX document
</Info>

## Fastest Path If You Just Want a Working Project

1. Start with `article` unless you already know you need `report`, `book`, or `beamer`.
2. Keep the first file small: title, abstract, two sections, and one list.
3. Add only the packages you actually need.
4. Compile early, then add images, references, and bibliography after the base file works.
5. Use a template once the minimal project is stable.

## Project Planning

### Before You Start

Before creating your LaTeX project, consider:

1. **Document type** - Article, report, book, or presentation?
2. **Required features** - Math equations, images, tables, bibliography?
3. **Output format** - PDF for print or digital distribution?
4. **Collaboration needs** - Working alone or with others?

### Choosing the Right Document Class

<CardGroup cols={2}>
  <Card title="article" icon="file-text">
    Best for papers, essays, and short documents

    * Sections start at top level
    * No chapters
    * Compact layout
  </Card>

  <Card title="report" icon="file-contract">
    Ideal for longer documents with chapters

    * Title page by default
    * Abstract support
    * Chapter organization
  </Card>

  <Card title="book" icon="book">
    Full-length books and manuals

    * Front/back matter
    * Two-sided printing
    * Professional typography
  </Card>

  <Card title="beamer" icon="presentation-screen">
    Presentations and slides

    * Frame-based content
    * Themes and transitions
    * Speaker notes
  </Card>
</CardGroup>

## Step 1: Create Project Structure

### Basic Project Setup

<LatexSource filename="main.tex" source={"\\documentclass[12pt, a4paper]{article}\n\n% Preamble - Package imports and settings\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage[english]{babel}\n\\usepackage{amsmath, amssymb, amsthm}\n\\usepackage{graphicx}\n\\usepackage[margin=1in]{geometry}\n\\usepackage{hyperref}\n\n% Document metadata\n\\title{My First LaTeX Document}\n\\author{Your Name}\n\\date{\\today}\n\n% Document content\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nThis is my first LaTeX document, demonstrating the basic structure\nand common elements used in academic writing.\n\\end{abstract}\n\n\\tableofcontents\n\\newpage\n\n\\section{Introduction}\nWelcome to LaTeX! This document will help you understand the basics\nof document creation and formatting.\n\n\\section{Getting Started}\nLet's explore the fundamental concepts and features of LaTeX.\n\n\\subsection{Why Use LaTeX?}\nLaTeX offers several advantages:\n\\begin{itemize}\n    \\item Professional typesetting\n    \\item Excellent mathematical notation\n    \\item Automatic numbering and references\n    \\item Consistent formatting\n\\end{itemize}\n\n\\section{Conclusion}\nYou've successfully created your first LaTeX document!\n\n\\end{document}"} />

<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_latex_how_to_first_project">
  <LatexPreview src="/images/rendered/learn-latex-how-to-first-project-01/page-1.svg" alt="Compiled PDF page 1 from main.tex" caption="Page 1 of 2. Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment." width={595.276} height={841.89} />

  <LatexPreview src="/images/rendered/learn-latex-how-to-first-project-01/page-2.svg" alt="Compiled PDF page 2 from main.tex" caption="Page 2 of 2. Generated from the shown source with pdfLaTeX in the pinned LaTeXCloud TeX Live 2026 environment." width={595.276} height={841.89} />
</RenderedOutput>

### Understanding the Structure

#### Preamble Section

The preamble (before `\begin{document}`) contains:

* **Document class**: Defines overall layout
* **Packages**: Add functionality
* **Settings**: Configure appearance
* **Metadata**: Title, author, date

#### Document Body

The main content (between `\begin{document}` and `\end{document}`) contains:

* **Front matter**: Title, abstract, table of contents
* **Main content**: Sections, paragraphs, lists
* **Back matter**: Bibliography, appendices

## Step 2: Add Essential Packages

### Core Package Set

<LatexSource filename="essential-packages.tex" source={"% Essential packages for any document\n\\usepackage[utf8]{inputenc}          % Input encoding\n\\usepackage[T1]{fontenc}             % Font encoding\n\\usepackage[english]{babel}          % Language support\n\\usepackage{geometry}                % Page layout\n\\usepackage{graphicx}                % Images\n\\usepackage{hyperref}                % Clickable links\n\n% Math and science\n\\usepackage{amsmath, amssymb}        % Math symbols and environments\n\\usepackage{siunitx}                 % SI units\n\n% Tables and lists\n\\usepackage{booktabs}                % Professional tables\n\\usepackage{enumitem}                % List customization\n\n% References and citations\n\\usepackage{biblatex}                % Bibliography\n\\addbibresource{references.bib}      % Bibliography file"} />

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

### Package Categories

<Tabs>
  <Tab title="Typography">
    <LatexSource filename="example.tex" source={"\\usepackage{microtype}     % Subtle typography improvements\n\\usepackage{fontspec}      % Custom fonts (XeLaTeX/LuaLaTeX)\n\\usepackage{lmodern}       % Latin Modern fonts\n\\usepackage{setspace}      % Line spacing control"} />

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

  <Tab title="Graphics">
    <LatexSource filename="example.tex" source={"\\usepackage{tikz}          % Drawings and diagrams\n\\usepackage{pgfplots}      % Plots and charts\n\\usepackage{subcaption}    % Subfigures\n\\usepackage{wrapfig}       % Text wrapping"} />

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

  <Tab title="Code">
    <LatexSource filename="example.tex" source={"\\usepackage{listings}      % Code listings\n\\usepackage{minted}        % Syntax highlighting\n\\usepackage{algorithm2e}   % Algorithms\n\\usepackage{verbatim}      % Verbatim text"} />

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

  <Tab title="Layout">
    <LatexSource filename="example.tex" source={"\\usepackage{multicol}      % Multiple columns\n\\usepackage{fancyhdr}      % Headers and footers\n\\usepackage{titlesec}      % Section formatting\n\\usepackage{tocloft}       % TOC customization"} />

    <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>
  </Tab>
</Tabs>

## Step 3: Write Content

### Text Formatting

<LatexSource filename="text-formatting.tex" source={"\\section{Text Formatting Examples}\n\n% Basic formatting\nThis is \\textbf{bold text}, \\textit{italic text}, and \\underline{underlined text}.\nYou can also combine them: \\textbf{\\textit{bold italic}}.\n\n% Font sizes\n{\\tiny tiny} {\\small small} {\\normalsize normal} {\\large large} {\\huge huge}\n\n% Emphasis and quotes\n\\emph{Emphasized text} adapts to context. Use ``double quotes'' for quotations.\n\n% Paragraph formatting\n\\paragraph{Named paragraph} This creates a named paragraph with special formatting.\n\n% Line breaks and spacing\nFirst line\\\\\nSecond line with forced break\n\nFirst paragraph.\n\nSecond paragraph with extra spacing."} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-latex-how-to-first-project-07/page-1.svg" alt="Compiled PDF page 1 from text-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>

### Lists and Enumerations

<LatexSource filename="lists.tex" source={"% Bullet points\n\\begin{itemize}\n    \\item First item\n    \\item Second item\n    \\begin{itemize}\n        \\item Nested item\n        \\item Another nested item\n    \\end{itemize}\n    \\item Third item\n\\end{itemize}\n\n% Numbered lists\n\\begin{enumerate}\n    \\item First step\n    \\item Second step\n    \\item Third step\n\\end{enumerate}\n\n% Description lists\n\\begin{description}\n    \\item[LaTeX] A document preparation system\n    \\item[PDF] Portable Document Format\n    \\item[BibTeX] Bibliography management tool\n\\end{description}\n\n% Custom lists with enumitem\n\\usepackage{enumitem}\n\\begin{enumerate}[label=(\\alph*)]\n    \\item First item with (a)\n    \\item Second item with (b)\n\\end{enumerate}"} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-latex-how-to-first-project-08/page-1.svg" alt="Compiled PDF page 1 from lists.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>

## Step 4: Add Visual Elements

### Including Images

<LatexSource filename="images.tex" source={"\\section{Working with Images}\n\n% Simple image inclusion\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.8\\textwidth]{example-image}\n    \\caption{A sample image with descriptive caption}\n    \\label{fig:example}\n\\end{figure}\n\n% Multiple images side by side\n\\begin{figure}[htbp]\n    \\centering\n    \\begin{subfigure}{0.45\\textwidth}\n        \\includegraphics[width=\\textwidth]{image1}\n        \\caption{First image}\n    \\end{subfigure}\n    \\hfill\n    \\begin{subfigure}{0.45\\textwidth}\n        \\includegraphics[width=\\textwidth]{image2}\n        \\caption{Second image}\n    \\end{subfigure}\n    \\caption{Two images side by side}\n    \\label{fig:comparison}\n\\end{figure}\n\nAs shown in Figure~\\ref{fig:example}, images can be easily referenced."} />

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

### Creating Tables

<LatexSource filename="tables.tex" source={"\\section{Tables}\n\n% Simple table\n\\begin{table}[htbp]\n    \\centering\n    \\caption{Sample data table}\n    \\label{tab:sample}\n    \\begin{tabular}{lcc}\n        \\toprule\n        Item & Quantity & Price \\\\\n        \\midrule\n        Apples & 5 & \\$2.50 \\\\\n        Oranges & 3 & \\$1.80 \\\\\n        Bananas & 6 & \\$3.00 \\\\\n        \\bottomrule\n    \\end{tabular}\n\\end{table}\n\nTable~\\ref{tab:sample} shows a professional table using booktabs."} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-latex-how-to-first-project-10/page-1.svg" alt="Compiled PDF page 1 from tables.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>

## Step 5: Mathematical Content

### Equations and Formulas

<LatexSource filename="mathematics.tex" source={"\\section{Mathematical Expressions}\n\n% Inline math\nThe quadratic formula is $x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}$.\n\n% Display equation with number\n\\begin{equation}\n    E = mc^2\n    \\label{eq:einstein}\n\\end{equation}\n\n% Multiple aligned equations\n\\begin{align}\n    f(x) &= x^2 + 2x + 1 \\\\\n         &= (x + 1)^2\n\\end{align}\n\n% Matrices\n\\begin{equation}\n    A = \\begin{bmatrix}\n        1 & 2 & 3 \\\\\n        4 & 5 & 6 \\\\\n        7 & 8 & 9\n    \\end{bmatrix}\n\\end{equation}\n\nAs shown in Equation~\\ref{eq:einstein}, mass and energy are related."} />

<RenderedOutput title="Rendered output">
  <LatexPreview src="/images/rendered/learn-latex-how-to-first-project-11/page-1.svg" alt="Compiled PDF page 1 from mathematics.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>

## Step 6: Compile Your Document

### Compilation Process

1. **Save your file** with `.tex` extension
2. **Choose compiler**:
   * **pdfLaTeX**: Standard choice, fast compilation
   * **XeLaTeX**: Unicode and system fonts
   * **LuaLaTeX**: Advanced features
3. **Run compilation** (may need 2-3 passes)
4. **Check output** for errors and warnings

### Common Compilation Issues

<Warning>
  **Fix these common errors**:

  * **Missing `$`**: Math mode not properly closed
  * **Undefined control sequence**: Typo in command or missing package
  * **Missing `\end{}`**: Environment not closed
  * **File not found**: Check image paths and filenames
</Warning>

### Compilation Workflow

```mermaid theme={null}
graph LR
    A[Write .tex file] --> B[Run pdfLaTeX]
    B --> C{Errors?}
    C -->|Yes| D[Fix errors]
    D --> B
    C -->|No| E[Check references]
    E --> F{References OK?}
    F -->|No| B
    F -->|Yes| G[Final PDF]
```

## Step 7: Add References

### Bibliography Management

<CodeGroup>
  ```latex bibliography.tex theme={null}
  % In preamble
  \usepackage{biblatex}
  \addbibresource{references.bib}

  % In document
  \section{Literature Review}

  According to \textcite{knuth1984}, TeX is a typesetting system.
  The LaTeX system \parencite{lamport1994} builds upon TeX.
  Recent developments are discussed in \cite{modern2023}.

  % At document end
  \printbibliography
  ```

  ```bibtex references.bib theme={null}
  @book{knuth1984,
      author = {Knuth, Donald E.},
      title = {The {\TeX}book},
      year = {1984},
      publisher = {Addison-Wesley}
  }

  @book{lamport1994,
      author = {Lamport, Leslie},
      title = {\LaTeX: A Document Preparation System},
      year = {1994},
      publisher = {Addison-Wesley}
  }

  @article{modern2023,
      author = {Smith, John and Doe, Jane},
      title = {Modern \LaTeX{} Techniques},
      journal = {Journal of Typesetting},
      year = {2023},
      volume = {15},
      pages = {123--145}
  }
  ```
</CodeGroup>

<RenderedOutput title="Expected effect">
  <Info>
    This code group documents a multi-step workflow across LaTeX and another file or command language. The blocks work together in a project, so there is no single standalone LaTeX page that would honestly represent the whole group.
  </Info>
</RenderedOutput>

## Project Organization

### File Structure

```
my-project/
├── main.tex           # Main document
├── chapters/          # Chapter files
│   ├── intro.tex
│   ├── methods.tex
│   └── results.tex
├── figures/           # Images and diagrams
│   ├── plot1.pdf
│   └── diagram.png
├── references.bib     # Bibliography
└── style.sty         # Custom styles
```

### Multi-file Projects

<LatexSource filename="main-multi.tex" source={"\\documentclass{report}\n% ... preamble ...\n\n\\begin{document}\n\n\\include{chapters/intro}\n\\include{chapters/methods}\n\\include{chapters/results}\n\n\\printbibliography\n\n\\end{document}"} />

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

<LatexSource filename="example.tex" source={"\\chapter{Introduction}\n\\label{ch:intro}\n\nThis chapter introduces the research topic...\n\n\\section{Background}\nThe background of this research..."} />

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

## Best Practices

<Tip>
  **Follow these guidelines for professional documents**:

  1. **Consistent style** - Use the same formatting throughout
  2. **Meaningful labels** - `\label{fig:data-analysis}` not `\label{fig1}`
  3. **Regular compilation** - Catch errors early
  4. **Version control** - Track changes with Git
  5. **Modular structure** - Split large documents into files
  6. **Comments** - Document complex code with `%` comments
</Tip>

## Complete Example Project

<LatexSource filename="complete-project.tex" source={"\\documentclass[12pt, a4paper]{article}\n\n% ==================\n% PREAMBLE\n% ==================\n% Encoding and fonts\n\\usepackage[utf8]{inputenc}\n\\usepackage[T1]{fontenc}\n\\usepackage{lmodern}\n\n% Language\n\\usepackage[english]{babel}\n\n% Page layout\n\\usepackage[margin=1in]{geometry}\n\\usepackage{setspace}\n\\onehalfspacing\n\n% Graphics and color\n\\usepackage{graphicx}\n\\usepackage[dvipsnames]{xcolor}\n\n% Math packages\n\\usepackage{amsmath, amssymb, amsthm}\n\n% Tables\n\\usepackage{booktabs}\n\\usepackage{array}\n\n% References\n\\usepackage{hyperref}\n\\hypersetup{\n    colorlinks=true,\n    linkcolor=blue,\n    citecolor=green,\n    urlcolor=red\n}\n\n% Bibliography\n\\usepackage{biblatex}\n\\addbibresource{references.bib}\n\n% Custom commands\n\\newcommand{\\R}{\\mathbb{R}}\n\\newcommand{\\important}[1]{\\textcolor{red}{\\textbf{#1}}}\n\n% Theorem environments\n\\newtheorem{theorem}{Theorem}[section]\n\\newtheorem{lemma}[theorem]{Lemma}\n\n% Document info\n\\title{A Complete LaTeX Project Example}\n\\author{Your Name\\\\\n\\small Department of Computer Science\\\\\n\\small University Name}\n\\date{\\today}\n\n% ==================\n% DOCUMENT BODY\n% ==================\n\\begin{document}\n\n\\maketitle\n\n\\begin{abstract}\nThis document demonstrates a complete LaTeX project structure,\nincluding all common elements used in academic writing. It serves\nas a template for creating professional documents.\n\\end{abstract}\n\n\\tableofcontents\n\\newpage\n\n\\section{Introduction}\n\\label{sec:intro}\n\nLaTeX is a powerful typesetting system particularly suited for\ntechnical and scientific documentation. This document demonstrates\nits capabilities through practical examples.\n\n\\subsection{Motivation}\nThe motivation for using LaTeX includes:\n\\begin{itemize}\n    \\item Superior mathematical typesetting\n    \\item Consistent document formatting\n    \\item Excellent bibliography management\n    \\item Cross-platform compatibility\n\\end{itemize}\n\n\\section{Mathematical Content}\n\\label{sec:math}\n\n\\subsection{Equations}\nThe quadratic equation \\cite{mathbook2020} is given by:\n\\begin{equation}\n    ax^2 + bx + c = 0\n    \\label{eq:quadratic}\n\\end{equation}\n\nThe solutions to Equation~\\eqref{eq:quadratic} are:\n\\begin{equation}\n    x = \\frac{-b \\pm \\sqrt{b^2 - 4ac}}{2a}\n\\end{equation}\n\n\\subsection{Theorems}\n\\begin{theorem}[Pythagorean Theorem]\n\\label{thm:pythagoras}\nIn a right triangle with legs $a$ and $b$ and hypotenuse $c$:\n\\begin{equation}\n    a^2 + b^2 = c^2\n\\end{equation}\n\\end{theorem}\n\n\\begin{proof}\nThe proof follows from geometric considerations...\n\\end{proof}\n\n\\section{Tables and Figures}\n\\label{sec:visual}\n\n\\subsection{Tables}\nTable~\\ref{tab:results} shows experimental results.\n\n\\begin{table}[htbp]\n    \\centering\n    \\caption{Experimental results}\n    \\label{tab:results}\n    \\begin{tabular}{lccc}\n        \\toprule\n        Method & Accuracy & Precision & Recall \\\\\n        \\midrule\n        Baseline & 0.85 & 0.82 & 0.88 \\\\\n        Improved & 0.92 & 0.90 & 0.94 \\\\\n        \\important{Proposed} & \\important{0.96} & \\important{0.95} & \\important{0.97} \\\\\n        \\bottomrule\n    \\end{tabular}\n\\end{table}\n\n\\subsection{Figures}\nFigure~\\ref{fig:example} shows an example image.\n\n\\begin{figure}[htbp]\n    \\centering\n    \\includegraphics[width=0.6\\textwidth]{example-image}\n    \\caption{Example figure with caption}\n    \\label{fig:example}\n\\end{figure}\n\n\\section{Code Listings}\n\\label{sec:code}\n\nHere's an example algorithm:\n\n\\begin{verbatim}\ndef fibonacci(n):\n    if n <= 1:\n        return n\n    return fibonacci(n-1) + fibonacci(n-2)\n\\end{verbatim}\n\n\\section{Conclusion}\n\\label{sec:conclusion}\n\nThis document has demonstrated the essential elements of a LaTeX\nproject. For more information, see \\cite{latex2023}.\n\n\\printbibliography\n\n\\appendix\n\\section{Additional Resources}\n\\begin{itemize}\n    \\item Official LaTeX documentation\n    \\item TeX Stack Exchange\n    \\item LaTeX Wikibook\n\\end{itemize}\n\n\\end{document}"} />

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

## Next Steps

Now that you've created your first project:

1. **Experiment with packages** - Try TikZ for diagrams or minted for code
2. **Create templates** - Save time on future projects
3. **Learn advanced features** - Master bibliographies and cross-references
4. **Join the community** - Get help on forums and Stack Exchange

<CardGroup cols={2}>
  <Card title="Working with Images" icon="image" href="/learn/latex/how-to/working-with-images">
    Learn image inclusion, positioning, and formatting
  </Card>

  <Card title="Creating Tables" icon="table" href="/learn/latex/how-to/professional-tables">
    Master professional table creation and formatting
  </Card>

  <Card title="Managing Large Documents" icon="folder" href="/learn/latex/how-to/large-documents">
    Organize multi-file projects effectively
  </Card>

  <Card title="Fix Errors" icon="bug" href="/learn/latex/how-to/fixing-compilation-errors">
    Troubleshoot common compilation problems
  </Card>
</CardGroup>

## Quick Reference

### Essential Commands

| Command            | Purpose           | Example                   |
| ------------------ | ----------------- | ------------------------- |
| `\documentclass{}` | Set document type | `\documentclass{article}` |
| `\usepackage{}`    | Load package      | `\usepackage{graphicx}`   |
| `\section{}`       | Create section    | `\section{Introduction}`  |
| `\label{}`         | Create reference  | `\label{sec:intro}`       |
| `\ref{}`           | Reference label   | `\ref{sec:intro}`         |
| `\cite{}`          | Cite reference    | `\cite{knuth1984}`        |

***

<Info>
  **Congratulations!** You've successfully created your first LaTeX project. Continue exploring our guides to master advanced features and create professional documents.
</Info>

## Start in LaTeX Cloud Studio

<CardGroup cols={2}>
  <Card title="Open in LaTeX Cloud Studio" icon="cloud" href="https://app.latex-cloud-studio.com/?utm_source=resources&utm_medium=card&utm_campaign=docs_open_app&utm_content=first_project_open_app">
    Write, compile, and iterate directly in your browser.
  </Card>

  <Card title="Start from Article Template" icon="file-text" href="/templates/article">
    Use a ready-made template, then adapt it to your content.
  </Card>
</CardGroup>
