4

For some reason the text of the second node is not printed inside the box of the node, but on the complete opposite side of the tikzpicture.

Any idea on how to fix it?

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{positioning,backgrounds}

\usepackage[english,hebrew,bidi=basic,provide=*]{babel}
\babelfont[hebrew]{sf}[Script=Hebrew]{Arial}

\begin{document}
\begin{frame}
\begin{tikzpicture}[background rectangle/.style={fill=gray!33}, show background rectangle]

\node [draw,text width=0.75\textwidth, align=left, outer sep=0pt,inner sep=0pt](n1) {%
לורם איפסום דולור סיט אמט.
};

\node [draw,below = 0pt of n1.south east,anchor=north east,outer sep=0pt,inner sep=0pt](n2) {%
שלום עולם};
\filldraw (n2) circle (1pt);
\end{tikzpicture}
\end{frame}
\end{document}

screenshot

(The MWE is with beamer but happens with article and book as well)

2 Answers 2

5

Add the package option layout=graphics, that is:

\usepackage[english,hebrew,bidi=basic,layout=graphics,provide=*]{babel}

enter image description here

4
  • Oh, this is nice to know! Up to now, I always changed the language to English (or any other LTR language) for the TikZ environment and only in the nodes set the language back to the RTL language. This makes things much easier! Commented Mar 16, 2023 at 16:25
  • 2
    @JasperHabicht Yes, I remember :)
    – tush
    Commented Mar 16, 2023 at 16:30
  • 1
    Mixing RTL and LTR stuff is far from trivial. This options mostly works, but it may fail in some cases. Just report any issue you find and I’ll fix it (more precisely, I’ll do my best to fix it). Commented Mar 16, 2023 at 17:34
  • @JavierBezos That's right, as, for example, in the answer I wrote.
    – tush
    Commented Mar 17, 2023 at 13:47
-1

Note that inserting a \noindent before the tikzpicture environment results in the problem to stay, regardless of the layout=graphics option.

Same with inserting text before the environment:

\documentclass{article}
%% same preamble as in Javier Bezos' answer
\begin{document}
אבג% so there is no \par command before the tikzpicture
\begin{tikzpicture}
〈same code〉
\end{tikzpicture}
\end{document}

enter image description here

1
  • 1
    Thanks. I’ll have a look at it, but please don’t report bugs as an answer. Either ask for help or report the bug as explained in the manual or in the readme (I wonder if the downvote is for this reason, or perhaps because it’s not a MWE, but I would suggest to the downvoter a more constructive approach with a comment about the reason). I’ve opened an issue: github.com/latex3/babel/issues/227 Commented Mar 17, 2023 at 17:46

You must log in to answer this question.

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