# Size of \baselineskip for \\ if font size is \footnotesize?

\documentclass{article}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}
\begin{tikzpicture}
\tikzstyle{every node}=[font=\footnotesize]

\node[anchor=north west, inner sep=0, rectangle, red, draw, minimum width=0.5cm](A) {%
\begin{minipage}[t]{0.5cm}%
x\\
x
\end{minipage}};

\node[inner sep=0, rectangle, blue, draw, minimum width=0.5cm, anchor=north west](B) at (0.5cm, -\baselineskip) {%
\begin{minipage}[t]{0.5cm}%
x\\
x
\end{minipage}};

\end{tikzpicture}
\end{document}


How can I align the two rectangles that it looks like...

You get this result if \tikzstyle{every node}=[font=\footnotesize] is commented out. The problem is that I need a smaller font size. I have tried to set the shift to -\footnotesep but no success.

• \baselineskip under \footnotesize is 9.5pt; see {\footnotesize\the\baselineskip}. – Werner Jan 8 '14 at 7:00
• As in the previous question, the title is misleading, the issue is not with \\  but rather a tikz question of how to propagate alignment from inner boxes to the outer node. The alignment you want is automatic with \begin{minipage}[b]{5mm}...\end{minipage}\begin{minipage}[t]{5mm}...\end{minipage} so your question is not about \\  and \baselineskip but about how to add the tikz boxes without breaking alignment. (Also it should not be tagged pdftex as you see same with classic tex or xetex or luatex) – David Carlisle Jan 8 '14 at 9:50
• @Werner: Is it possible to set a new length to '\footnotesize\the\baselineskip' so that I can use it in Tikz? I have tried '\newlength{\mylength}\setlength{\mylength}{\footnotesize\the\baselineskip}' but no success. – user4811 Jan 9 '14 at 15:44
• @user4811: Of course, just \setlength{\mylength}{9.5pt} would work. :) But you can also try {\footnotesize\global\setlength{\mylength}{\baselineskip}}. – Werner Jan 9 '14 at 15:49
• @Werner: Woohoo, this works! Thx! – user4811 Jan 9 '14 at 15:53

If you can use TiKZ v 3.0.0, it introduces a new node option called node font which is used to compute all dimensions of node, while font option only affects text inside the node and not to its dimensions.

With this version is easy to get what you want:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{positioning}

\begin{document}

\verb+node font=\footnotesize+

\begin{tikzpicture}[every node/.style={node font=\footnotesize}]
\node[anchor=north west, inner sep=0, rectangle, red, draw,
text width=0.5cm, align=left](A) {%
x\\
x
};
\node[inner sep=0, rectangle, blue, draw,
text width=0.5cm, align=left, anchor=north west](B)
at (0.5cm, -\baselineskip) {%
x\\
x
};
\end{tikzpicture}

\verb+font=\footnotesize+

\begin{tikzpicture}[every node/.style={font=\footnotesize}]
\node[anchor=north west, inner sep=0, rectangle, red, draw,
text width=0.5cm, align=left](A) {%
x\\
x
};
\node[inner sep=0, rectangle, blue, draw,
text width=0.5cm, align=left, anchor=north west](B)
at (0.5cm, -\baselineskip) {%
x\\
x
};
\end{tikzpicture}
\end{document}


1. used /.style instead of tikzstyle. Please look at Should \tikzset or \tikzstyle be used to define TikZ styles?
2. deleted minipages inside nodes. Text node is similar to a minipage, you need to fix a text width and some align option to use \\ inside nodes to break lines.