Algorithm LaTeX Standard
Publication-quality LaTeX pseudocode and matching TikZ flowcharts for academic papers.
Pseudocode Formats
Option A: Inline Bold-Enumerate (lightweight)
\vspace{2mm}
\noindent\textbf{Algorithm N: [Title]}
\begin{enumerate}
\item \textbf{Input:} [describe inputs]
\item \textbf{Initialize:} [setup steps]
\item \textbf{Main Loop:} [core procedure]
\begin{itemize}
\item Step details with math: $formula$
\end{itemize}
\item \textbf{Output:} [what is returned]
\end{enumerate}
Option B: Formal Algorithm Environment
\begin{algorithm}[h!]
\caption{Algorithm Title}
\label{alg:name}
\begin{algorithmic}[1]
\REQUIRE Input description
\ENSURE Output description
\STATE Initialize variables
\FOR{each iteration}
\STATE Compute step
\ENDFOR
\RETURN result
\end{algorithmic}
\end{algorithm}
Rule: Match the paper's existing algorithm style exactly. Never mix formats.
TikZ Flowchart Standard
Default Color Palette
% Section backgrounds
\definecolor{secBlue}{RGB}{214,230,245}
\definecolor{secYellow}{RGB}{255,243,205}
\definecolor{secGreen}{RGB}{218,238,218}
\definecolor{secPurple}{RGB}{228,220,240}
% Box fills
\definecolor{boxBlue}{RGB}{175,208,240}
\definecolor{boxYellow}{RGB}{248,228,160}
\definecolor{boxGreen}{RGB}{178,222,178}
\definecolor{boxPurple}{RGB}{198,182,218}
\definecolor{boxOrange}{RGB}{248,210,160}
\definecolor{boxGray}{RGB}{222,222,228}
\definecolor{accentGreen}{RGB}{200,232,200}
% Text and arrows
\definecolor{arrowC}{RGB}{75,75,75}
\definecolor{labelC}{RGB}{55,55,55}
\definecolor{noteC}{RGB}{120,120,130}
Node Styles
| Style | Purpose | Key Properties |
|---|---|---|
stepbox |
Phase label (left column) | draw=gray!55, fill=white, rounded corners=2pt, font=\sffamily\footnotesize\bfseries |
mbox |
Main content box | draw=gray!55, rounded corners=3pt, min-height=0.65cm, font=\sffamily\small |
sbox |
Secondary box | draw=gray!45, rounded corners=3pt, min-height=0.52cm, font=\sffamily\footnotesize |
tbox |
Tertiary/detail box | draw=gray!40, rounded corners=2pt, min-height=0.42cm, font=\sffamily\scriptsize |
Flowchart Layout
Organize as horizontal colored bands, one per algorithm phase:
+-------------------------------------------+
| [StepBox] | Phase 1 content | secBlue band
+-------------------------------------------+
| [StepBox] | Phase 2 content | secYellow band
| | [a] -> [b] -> [c] | parallel sub-steps
+-------------------------------------------+
| [StepBox] | Phase 3 content | secGreen band
+-------------------------------------------+
| [StepBox] | Phase 4 content | secPurple band
+-------------------------------------------+
Rules
- Style matching: If the paper has existing flowcharts, reuse their colors, node styles, and layout grid exactly
- Left column: Step labels in
stepboxstyle ("Input", "Loop", "Solve", "Eval") - Main area: Boxes with formulas connected by arrows
- Key equations: Use
\displaystyleandaccentGreenbackground for emphasis - Feedback loops: Dashed arrows only
- Notes: Small gray text (
\sffamily\scriptsize, text=noteC) for implementation details - Font:
\sffamilythroughout TikZ for clean sans-serif - Document class:
\documentclass[border=6pt]{standalone}for auto-cropping - Max boxes per band: 7 (split into sub-bands if more)
Compilation
# Compile standalone flowchart
cd figures/ && pdflatex -interaction=nonstopmode flowchart.tex
# Convert to PNG for preview
gs -dNOPAUSE -dBATCH -sDEVICE=png16m -r200 \
-sOutputFile=flowchart.png flowchart.pdf
# Include in paper
\includegraphics[width=0.95\textwidth]{figures/flowchart.pdf}
Cross-Reference Checklist
When inserting or renumbering algorithms:
- Search all
Algorithm~Nreferences in the paper - Update captions, figure captions, conclusion text
- Compile twice to resolve all references