Inside a TikZ node, one can force line breaks using \\
providing the align
option of the node is set.
I would like to increase the line spacing inside a node. This can be done in the usual way with the optional parameter of \\
, e.g. \\[1em]
. Doing this for every line break is tedious though. Is there a way to increase the break globally, so that any \\
inside a node acts as \\[1em]
?
EDIT: Almost there!
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}
\tikzset{
mynode/.style={
draw
, align=center
, execute at begin node=\setlength{\baselineskip}{2em}
}
}
\begin{tikzpicture}
\node[mynode] {
this \\
is \\
\tikz \node[mynode] {a \\ break};
};
\end{tikzpicture}
\end{document}
This produces:
The remaining question is how to place a 2em break before the inner node.
Best Answer
What about this?
or
(If it doesn't work, try ending your node text with an explicit
\par
.)Now as for the second part: this is not only non-trivial, but also not well-defined. As the name suggests,
\baselineskip
is the distance between the baselines of consecutive lines of text (or hboxes, if you prefer). In the case of the "inner" tikz node, there's the question: where its baseline is located? This is configurable by the tikz optionbaseline
(this was hard to guess, right;)?), but if you set it higher, then - if you add another line or whatever below - the distance there will be to small.Probably the best answer to your problem are the
\lineskip
and\lineskiplimit
parameters. Actually (well, AFAIR, since I've got my copy of The TeXbook at my office), the rule is (more or less) as follows:Therefore you might want to set it up the following way:
where "close to each other" means "closer than the threshold".