Documentation/TikZ & Graphics/Fix: TikZ Diagram Too Large — How to Fit on Page
TikZ & Graphics

Fix: TikZ Diagram Too Large — How to Fit on Page

A common headache in LaTeX: you build a beautiful TikZ diagram, but it overflows the margins or pushes onto the next page. Brute-force scaling often makes text unreadable. The right approach combines smart scaling, layout adjustments, and proper containment. This guide covers every technique from quick fixes to architectural solutions. Bibby AI's live preview shows your diagram dimensions in real time, so you catch overflow issues immediately instead of discovering them after a full Overleaf recompile.

Scale the Entire Diagram Proportionally

Use the scale transform, adjustbox, or resizebox to fit a diagram within the text width:

\documentclass{article}
\usepackage{tikz}
\usepackage{adjustbox}
\usetikzlibrary{positioning}

\begin{document}

% Method 1: TikZ scale (scales coordinates but NOT text by default)
\begin{tikzpicture}[scale=0.7, every node/.style={scale=0.7}]
    \node[draw] (a) at (0,0) {Node A};
    \node[draw] (b) at (5,0) {Node B};
    \node[draw] (c) at (10,0) {Node C};
    \draw[->] (a) -- (b) -- (c);
\end{tikzpicture}

\bigskip

% Method 2: adjustbox (scales everything including text, auto-fits)
\begin{adjustbox}{max width=\textwidth}
\begin{tikzpicture}
    \node[draw] (a) at (0,0) {Node A};
    \node[draw] (b) at (5,0) {Node B};
    \node[draw] (c) at (10,0) {Node C};
    \node[draw] (d) at (15,0) {Node D};
    \draw[->] (a) -- (b) -- (c) -- (d);
\end{tikzpicture}
\end{adjustbox}

\bigskip

% Method 3: resizebox (specify exact dimensions)
\resizebox{\textwidth}{!}{%
\begin{tikzpicture}
    \node[draw] (a) at (0,0) {Wide Diagram};
    \node[draw] (b) at (12,0) {Fits Now};
    \draw[->] (a) -- (b);
\end{tikzpicture}}

\end{document}

Reduce Diagram Size Through Layout Changes

Instead of scaling down, restructure the layout to naturally fit the available space:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

% BEFORE: Too wide (single row)
% \begin{tikzpicture}[node distance=2.5cm]
%     \node[draw](a){A}; \node[draw,right=of a](b){B};
%     \node[draw,right=of b](c){C}; \node[draw,right=of c](d){D};
%     \node[draw,right=of d](e){E};
% \end{tikzpicture}

% AFTER: Wrap into multiple rows
\begin{tikzpicture}[
    node distance=1cm and 1.8cm,
    every node/.style={draw, rounded corners, minimum width=2cm, minimum height=0.7cm, font=\small}
]
    \node (a) {Step 1};
    \node[right=of a] (b) {Step 2};
    \node[right=of b] (c) {Step 3};
    \node[below=of c] (d) {Step 4};  % Wrap to next row
    \node[left=of d] (e) {Step 5};

    \draw[->] (a) -- (b);
    \draw[->] (b) -- (c);
    \draw[->] (c) -- (d);
    \draw[->] (d) -- (e);
\end{tikzpicture}

\end{document}

💡 Tips

  • Prefer adjustbox with max width=\textwidth over manual scale factors — it auto-calculates the right scale.
  • When using TikZ's scale option, always add 'every node/.style={scale=0.7}' too, or text stays full-size.
  • Reduce node distance and minimum width before resorting to scaling — it keeps text readable.
  • For landscape-oriented diagrams, consider using \begin{landscape} from the pdflscape package instead of scaling.

Try This in Bibby AI

Write LaTeX faster with AI auto-complete and instant compilation.

Start Writing Free

Related Tutorials

Fix: TikZ Diagram Too Large — How to Fit on Page | Bibby AI