I have encountered a strange problem with text formatting within Nodes in Tikz. I want to use nodes to create information boxes within Tikz diagrams, for example as in the TikZ & PGF Manual v3.0.1a - Till Tantau, 2015, section 2.1, pg 29, where such an explanatory box is placed to the right of the geometry diagram, the Tikz code for which is seen on pg 45.
Sometimes it is desirable to have more complicated formatting within such information boxes such as multiple font sizes.
However I am encountering problems with the formatting that Tikz produces, as seen in the diagram below where I have created 6 example nodes :-
Node 1
We use the node font
property set to \LARGE
.
For the second paragraph we change to \large
.
The second paragraph has excessive line spacing.
Node 2
Here we do not use node font
property, but just \LARGE
with a single paragraph.
The formatting does not come out properly.
Node 3
This is as Node 2, except we add \large
and a second paragraph.
The formatting improves somewhat but is still not right.
Node 4
This is exactly as Node 1 except this time we enclose the second paragraph text within a quote
environment.
The formatting improves notably.
Node 5
This is exactly as Node 1 except this time we enclose the second paragraph text within a description
list environment.
The formatting improves notably.
Node 6
This is exactly as Node 1 except this time we enclose the second paragraph text within a trivlist
environment.
The formatting appears reasonably good. Using a \vspace
command with a negative amount of space removes the unwanted space between the 2 paragraphs.
Thus the method in Node 6 provides some sort of a `hack' to get the formatting right.
However I would be interested to know why are these problems occurring in the first place, and is there any more proper way to get the formatting right than the above hack ?
I am using MiKTeX v2.9, and TeXstudio v2.12.10 on Windows 7.
\documentclass[a4paper]{article}
\usepackage{tikz}
\usepackage[margin=0.3in]{geometry}
\begin{document}
\begin{tikzpicture}
% Node 1
\node[draw, inner sep=0.5em, text width=5cm, anchor=south west, node font=\LARGE] at (0, 0) {
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description. PGF is a lower-level language, while TikZ.
\large
The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost.
};
% Node 2
\node [draw, inner sep=0.5em, text width=5cm, anchor=south west] at (6.5, 0) {
\LARGE
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description. PGF is a lower-level language, while TikZ. The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost.
};
% Node 3
\node [draw, inner sep=0.5em, text width=5cm, anchor=south west] at (13, 0) {
\LARGE
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description. PGF is a lower-level language, while TikZ.
\large
The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost.
};
\end{tikzpicture}
\vspace{4em}
\begin{tikzpicture}
% Node 4
\node[draw, inner sep=0.5em, text width=5cm, anchor=north west, node font=\LARGE] at (0, 0) {
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description. PGF is a lower-level language, while TikZ.
\large
\begin{quote}
The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost.
\end{quote}
};
% Node 5
\node[draw, inner sep=0.5em, text width=5cm, anchor=north west, node font=\LARGE] at (6.5, 0) {
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description. PGF is a lower-level language, while TikZ.
\large
\begin{description}
\item[item1] The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost.
\end{description}
};
% Node 6
\node[draw, inner sep=0.5em, text width=5cm, anchor=north west, node font=\LARGE] at (13, 0) {
PGF/TikZ is a pair of languages for producing vector graphics from a geometric/algebraic description. PGF is a lower-level language, while TikZ.
\large
\vspace{-0.5em}
\begin{trivlist}
\item The top-level PGF and TikZ commands are invoked as TeX macros, but in contrast with PSTricks, the PGF/TikZ graphics themselves are described in a language that resembles MetaPost.
\end{trivlist}
};
\end{tikzpicture}
\end{document}