Tx · LaTeX & TikZ

How to Use TikZ with the Springer Nature LaTeX Template

Published By the 9to5Science editorial team

At a glance

  1. 1. Load TikZ

    Add \usepackage{tikz} to the preamble, after the Springer Nature document class.

  2. 2. Test a simple picture

    Compile a small TikZ drawing before adding libraries or complex figure code.

  3. 3. Check the error

    Use the first relevant error message to identify a missing package, library, or option clash.

  4. 4. Follow journal rules

    Keep the template's class and settings, and check your journal's instructions for figure submission.

The Springer Nature LaTeX template does not normally prevent you from drawing figures with TikZ. In a document using the sn-jnl class, load TikZ in the preamble and put the drawing in a tikzpicture environment. If that simple setup fails, the error message usually points to a package, library, or TeX installation issue.

Minimal Springer Nature example

The example below uses the sn-basic class option. Compile it in a project that includes Springer Nature’s sn-jnl.cls file and a current TeX distribution with PGF/TikZ installed.

\documentclass[pdflatex,sn-basic]{sn-jnl}
\usepackage{tikz}

\begin{document}

\title{A test article}
\author{Author Name}
\maketitle

\begin{figure}[t]
  \centering
  \begin{tikzpicture}
    \draw[thick,->] (0,0) -- (2,0) node[right] {$x$};
    \draw[thick,->] (0,0) -- (0,1.5) node[above] {$y$};
    \draw[blue,thick] (0,0) -- (1,1);
  \end{tikzpicture}
  \caption{A simple TikZ figure.}
  \label{fig:tikz-test}
\end{figure}

Figure~\ref{fig:tikz-test} was drawn with TikZ.

\end{document}

The tikz package is part of PGF, the graphics system that provides TikZ’s drawing commands. For this basic figure, no additional TikZ library is needed. Load any extra libraries you use—such as \usetikzlibrary{positioning}—in the preamble too.

Diagnose the error before changing the template

Compile the small example first. If it works, add your real drawing a piece at a time. This separates problems in the figure code from problems in the document setup. Check the first relevant error in the log; later errors can be consequences of that first one.

Error or symptomWhat to check
Environment tikzpicture undefinedConfirm \usepackage{tikz} is in the preamble, before \begin{document}, and that the document is using the expected file.
File 'tikz.sty' not foundInstall or update the PGF/TikZ package in your TeX distribution.
I do not know the key ...Load the library that defines the key with \usetikzlibrary{...}, or check that its spelling is correct.
Option clash for package xcolorAvoid loading xcolor a second time with different options. If you need color options, pass them before \documentclass, or follow the class’s package setup.
Errors inside PGF/TikZ internalsUpdate PGF/TikZ and compile with a current LaTeX distribution before editing the class file.

TikZ works with pdfLaTeX as well as other common LaTeX engines. Use the engine selected by the Springer template unless the journal specifies otherwise. Features such as TikZ externalization are different: they may require shell-escape permission and extra configuration, so turn them off while debugging a basic drawing.

Keep the class and journal settings

Do not replace sn-jnl merely because a TikZ picture fails. First confirm that a minimal picture works, then restore your actual figure code and any required libraries. Also avoid editing the supplied class file: local changes can make the project harder to compile and may conflict with template updates.

The LaTeX code for a figure and the journal’s figure-submission rules are separate concerns. A journal may request figures as separate files or specify production requirements. Check the current instructions for your target journal; export or submit the figure in the required format if requested. TikZ itself can remain in the source during preparation where the journal’s workflow permits it.

Common mistakes

  • Putting \usepackage{tikz} after \begin{document}. Packages belong in the preamble.
  • Loading every TikZ library pre-emptively. Load only the libraries your code needs; this makes errors easier to locate.
  • Treating a missing key as a class conflict. Many key errors simply mean the relevant library was not loaded.
  • Changing the publisher class to silence an error. This can hide the real cause and produce a document that no longer follows the template.
  • Debugging a large diagram all at once. Start with one line or node, compile, and add elements incrementally.

For a package-level reference to TikZ and PGF, see the PGF manual. The Springer class and journal-specific submission instructions should come from the template and journal you are using.

References

  1. PGF/TikZ — CTAN package page and documentation

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.