2

I am new to TkiZ. I am trying to decrease the font size of a node locally.

Tried to read the below (Page 224):

http://mirror.utexas.edu/ctan/graphics/pgf/base/doc/pgfmanual.pdf

The changes are not taking effect. Hope you can guide me on what could have be done wrongly.

MWE:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.multipart, shapes.geometric, arrows}
\begin{document}

\tikzstyle{rec} = [rectangle split, rectangle split horizontal, rectangle split parts=3, minimum height=1cm, minimum width=3cm, align=left, draw=black, fill=blue!30] 

\begin{tikzpicture} [node distance=1.5cm]

\node (rec1) [rec] {\nodepart{two}
\textbf{Node: Normal Size Text}
\\\# Text 1
\\\# Text 2
\\\# Text 3
};

\node (rec2) [rec, below of=rec1, yshift=-1cm, font=\small] {\nodepart{two} %Attempt 1: not working
%\node (rec2) [rec, below of=rec1, yshift=-1cm, style={font=\small}] {\nodepart{two} %Attempt 2: not working
%\node (rec2) [rec, below of=rec1, yshift=-1cm] {\nodepart{two} \small %Attempt 3: not working
\textbf{Node: Small Size Text}
\\\# Text 1
\\\# Text 2
\\\# Text 3
};

\end{tikzpicture}
\end{document}
  • You should use \tikzset rather than \tikzstyle, by the way. (The latter is considered deprecated.) – cfr Jan 09 '15 at 00:01

1 Answers1

6

That is because you are using minimal document class which doesn't provide font size commands like \small. Use standalone or article or book.... instead

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes,shapes.multipart, shapes.geometric, arrows}
\begin{document}

\tikzset{rec/.style = {rectangle split, rectangle split horizontal, rectangle split parts=3, 
  minimum height=1cm, minimum width=3cm, align=left, draw=black, fill=blue!30}
}

\begin{tikzpicture} [node distance=1.5cm]

\node (rec1) [rec] {\nodepart{two}
\textbf{Node: Normal Size Text}
\\\# Text 1
\\\# Text 2
\\\# Text 3
};

\node (rec2) [rec, below of=rec1, yshift=-1cm, font=\small] {\nodepart{two} %Attempt 1: not working
%\node (rec2) [rec, below of=rec1, yshift=-1cm, style={font=\small}] {\nodepart{two} %Attempt 2: not working
%\node (rec2) [rec, below of=rec1, yshift=-1cm] {\nodepart{two} \small %Attempt 3: not working
\textbf{Node: Small Size Text}
\\\# Text 1
\\\# Text 2
\\\# Text 3
};

\end{tikzpicture}
\end{document}

Bottom line

Never use minimal unless you know what you are doing. For further details, please visit and read:

why-should-the-minimal-class-be-avoided

user43963
  • 1,570