3

I am trying to change the font size in a rectangle node but still have the rectangle a predefined size (the one of t=other rectangles). And also, I would like to left align in some nodes, and have a line break...

I have been through many Q&A but can't make it work.

enter image description here

so here is the example code:

\documentclass[class=minimal,border=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\tikzset{
punktchain/.style={rectangle, draw=black, minimum width=12em, minimum height=3em},
punktchain2/.style={rectangle, draw=black, minimum width=12em, minimum height=3em},
punktchain3/.style={rectangle, draw=black, minimum width=12em, minimum height=3em},
}

\begin{document}
\begin{tikzpicture}
  [node distance=.8cm]
     \node[punktchain] (x1) {TUTU};
     \node[punktchain2, below=1.5cm of x1] (x2) {TITI:\\TOTO};
     \node[punktchain2, below =1.5cm of x2] (x3) {TATA};
  \end{tikzpicture}
\end{document}

and I would like "TITI:" to be left aligned and with sriptnotesize and "TOTO" after a line break and of scriptnotesize too.

Any help would be greatly appreciated.

1
  • There is no such size as scriptnotesize. You may be confusing \scriptsize and \footnotesize...
    – jub0bs
    Aug 24, 2013 at 10:48

1 Answer 1

4

Font size

If the class=minimal option is used with the standalone class, the standard font-size modifying macros (such as \scriptsize, \footnotesize, etc.) are not available. However, if you really have to use that class option, you can always define those macros that you need.

The standalone class uses a 10pt font size by default. According to subsection 5.2 of the LaTeX2e documentation, when the default font size is 10pt, \scriptsize and \footnotesize are defined by \fontsize{7pt}{8pt}\selectfont and \fontsize{8pt}{9pt}\selectfont, respectively.

Left alignment and line breaks in tikz nodes

See this canonical answer on how to effect line breaks in tikz nodes. One approach is to use align=left and \\, but it seems that the font size on a given line is not affected by modifications on previous lines; this means that, with this approach, you need to modify the size of each line individually. Not very maintainable...

A better (in your case, at least) approach is to use a tabular composed of one left-aligned column (see below).


enter image description here

\documentclass[class=minimal,border=0pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{positioning}

\def\scriptsize{\fontsize{7pt}{8pt}\selectfont}
\def\footnotesize{\fontsize{8pt}{9pt}\selectfont}

\tikzset{
punktchain/.style={rectangle, draw=black, minimum width=12em, minimum height=3em},
punktchain2/.style={rectangle, draw=black, minimum width=12em, minimum height=3em},
punktchain3/.style={rectangle, draw=black, minimum width=12em, minimum height=3em},
}

\begin{document}
\begin{tikzpicture}[node distance=.8cm]
    \node[punktchain] (x1) {TUTU};
  \node[punktchain2, below=1.5cm of x1] (x2)
  {
    \scriptsize
    \begin{tabular}{l}
        TITI:\\
        TOTO
    \end{tabular}
  };
    \node[punktchain2, below =1.5cm of x2] (x3) {TATA};
\end{tikzpicture}
\end{document}
2
  • OK thanks. I didn't realize that class=minimal was preventing a change in the font size. for the line break inside a node environment, thank you for the link. Since I have to use left aligned it sorts the issue pretty easily.
    – jejuba
    Aug 24, 2013 at 16:18
  • font=\scriptsize, align=left works around the \\ problem. For the downsides of using font, see Strech the text to the borders of a node by using \hfill (CVS has this fixed IIRC) which is why I prefer to use either fixed units or /utils/exec=\scriptsize which would make the node also smaller in this case but in other cases it is IMO better (the inner seps are also correctly calculated then). Nov 21, 2013 at 21:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .