T-F-S / genealogytree

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

Using genealogytree with RTL languages #44

Closed hzarnani closed 8 months ago

hzarnani commented 8 months ago

Hello @T-F-S, This is not an issue per se, but rather just a question. And it is somewhat related to the question https://github.com/T-F-S/tcolorbox/issues/190.

I'm seeking advice on how best to use tcolorbox and the genealogytree package in a "mostly" RTL document (I use the term "mostly" the same way the babel package documentation uses it in Sec. 1.3 "Mostly monolingual documents").

If a genealogytree is drawn when the selected language is an RTL one, the text would be placed appropriately on the page, but the boxes would go to the right and off the margin. Short of having a way to "horizontally flip" the resulting TikZ picture along its left side to align the text and graphics, one has to:

  1. draw the tikzpicture in an LTR environment and just switch to the other language inside the tcbox, and
  2. reverse the order of children/parents so the first parent/child appears on the right and the last appears on the left

The second (reversing the order of elements in a parent or child) is easy enough. However, what I'm having trouble with as a beginner LaTeX user is changing the language inside gtr box and still be able to use all the predefined database processors and templates. I have played with setting the node processor as in Sec. 6.1 and 6.3 of the documentation, but that often has other side effects and doesn't apply to all processing options.

Next, I was going to try renewing the \tcboxfit command and surrounding the body with \begin{otherlanguage}{persian}...\end{otherlanguage}, but I wasn't sure if that was going to be fruitful or even how to correctly do that.

My apologies for not providing any specific examples or pictures. I can add some later. But I thought I would raise the question first in case there is a general recommendation.

T-F-S commented 8 months ago

My apologies for not providing any specific examples or pictures. I can add some later. But I thought I would raise the question first in case there is a general recommendation.

No, I fear there is no general recommendation, because I have utterly no experience with RTL languages at all...

I presume, processing=fit may be useful for you (database may be too LTR specific). Here, you can give options to the boxes through box={.....} as seen e.g. on page 141 or 142.

Maybe, the following may work (for a recently updated tcolorbox package):

...
box={
   environment upper args={otherlanguage}{{persian}}  %   Note the double brackets around {{persian}}
}
...

This inserts an environment to the boxes, but may fail for special verbatim-like environments. Give it a try.

hzarnani commented 8 months ago

That you very much. I'll give that a try.

hzarnani commented 8 months ago

In my attempt at this, I've hit a roadblock, which is likely more of a package management issue.

I upgraded my tcolorbox package to version 6.2.0 to get the newly introduced feature (environment upper args). However, now when I \usepackage{tcolorbox} in any document, I arrive at the following error message.

! Undefined control sequence.
\__tcobox_set_backslash_removed:Nn ...1\tl_set:Ne 
                                                  #1{\exp_last_unbraced:NV \...

l.2522 \DeclareTotalTCBox{\tcboxverb}
                                   { O{} v }{verbatim,#1}{#2}

I had first just downloaded the code and copied the files in my local project directory without updaing my site-wide distribution. When I saw the above error, my first assumption was that I've messed something up, or that using the latest development code wasn't as easy as copying the files in my local directory or ~/texmf/tex. So I decided to use the TeX Live Utility on my Mac to properly do the upgrade. But I arrived at the same error, now across the board, unfortunately. I haven't tried tlmgr on my Ubuntu machine yet. But before going down that route, I'm wondering if I should do anything special to use the latest version of tcolorbox.

hzarnani commented 8 months ago

The ! Undefined control sequence. issue I was having must have been due to a user error on my part. I did an upgrade of all my texlive packages, and that got me past this issue. I'm not sure which of the tcolorbox dependencies had to be updated to resolve it though.

And the suggestion you'd given me actually seems to work just fine with type setting RTL inside a genealogytree tcolorbox. Thank you very much!

T-F-S commented 8 months ago

Upgrading was exactly the right thing. tcolorbox version 6.2.0 uses a quite new feature from LaTeX3 (I wasn't aware that it so sooo new), see https://github.com/T-F-S/tcolorbox/issues/267#issuecomment-1899287442. This caused the error.