1

The MWE shown below, the text in the nodes of the Tikz picture apears outside of the node, the nodes are drawn correctly yet the text in them is outside, how can I fix this issue? Also, some times the letters are output in reverse order. How can I fix such issues?

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} 
\usepackage{pdflscape}
\usepackage[hidelinks,colorlinks=true,breaklinks,allcolors=blue]{hyperref} 

\usepackage{tikz} 
    \usetikzlibrary{tikzmark,arrows.meta,arrows,positioning,matrix,quotes, shapes.geometric,calc,decorations.pathreplacing}
\usepackage[edges]{forest}  


\begin{filecontents}{babel-cop.ini}
[identification]
charset = utf8
version = 0.1
date = 2019-08-25
name.local = ϯⲙⲉⲧⲣⲉⲙⲛ̀ⲭⲏⲙⲓ
name.english = Coptic
name.babel = coptic
tag.bcp47 = cop
tag.opentype = COP
script.name = Coptic
script.tag.bcp47 = Copt
script.tag.opentype = copt
level = 1
encodings = 
derivate = no
[captions]
[date.gregorian]
[date.islamic]
[time.gregorian]
[typography]
[characters]
[numbers]
[counters]
\end{filecontents}

\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelprovide[import=el]{polutonikogreek}
\babelprovide[import=cop]{coptic}

\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}
\babelfont[english]{rm}{Times New Roman}
\babelfont[polutonikogreek]{rm}[Language=Default]{Palatino Linotype}
\babelfont[coptic]{rm}[Language=Default]{FreeSerifAvvaShenouda}

\usepackage{booktabs}
\usepackage{makecell} 
\usepackage{boldline} 



\usepackage{fancyhdr} 
\usepackage[normalem]{ulem}



\begin{document}

\newgeometry{landscape,margin=2.5cm}
\pagewidth  = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%
%begin Flow chart
%%%%%%%%%%%%%%%%%%%%%%%%%%%Block definition%%%%%%%%%%%%%%%
%start and stop blocks.
\tikzset{startstop/.style={circle, minimum width=1.5cm, minimum height=1cm,text centered, draw=black, fill=black}}

\tikzset{io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=1.5cm, minimum height=1cm, text centered, draw=black, none}}

\tikzset{process/.style={rectangle, minimum width=1.5cm, minimum height=1cm, text centered,draw=black, fill=none}}

\tikzset{emph/.style={rectangle, minimum width=1.5cm, minimum height=1cm, text centered, draw=black, fill=none}}

\tikzset{decision/.style={diamond, minimum width=1.5cm, minimum height=1cm, text centered, draw=black, fill=none}}

\tikzset{arrow/.style={thick,->,>=stealth}}
\tikzset{line/.style={thick}}

%%%%%%%%%%%%%%%%Building the flow chart%%%%%%%%%%%%%%%%%

\begin{tikzpicture}[node distance=0.5cm,auto]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node (start) [startstop] {};
%%%%%%%%%%%%%%%%325%%%%%%%%%%%%%%%%%%%
\node (325) [process, left = of start,text width=2cm,align={center}]{ذهب الولد};
\node (325-emph) [process, below = of 325, dashed,text width=2cm] 
{\textbf{جاء الإنسان}
لم ينام
\uline{سعيد}
\foreignlanguage{polutonikogreek}{δφσδφδσ}
};
%%%%%%%%%%%%%%%%325%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%arrows%%%%%%%%%%%%%%%%%%%

\draw [arrow] (start) -- (325);
\draw [line,dashed] (325) -- (325-emph);
%\draw [arrow] (325) -- (381);


\end{tikzpicture}

%\end{sidewaysfigure}
%\end{landscape}

\clearpage
\restoregeometry
\pagewidth  = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%


Result

Silva
  • 743
  • 1
    Off-topic but \tikzstyle is deprecated. It would be great if you could replace those with the corresponding \tikzset syntax. –  Apr 22 '20 at 17:45
  • @Schrödinger's cat, do you happen to have any reference, it is my first time using tikz – Silva Apr 22 '20 at 17:48
  • 1
    See https://tex.stackexchange.com/q/52372/194703. –  Apr 22 '20 at 17:50
  • Recent versions of babel are not supposed to need \foreignlanguage commands to detect a RTL script, but does adding them solve the issue? – Davislor May 11 '20 at 18:50
  • I am using the \foreignlanguage command for non-arabic scripts since the "Arabic" language is the default language of the document. But by that do you mean that I remove the foreign langguage commands and run the file where the languages are detected automatically??? – Silva May 11 '20 at 18:54
  • @Silva I'll have a look at it, but mixing text and graphics is still problematic in bidi layouts. Babel attempts to fix the most usual cases, but very likely there are still others where you must play with explicit markup. – Javier Bezos May 12 '20 at 14:39
  • 1
    @JavierBezos, you may also want to take a look at: https://tex.stackexchange.com/questions/543588/forest-package-tree-connector-apear-reversed as well as https://tex.stackexchange.com/questions/543445/cartouche-textbox/543498?noredirect=1#comment1373302_543498 – Silva May 12 '20 at 17:00
  • 1
    @Silva Thank you. The more examples I have, the better. – Javier Bezos May 12 '20 at 17:04

