2

Assumed we have some simple code to display text above a brace styled node in TikZ.


Minimum working example (MWE):

\documentclass{standalone}
\usepackage{pgfplots}

\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0,xmax=1,ymin=0,ymax=1]

\draw [decorate,decoration={brace,amplitude=5pt,raise=4pt},yshift=0pt]
(20,50) -- (80,50) node [black,midway,align=center,yshift=0.75cm] {\footnotesize Test\\\footnotesize Test};

\end{axis}
\end{tikzpicture}
\end{document}

Screenshot of the result:

Screenshot of the result


Description of the issue:

As you can see, the empty space between those two text lines is very huge and therefore doesn't look very nice.

How can I decrease the white space between two text lines?

  • 2
    The correct usage is font=\footnotesize as in: \documentclass[tikz,border=3.14mm]{standalone} \usepackage{pgfplots} \begin{document} \begin{tikzpicture} \begin{axis}[xmin=0,xmax=1,ymin=0,ymax=1] \draw [decorate,decoration={brace,amplitude=5pt,raise=4pt},yshift=0pt] (20,50) -- (80,50) node [black,midway,align=center,yshift=0.75cm,font=\footnotesize] {Test\\ Test}; \end{axis} \end{tikzpicture} \end{document} If you want to further decrease the distance, use e.g. a node content of the sort {Test\\[-0.2em] Test}. – user121799 Feb 14 at 19:05
  • @marmot: Once more: Thanks you very much! :-) You can post this as an answer... – Dave Feb 14 at 19:19
5

The appropriate usage for having the font in \footnotesize (or any other size like \small, \large etc.) is either

font=\footnotesize

or

node font=\footnotesize

As far as I can tell, here is no visible difference in the output of these two options in the case of your MWE. It can, however, be useful to have two font commands, so you may say \tikzset{every node/.append style={font=\sffamily}} and add to a specific node node font=\footnotesize such that the node font of this node will then be both sans serif and small.

Applied to your MWE, you could do

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=0,xmax=1,ymin=0,ymax=1]

\draw [decorate,decoration={brace,amplitude=5pt,raise=4pt},yshift=0pt]
(20,50) -- (80,50) node
[black,midway,align=center,yshift=0.75cm,font=\footnotesize] {Test\\ Test};

\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

If you want to further decrease the distance, use e.g. a node content of the sort {Test\\[-0.2em] Test}. This tuning is always available, regardless of the size. It will me conceivably more important if different lines of the text have different font sizes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.