Draw flowcharts, block diagrams, and plots directly in LaTeX with TikZ and pgfplots: the tikzpicture environment, coordinates, nodes, arrows, styles, relative positioning, and how the AI coauthor's TikZ Diagrams skill can draft them for you.
Diagrams with TikZ
TikZ lets you describe a drawing in code so it is typeset with the same fonts as your text, scales without blurring, and lives in version history with the rest of the paper. It is ideal for flowcharts, architecture diagrams, state machines, and small plots. Coauthor's compiler includes TikZ and all its libraries, and the AI coauthor has a dedicated TikZ Diagrams skill for drafting them.
Setup
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, shapes.geometric, calc}
Load only the libraries you use; each adds compile time. Common ones: arrows.meta (modern arrow tips), positioning (right=of), shapes.geometric (diamonds, ellipses), calc (coordinate arithmetic), automata (state machines), trees, matrix, fit, backgrounds, decorations.pathmorphing.
Your First Picture
\begin{tikzpicture}
\draw (0,0) -- (2,1); % line
\draw (0,0) rectangle (2,1); % rectangle by two corners
\draw (1,0.5) circle (0.3); % circle
\draw[->, thick] (2,1) -- (3,1.5); % arrow
\draw[dashed, red] (0,1) -- (2,0); % styled line
\node at (1,-0.4) {caption text}; % text at a point
\end{tikzpicture}
Coordinates are in centimeters by default; -- connects points. Everything inside [...] is an option: thick, dashed, red, fill=blue!20 (20% blue), ->, <->, rounded corners. Wrap the picture in a figure environment with \caption and \label exactly as for an image; see Figures and Images.
Nodes
Nodes are boxes of text (or shapes) that you can name and connect:
\begin{tikzpicture}[node distance=1.5cm]
\node[draw, rounded corners] (in) {Input};
\node[draw, fill=blue!15, right=of in] (enc) {Encoder};
\node[draw, fill=blue!15, right=of enc] (dec) {Decoder};
\node[draw, rounded corners, right=of dec] (out) {Output};
\draw[->] (in) -- (enc);
\draw[->] (enc) -- node[above] {$z$} (dec);
\draw[->] (dec) -- (out);
\end{tikzpicture}
(name)after the options names the node;(enc)can then be used as a coordinate, and TikZ connects to the node border.right=of enc(frompositioning) places a node relative to another; alsobelow=of,above left=of,below=1cm of.node[above] {$z$}in the middle of a path labels the edge.- Anchors such as
(enc.north)or(dec.south west)pick a specific point on a node's border.
Styles
Define the look once and reuse it:
\begin{tikzpicture}[
node distance=1.2cm,
block/.style={rectangle, draw, fill=gray!10, minimum width=2.4cm, minimum height=0.9cm},
decision/.style={diamond, draw, aspect=2, fill=yellow!20},
arrow/.style={->, >=Stealth, thick}
]
\node[block] (load) {Load data};
\node[block, below=of load] (train) {Train};
\node[decision, below=of train] (ok) {Converged?};
\node[block, below=of ok] (eval) {Evaluate};
\draw[arrow] (load) -- (train);
\draw[arrow] (train) -- (ok);
\draw[arrow] (ok) -- node[right] {yes} (eval);
\draw[arrow] (ok.east) -- ++(1.5,0) |- node[near start, above] {no} (train.east);
\end{tikzpicture}
++(1.5,0) is a relative coordinate and |- draws a vertical-then-horizontal path. Put a shared style set in your macros.tex (see Packages and the Preamble) so every figure in the paper looks the same.
Plots with pgfplots
For data plots, use pgfplots, which is built on TikZ:
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
...
\begin{tikzpicture}
\begin{axis}[xlabel={Epoch}, ylabel={Loss}, width=0.7\linewidth, height=5cm, legend pos=north east, grid=major]
\addplot coordinates {(1,0.9) (2,0.6) (3,0.45) (4,0.38) (5,0.35)};
\addplot coordinates {(1,0.95) (2,0.7) (3,0.6) (4,0.58) (5,0.57)};
\legend{train, validation}
\end{axis}
\end{tikzpicture}
\addplot table {data.csv}; reads a file from your project folder (upload it as a supporting file). For large datasets, plotting in Python or R and uploading a PDF is faster to compile.
Let the AI Draw It
The AI coauthor has a TikZ Diagrams skill with reference material on shapes, libraries, positioning, and complete examples. Describe the diagram in the thread, for example: "Add a TikZ flowchart after the first paragraph of Section 3 in main.tex: data preprocessing, then two parallel branches (feature extraction and augmentation) that merge into training, then evaluation. Use rounded boxes and Stealth arrows."
The skill loads automatically for requests like this, and the AI inserts the tikzpicture (and the required \usepackage/\usetikzlibrary lines if they are missing) directly into your file. Compile with Ctrl+S to see it, then ask for adjustments ("make the branches vertical", "add a legend"). Provenance records the diagram as AI-assisted, which matters for venue disclosure. See Skills.
Tips and Troubleshooting
| Issue | What to do |
|---|---|
| Diagram too wide for the column | Add scale=0.8 to the tikzpicture options, or \resizebox{\linewidth}{!}{...} around it; transform shape scales node text too |
Package tikz Error: ... library not found | Check the \usetikzlibrary spelling; for example arrows.meta, not arrow.meta |
Undefined control sequence \node | \usepackage{tikz} missing |
| Edge labels overlap lines | Use node[above, fill=white, inner sep=1pt] |
| Compile is slow or times out | Large pgfplots data or many pictures; downsample data or move heavy figures to PDF images |
TikZ errors show up in the Compilation Results panel with a line number inside the picture; see Fixing Common LaTeX Errors. Externalizing TikZ pictures (\tikzexternalize) needs shell escape, which Coauthor's compiler disables; keep pictures inline.
Related articles
Prefer to ask?
Inside Coauthor, ask the AI coauthor how any feature works — it answers from these same help articles. For anything else, use the ? button in the top-right corner of the app.