179

Taking from the PGF manual,

\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node (c) at (1,2) {x};
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}

I'd like to increase the size of x. The problem is that I have multiple circles in the same diagram. Some of them require a larger sized font, while others are okay at default. How do I do this?

3
  • 15
    how about \node[scale=3] at (1,2) {x} (choose the number appropriately)
    – cmhughes
    Commented Apr 5, 2013 at 17:38
  • @cmhughes: why not post an answere? ;) Commented Apr 5, 2013 at 19:03
  • What are the necessary \usetikzlibrary{} items for this picture to work? positioning for sure, but how to get rid of Undefined control sequence in circle [at=(c), radius=\n1]? Commented Sep 17, 2021 at 23:25

4 Answers 4

260

You can change the font size inside a tikZ node like you do it in normal LaTeX – use one of these:

\tiny
\scriptsize
\footnotesize
\small
\normalsize
\large
\Large
\LARGE
\huge
\Huge

e.g.

\node (c) at (1,2) {\large x};

or

\node (c) at (1,2) {\large $x$}; %note the \large *outside* the inline math

Edit: To change font size inside math mode, LaTeX provides the following commands:

\displaystyle
\textstyle
\scriptstyle
\scriptscriptstyle

Using scaling algorithms provided by tikZ/pgf (e.g. scale=...) scales "the entire character", so it may look ugly if you use too much scaling. If you set the font sizes with the above commands, LaTeX selects different symbols for the different font sizes. This ensures the fonts are readable and have enough "details". If you want a more extreme scaling, use the scale=3.0 option for the node.

9
  • 11
    Maybe worth pointing out the font key which could be of help in this case :) Commented Apr 5, 2013 at 17:56
  • 1
    @ralfix sorry i didn't mention it. it's too early in the morning for me. bah! Commented Apr 5, 2013 at 18:02
  • 1
    @ClaudioFiandrino: Do you mean the scale option? Commented Apr 5, 2013 at 18:11
  • 38
    @Qrrbrbirlbel: you're right... what I wanted to say was that \node (c) at (1,2) {\large x}; is equivalent to \node[font=\large] (c) at (1,2) {x}; Commented Apr 5, 2013 at 19:15
  • 15
    @ClaudioFiandrino: with the notable exception that {\large x\\y} produces a large x and a normal y, while \node[font=\large,align=center] {x\\y} makes everything large.
    – Michaël
    Commented Dec 7, 2016 at 14:15
59

Set a new style so that you can use it later.

For example:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{relsize}

\tikzset{fontscale/.style = {font=\relsize{#1}}
    }

\begin{document}
\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node (c) at (1,2) [fontscale=4] {x};
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}
\end{document}
0
28

At the top, write

\begin{tikzpicture}[thick,scale=1, every node/.style={scale=1.3}]
\draw [help lines] (0,0) grid (3,3);
\coordinate (a) at (rnd,rnd);
\coordinate (b) at (3-rnd,3-rnd);
\draw (a) -- (b);
\node (c) at (1,2) {x};
\draw let \p1 = ($ (a)!(c)!(b) - (c) $),
        \n1 = {veclen(\x1,\y1)}
    in circle [at=(c), radius=\n1];
\end{tikzpicture}

the thick changes your arrows, the first scale changes the scale of your drawing, but the second argument changes the size of your nodes, presumably where you have your text. This will change for all nodes.

2
  • 3
    This wont work for this example actually. It will change the font size for all labels however. Commented Mar 13, 2019 at 19:56
  • This method solved a problem that had been bothering me for years, as I needed to scale the figure, and resize the font accordingly. Commented Nov 21, 2023 at 7:54
18

You can use the font option of the \node command. The font option accepts typical font commands such as \node[font = {\Huge\bfseries\sffamily}, red] (huge font size, bold, sans serif).

enter image description here

(Taken from the manual.)

enter image description here

\documentclass{article}

\usepackage{tikz}
\usetikzlibrary{calc} 

\begin{document}

\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node[font = {\normalfont}, red] (c) at (1,2) {x}; % <=== See here!
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}

\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,3);
  \coordinate (a) at (rnd,rnd);
  \coordinate (b) at (3-rnd,3-rnd);
  \draw (a) -- (b);
  \node[font = {\Huge\bfseries\sffamily}, red] (c) at (1,2) {x}; % <=== See here!
  \draw let \p1 = ($ (a)!(c)!(b) - (c) $),
            \n1 = {veclen(\x1,\y1)}
        in circle [at=(c), radius=\n1];
\end{tikzpicture}

\end{document}

\tiny
\scriptsize
\footnotesize
\small
\normalsize 
\large
\Large  
\LARGE  
\huge   
\Huge

enter image description here

(Taken from the manual.)

You must log in to answer this question.

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