2
\documentclass{standalone} %or standalone
\usepackage[all]{genealogytree}

\gtrset{info separators={\par}{. }{}{}} %no period after comment

\begin{document}
\begin{tikzpicture}

        \genealogytree[
                processing=fit,
                level distance=1cm,
                level size=1.5cm,
                node size from=2cm to 4cm,
                box clear,
                box={enhanced,fit basedim=8pt,
                        halign=center,valign=center,
                        before upper={\parskip 0.15\tcbfitdim plus 0pt minus 0pt},
                        drop fuzzy shadow
                },
                database content interpreter,
                database format=full,
                list separators hang,
                edges=rounded,
                date format=dd.mm.yyyy]{
                parent{
                        g[female]{
                                female,
                                name = {Name \surn{Long Surname}},
                                birth- = {1865-10-08},
                                death- = {1945-08-20},
                                comment = {born NameWithfxx},
                        }
                }
        }

\end{tikzpicture}
\end{document}

with that I get this:

f in comment, with before upper option

this is bad since I don't know why exactly more space is left on the left and right and the font is smaller.

If I now replace the character 'f' in the comment by an 'r' I get this:

r in comment, with before upper option

which is really weird since what characters I use shouldn't matter in this way (I tried it with other characters too, some seem to be working, some not).

I tried some things and finally I got that if I remove the "before upper" option of the boxes I get this with the r

r in comment, without upper option

and this with the f

f in comment, without before upper option.