1 Answers1

1

The cause of the issue is the use of arabic language as the main language, and thus write from right to left, upon locally switching to a left to right language, the issue is resolved

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} 
\usepackage{pdflscape}
\usepackage[hidelinks,colorlinks=true,breaklinks,allcolors=blue]{hyperref} 

\usepackage{tikz} 
    \usetikzlibrary{tikzmark,arrows.meta,arrows,positioning,matrix,quotes, shapes.geometric,calc,decorations.pathreplacing}
\usepackage[edges]{forest}  


\begin{filecontents}{babel-cop.ini}
[identification]
charset = utf8
version = 0.1
date = 2019-08-25
name.local = ϯⲙⲉⲧⲣⲉⲙⲛ̀ⲭⲏⲙⲓ
name.english = Coptic
name.babel = coptic
tag.bcp47 = cop
tag.opentype = COP
script.name = Coptic
script.tag.bcp47 = Copt
script.tag.opentype = copt
level = 1
encodings = 
derivate = no
[captions]
[date.gregorian]
[date.islamic]
[time.gregorian]
[typography]
[characters]
[numbers]
[counters]
\end{filecontents}

\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelprovide[import=el]{polutonikogreek}
\babelprovide[import=cop]{coptic}

\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{amiri}
\babelfont[english]{rm}{Times New Roman}
\babelfont[polutonikogreek]{rm}[Language=Default]{Palatino Linotype}
\babelfont[coptic]{rm}[Language=Default]{FreeSerifAvvaShenouda}

\usepackage{booktabs}
\usepackage{makecell} 
\usepackage{boldline} 



\usepackage{fancyhdr} 
\usepackage[normalem]{ulem}



\begin{document}

\newgeometry{landscape,margin=2.5cm}
\pagewidth  = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%
%begin Flow chart
%%%%%%%%%%%%%%%%%%%%%%%%%%%Block definition%%%%%%%%%%%%%%%
%start and stop blocks.
\tikzset{startstop/.style={circle, minimum width=1.5cm, minimum height=1cm,text centered, draw=black, fill=black}}

\tikzset{io/.style={trapezium, trapezium left angle=70, trapezium right angle=110, minimum width=1.5cm, minimum height=1cm, text centered, draw=black, none}}

\tikzset{process/.style={rectangle, minimum width=1.5cm, minimum height=1cm, text centered,draw=black, fill=none}}

\tikzset{emph/.style={rectangle, minimum width=1.5cm, minimum height=1cm, text centered, draw=black, fill=none}}

\tikzset{decision/.style={diamond, minimum width=1.5cm, minimum height=1cm, text centered, draw=black, fill=none}}

\tikzset{arrow/.style={thick,->,>=stealth}}
\tikzset{line/.style={thick}}

%%%%%%%%%%%%%%%%Building the flow chart%%%%%%%%%%%%%%%%%
\begin{otherlanguage}{coptic}
\begin{tikzpicture}[node distance=0.5cm,auto]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node (start) [startstop] {};
%%%%%%%%%%%%%%%%325%%%%%%%%%%%%%%%%%%%
\node (325) [process, left = of start,text width=2cm,align={center}]{\foreignlanguage{arabic}{ذهب الولد}};
\node (325-emph) [process, below = of 325, dashed,text width=2cm] 
{\foreignlanguage{arabic}{\textbf{جاء الإنسان}
لم ينام
\uline{سعيد}}
\foreignlanguage{polutonikogreek}{δφσδφδσ}
};
%%%%%%%%%%%%%%%%325%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%arrows%%%%%%%%%%%%%%%%%%%

\draw [arrow] (start) -- (325);
\draw [line,dashed] (325) -- (325-emph);
%\draw [arrow] (325) -- (381);


\end{tikzpicture}
\end{otherlanguage}
%\end{sidewaysfigure}
%\end{landscape}

\clearpage
\restoregeometry
\pagewidth  = \paperwidth
\pageheight = \paperheight
\fancyheadoffset[lh]{0pt}%


enter image description here

Silva
  • 743