# Adjusting text size in Tikz

I want to adjust my text size in the following code:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{plotmarks}

\begin{document}
\tikzset{fontsize=20}
\begin{tikzpicture}
\draw (20pt,20pt) rectangle ++(100pt,100pt);
\filldraw (70pt,70pt) circle (3pt);
\draw (20pt,20pt)--(120pt,120pt);
\node(text) at (10pt,70pt) {$\theta_1$};
\node(text) at (70pt,10pt) {$\theta_2$};
\end{tikzpicture}

\end{document}


I couldn't find anything by searching.

• Did you try to use \large or \Large or other commands? Oct 22 '13 at 22:37
• @Sigur, But can't I adjust it to a specific size? Plus I just tried it and it doesn't work.
– Naji
Oct 22 '13 at 22:38
• @Naji That hasn’t anything to do with with TikZ. The node text is just TeX as everything else. You can just do {\fontsize{20}{22.4}\selectfont$\theta_1$}. You can also the font key (e.g. font=\fontsize{size}{skip}\selectfont or any other font command like \Large or whatever is provided by class and packages). You can also issue those macros directly in the TikZ picture (or before it) then also length in em and ex get adjusted correctly. You can also use scale=2 at the node to make a 10pt font in a 20pt font … Oct 22 '13 at 22:40
• @PaulGessler, Yes!
– Naji
Mar 2 '14 at 10:43

Instead of repeating font size operations in the code of each node, I recommend defining a style. Either globally, via \tikzset, or locally, as option to the tikzpicturefor example. I would never change font sizes within the text. Also in classic LaTeX documents, sizes should be set via macros defined in the preamble, for consistency and allowing changes.

You can inherit and combine styles, to further avoid repeating and to keep things consistent.

\tikzset{%
bignode/.style     = {font=\fontsize{20}{22.4}\selectfont},
mathnode/.style    = {execute at begin node=$, execute at end node=$},
bigmathnode/.style = {bignode, mathnode}}
...
\node [bigmathnode] (text) at (10pt,70pt) {\theta_1};
\node [bigmathnode] (text) at (70pt,10pt) {\theta_1};


Based on what has been suggested by @Qrrbrbirlbel in the comments the code should be manipulated as follows.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\usetikzlibrary{plotmarks}

\begin{document}
\begin{tikzpicture}
\draw (20pt,20pt) rectangle ++(100pt,100pt);
\filldraw (70pt,70pt) circle (3pt);
\draw (20pt,20pt)--(120pt,120pt);
\node(text) at (10pt,70pt) {\fontsize{20}{22.4}\selectfont$\theta_1$};
\node(text) at (70pt,10pt) {{\fontsize{20}{22.4}\selectfont$\theta_1$};
\end{tikzpicture}

\end{document}


@Qrrbrbirlbel pointed out that the text part of the node is functioning as any other part of TeX document, and as a result the general structure of {\fontsize{20}{22.4}\selectfont$TEXT_HERE$} can be used for font-size-manipulation. There is no need for using tikzset command anymore.