1
\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}[node distance=2.5cm,auto,>=latex',
squarednode/.style={rectangle, draw=black!80, fill=black!100, very thick, minimum size=5mm,text=white}]
    \node [squarednode] (encoder) {$\text{encoder}$};
\end{tikzpicture}

\end{document}

When compiling, here is the error message :

! Undefined control sequence.
<recently read> \text 

l.10     \node [squarednode] (encoder) {$\text
                                              {encoder}$};

I do not understand... it works perfectly on another .tex that has the same code (but it's a beamer package slide tex file)

Any idea on why this might not work?

Thanks

2
  • 2
    You need to load amsmath to have \text defined.
    – user121799
    Jul 4, 2019 at 9:13
  • That worked. Thanks! I didn't had to load it on my beamer tex file..
    – truvaking
    Jul 4, 2019 at 9:16

1 Answer 1

3

Welcome to TeX-SE! This has nothing to do with tikz, but the error message just tells you that \text is not defined. \text comes with amsmath. Of course, in your application, \text is not necessary, you could just do \node [squarednode] (encoder) {encoder};.

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

\begin{document}
\begin{tikzpicture}[node distance=2.5cm,auto,>=latex',
squarednode/.style={rectangle, draw=black!80, fill=black!100, very thick, minimum size=5mm,text=white}]
    \node [squarednode] (encoder) {$\text{encoder}$};
\end{tikzpicture}

\end{document}
3
  • (+1) I didn't knew @marmots are faster than Falcons :-D. Jul 4, 2019 at 9:17
  • 2
    @Raaja If we were slower, the eagles could catch us. So we need to be fast. ;-)
    – user121799
    Jul 4, 2019 at 9:18
  • 1
    Fair enough (until next-time). Jul 4, 2019 at 9:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .