Adding two latex variables in Tikz beamer
Just use \the\numexpr\i+\j
. This works regardless of whether or not you have loaded TikZ. (And use math mode and \scriptstyle
instead of \tiny
.)
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\setbeamertemplate{footline}[frame number]{}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\setbeamertemplate{frametitle}[default][center]
\begin{document}
\title{Some Title}
\author{greatest author out there}
\frame{\titlepage}
\begin{frame}
\frametitle{Adding two integers}
\begin{tikzpicture}
\def \i {4}
\def \j {17}
\draw (0,0) node{$\scriptstyle i+j =\the\numexpr\i+\j$};
\end{tikzpicture}
\end{frame}
\end{document}
Try this way:
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\setbeamertemplate{footline}[frame number]{}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\setbeamertemplate{frametitle}[default][center]
\begin{document}
\title{Some Title}
\author{greatest author out there}
\frame{\titlepage}
\begin{frame}
\frametitle{Adding two integers}
\begin{tikzpicture}
\def \i {4}
\def \j {17}
\pgfmathtruncatemacro\ij{\i+\j}
\draw (0,0) node{\tiny i+j = \ij};
\end{tikzpicture}
\end{frame}
\end{document}
You have to tell tikz/pgf
to calculate the result first ... This is what \pgfmathtruncatemacro
does here.
PS: See also \pgfmathsetmacro
tikz does not know that you want the sum, you need to tell it with \pgfmathparse
\tiny{...}
is wrong. It should be {\tiny ...}
, but better use the tikz key font=\tiny
\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{matrix}
\setbeamertemplate{footline}[frame number]{}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\setbeamertemplate{frametitle}[default][center]
\begin{document}
\title{Some Title}
\author{greatest author out there}
\frame{\titlepage}
\begin{frame}
\frametitle{Adding two integers}
\begin{tikzpicture}
\def \i {4}
\def \j {17}
\draw (0,0) node[font=\tiny] {i+j =\pgfmathparse{\i+\j}\pgfmathresult };
\end{tikzpicture}
\end{frame}
\end{document}