Does anyone have an Idea why it is that way, why does it matter which character is used and what does the "before upper" option do? (I just took it from the signpost template and wasn't able to find what the option does on the internet)

EDIT: Figured finally out that the before upper option (before upper={\parskip 0.15\tcbfitdim plus 0pt minus 0pt},) is processed by tcolorbox (the given code is placed after the color and font settings but before the content). But I still don't know why this conflicts with characters like f,g or q

5
  • 1
    A difference is that the "f" goes under the line so it takes up more space vertically.
    – pst
    Mar 18, 2020 at 9:28
  • Thanks for your response, that fits with my experience that this phenomena occurs with the character 'q' as well.
    – atticus
    Mar 18, 2020 at 10:58
  • Remains the question what this option ("before upper") does and why it helps
    – atticus
    Mar 18, 2020 at 10:59
  • I figured out the box option of genealogytree is processed by tcolorbox. So I finally found the "before upper" option in the tcorbox documentation. Now my problem is that I'm too dumb to unterstand what \parskip 0.15\tcbfitdim plus 0pt minus 0pt does or moreover what the problem with that is (in the cases with the character f and q f.e.)
    – atticus
    Mar 18, 2020 at 17:49
  • Well the line sets the spacing according to the font size. Where this spacing is used I don't know.
    – atticus
    Mar 20, 2020 at 16:09

1 Answer 1

3

Solution 1: Allow variable node width and font size shrinking. Slightly enlarge the level size=1.5cm to, for example level size=1.6cm, to handle the specific situation (f causes font shrinking).

Solution 2: Allow variable node height with the cost of fixed node width and fixed font size. (see below)

Explanation

It is the total height of node g[female] that matters. Here the "node" is a genealogytree concept and is different from the tikz node.

Initially, genealogytree sets option timeflow=down. This fixes the height of every node to level size, and let option node size from sets the range of node width. If the natural height or width of node is larger than the fixed height or minimum width, respectively, genealogytree tries to firstly enlarge the width. If maximum width (with fixed height) is still not big enough, then font size is shrunk, using fitting library of tcolorbox.

In your example,

  • level size=1.5cm and node size from=2cm to 4cm sets the node size;
  • by setting \gtrset{info separators={\par}{. }{}{}}, the node content is split into four paragraphs, joined by three vertical skip \parskip;
  • by setting before upper={\parskip=0.15\tcbfitdim plus 0pt minus 0pt}, \parskip is set, at the beginning of node content, to be variable with font size. Here \tcbfitdim represents the used font size set by fitting library of tcolorbox. (By setting fit basedim=8pt, \tcbfitdim starts from 8pt).
  • Here comes the most tricky part: the f (with a depth) in comment = {born NameWithfxx} makes the natural (total) height of node slightly bigger than 1.5cm, which causes node width enlarging. But even using maximum width will not solve the too-high problem, font size is then shrunk (with the maximum width applied). This makes the output of f and r differs in two ways: the node width and the font size. But these differences has a same cause.
  • The change to \parskip is nothing more than adding vertical spaces and making the node higher.

Some examples to show how tricky it is:

enter image description here

\documentclass{article} %or standalone
\usepackage[all]{genealogytree}

\gtrset{info separators={\par}{. }{}{}} %no period after comment

\begin{document}

\newcommand\testGTree[3][]{
  \par
  \parbox{20em}{\texttt{%
    \detokenize{\parindent= #2} ... \\
    comment = \detokenize{#3}
  }}
  \begin{tikzpicture}[baseline=(current bounding box.center)]
    \genealogytree[
      processing=fit,
      level distance=1cm,
      level size=1.5cm,
      node size from=2cm to 4cm,
      box clear,
      box={enhanced,fit basedim=8pt,
        halign=center,valign=center,
        before upper={\parskip=#2 plus 0pt minus 0pt},
        drop fuzzy shadow
      },
      database content interpreter,
      database format=full,
      list separators hang,
      edges=rounded,
      date format=dd.mm.yyyy,
      #1] 
    {
      parent{
        g[id=xxx]{
          female,
          name = {Name \surn{Long Surname}},
          birth- = {1865-10-08},
          death- = {1945-08-20},
          comment = {#3\smash{, \the\tcbfitdim}},
        }
      }
    }
    \draw (0, 0) grid (4, .1); % to measure node width
  \end{tikzpicture}
  \par
}

\parindent=0pt
\paragraph{Group 1} zero \verb|\parindent| is ok
\testGTree{0pt}{f}
\testGTree{0pt}{r}

\paragraph{Group 2} \verb|\parindent=.8pt ...| is enough to trigger width enlarging and font size shrinking
\testGTree{.8pt}{f}
\testGTree{.8pt}{r}

\paragraph{Group 3} with \verb|\parindent=0.15\tcbfitdim ...|, depth \verb|0.2pt| is enough to trigger.

\newlength{\charDepth}
\newcommand{\showDepth}[1]{%
  \settodepth\charDepth{#1}%
  #1\smash{, \the\charDepth}
}

\testGTree{0.15\tcbfitdim}{\showDepth f}
\testGTree{0.15\tcbfitdim}{\showDepth r}
\testGTree{0.15\tcbfitdim}{r \rule[-.2pt]{1pt}{5pt}}

\paragraph{Group 4} a slightly larger \verb|level size=1.6cm| fixes the original problem.
\testGTree[level size=1.6cm]{0pt}{f}
\testGTree[level size=1.6cm]{0pt}{r}
\end{document}

Solution 2

Result: fix node width and let node height change by content. Restricted by the package implementation, you cannot have both width and height variable.

Main change: use tcolorbox option natural height. Search natural height in doc of genealogytree to see more examples.

Changes in detail:

  • Add option natural height inside box={...}.
  • Change processing=fit to processing=tcolorbox, to allow variable node height. Also add size=title inside box={...} to set tcolorbox margins.
  • Adjust node size to some appropriate value. This would be used as the fixed node width.
  • Replace useless fitting related options. Inside box={...},
    • replace fit basedim=8pt by fontupper=\fontsize{8}{9.6}\selectfont
    • replace 0.15\tcbfitdim used in before upper={...} by 1.2pt (8pt * 0.15).

variable node height

\documentclass{article} %or standalone
\usepackage[all]{genealogytree}

\gtrset{info separators={\par}{. }{}{}} %no period after comment

\begin{document}
\begin{tikzpicture}[baseline=(current bounding box.center)]
  \genealogytree[
      processing=tcolorbox,
      level distance=1cm,
      level size=1.5cm,
      node size=3cm,
      box clear,
      box={enhanced, 
        fontupper=\fontsize{8}{9.6}\selectfont,
        halign=center, valign=center, size=title,
        % 1.2pt = 8pt * 0.15
        before upper={\parskip=1.2pt plus 0pt minus 0pt},
        drop fuzzy shadow,
        natural height
      },
      database content interpreter,
      database format=full,
      list separators hang,
      edges=rounded,
      date format=dd.mm.yyyy] 
  {
    parent{
      g[id=xxx]{
        female,
        name = {Name \surn{Long Surname}},
        birth- = {1865-10-08},
        death- = {1945-08-20},
        comment = {born NameWithfxx},
      }
    }
  }
\end{tikzpicture}
\end{document}
8
  • Thank you very much for your answer, I already was a bit desperate since I didn't know how to fix it. For me as a beginner its very difficult to understand/see connections like this since so many packages (I don't know that well yet) different from the one you initially use (genealogytree) are internally used.
    – atticus
    Mar 21, 2020 at 16:19
  • Is there a way to make this more general so that everywhere the same fontsize is used (i.e. allowing the height to be more dynamic)?
    – atticus
    Mar 21, 2020 at 16:19
  • 1
    @atticus 1) Using latex is not always so difficult. You just encountered a deep dependence package relations. Say, genealogytree relies tcolorbox, and tcolorbox relies tikz, and the latter in each pair is more complicated than the former. This is a (very) rare case. 2) I have added a no-font-shrink example. Mar 21, 2020 at 17:43
  • Using latex is not always so difficult. Yes I know, as a matter of facts it is easy after the first short time, but only the normal things not something like this where you have to handle that much big packages (espacially pgf/tikz is not that easy). Would you just shortly point out what option are (at least for tcolorbox) obsolete after that change? (so that one could experiment a bit)
    – atticus
    Mar 21, 2020 at 19:08
  • @atticus Answer updated. fit fontdim is still usefull. Mar 22, 2020 at 5:51

You must log in to answer this question.

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