T-F-S / genealogytree

pedigree and genealogy tree diagrams
LaTeX Project Public License v1.3c
47 stars 7 forks source link

Add and print custom date values #32

Closed jojomi closed 5 years ago

jojomi commented 5 years ago

Hello Thomas,

I tried to add a custom date (religious marriage date in my case) to my tree data by defining my own database format and including the key in the gtreventlist:

\gtrDeclareDatabaseFormat{full-dates}{}{%
    \gtrPrintName%
    \begin{gtreventlist}%
        \gtr@list@event{birth}%
        \gtr@list@event{baptism}%
        \gtr@list@event{engagement}%
        \gtr@list@event{marriage}%
        \gtr@list@event{marriagereligious}%
        \gtr@list@event{divorce}%
        \gtr@list@event{floruit}%
        \gtr@list@event{death}%
        \gtr@list@event{burial}%
    \end{gtreventlist}%
    \gtr@print@infolist%
}

In the documentation I did not find anything about custom date values and it seems to be ignored here. Is there a way to get custom date fields for my data?

jojomi

mikkelee commented 5 years ago

Perhaps the diff from when I added floruit events is useful?

See #9

T-F-S commented 5 years ago

From a quick check without coding, I think you just missing to add a line

\gtr@db@new@event@store{marriagereligious}

to get it alive. Maybe, looking for the implementation of divorce gives enough information for your adaption.

jojomi commented 5 years ago

Thanks to both of you! @T-F-S your suggestion helped to get it to work basically.

This is my current code:

\makeatletter
\gtr@db@new@event@store{marriagereligious}
\makeatother

\gtrset{
    %marriageagereligious/.initial=\gtrsymBuried,
    /gtr/event prefix/marriageagereligious=brel,
}

\makeatletter
\gtrDeclareDatabaseFormat{full-ages}{}{%
    \gtrPrintName%
    \begin{gtreventlist}%
        …
        \gtr@list@event{marriage}\pgfkeysifdefined{/gtr/database/save/marriageage}{ \textcolor{gray}{(\pgfkeysvalueof{/gtr/database/save/marriageage})}}{}%
        \gtrifeventdefined{marriagereligious}{%
            \gtr@list@event{marriagereligious}\pgfkeysifdefined{/gtr/database/save/marriageagereligious}{ \textcolor{gray}{(\pgfkeysvalueof{/gtr/database/save/marriageagereligious})}}{}%
        }{}%
   …
    \end{gtreventlist}%
    \gtr@print@infolist%
}

My attempts to set a "symbol" were unsuccessful though :/

\gtrset{
    %marriageagereligious/.initial=\gtrsymBuried, % no visible effect at all
     /gtr/event prefix/marriageagereligious=brel, %  Package pgfkeys Error: I do not know the key '/gtr/event prefix/marriageagereligious', to which you passed 'brel', and I am going to ignore it. Perhaps you misspelled it.
}
T-F-S commented 5 years ago

Try to add .initial to create the new key/option:

\gtrset{/gtr/event prefix/marriageagereligious/.initial=brel}

After the initial setting, the option can be used directly (if needed)

\gtrset{/gtr/event prefix/marriageagereligious=\somesymbolmacro}
jojomi commented 5 years ago

Sorry for the late answer, but your code works, @T-F-S, thank you very much!

I tried to add a name for the legend, but that did not work this way (sorry, I am such a lousy TeX programmer!):

\gtrset{
    /gtr/event prefix/marriagereligious/.initial=\gtrsymChurch,
}

\gtrset{language@/german/.code={%
  \gtrset{symlang/.cd,
    Church=kirchl. getraut,
  }
}}

\gtr@symbol@factory{Church}{%
  \begin{gtr@tikzpicture}[line width=3mm,color=gtrsymbol]%
    \path[use as bounding box] (0,0) rectangle (2.7,2.1);
    \fill (0.25,0) -- (2.25,0) -- (2.25,1.5) -- (1.8,1.75) -- (1.35,1.5) -- (1.35,1) -- (0.25,1) -- cycle;
  \end{gtr@tikzpicture}%
}{0.011}%

This is my result though: legend

Do you perhaps have another kind hint how to proceed here?

T-F-S commented 5 years ago

Try to set the following in the preamble of your document:

\gtrset{language=german}
\gtrset{symlang/Church=kirchl. getraut}

Otherwise, the complete language file would have to be replaced.

jojomi commented 5 years ago

Thank you for the pointer to the right direction. I got it to work after moving the second line after the symbol creation via the factory. That probably is obvious, but might still be worth mentioning.