2

I am using polyglossia (arabic and english) and a conditional environment that I can turn off and on, representing the teacher's version.

In the MWE below, I have three single rows in tabular and I expect the output to be the same in each.

  1. The first row uses \textenglish and gives the result I want and expect.

  2. The second row uses the begin{english} environment but the RTL seems to be ignored. I don't know why.

  3. The third row uses the conditional environment, and its RTL is also ignored and the alignment is different again.

It is the behaviour of the third row I want to fix, but the first two are good for comparison.

I wonder if the bidi package might have a bug here, but I too newbie to be able to know for sure.

Here is the MWE. The fonts are unimportant.

\documentclass[11pt,oneside]{article}
\newif\ifteacher
\teachertrue
% \teacherfalse
\usepackage{environ}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.00]{Times New Roman}
\newfontfamily\englishfont[Script=Latin]{Times New Roman}

\NewEnviron{forteacher}
{
\ifteacher
\begin{english}
\BODY\par
\end{english}
\else
\fi
}

\begin{document}

\begin{tabular}{rl}
ااا  ببب & \textenglish{aaa bbb} 
\end{tabular}

\begin{tabular}{rl}
ااا  ببب &
\begin{english}
aaa bbb
\end{english} 
\end{tabular}

\begin{tabular}{rl}
ااا  ببب &
\begin{forteacher}
aaa bbb
\end{forteacher} 
\end{tabular}

\end{document}
1

This is not a bidi package bug but I think you have a misunderstanding of when to use \textenglish and when to use english environment.

For short text (less than a line), you use \textenglish and for long text, you use english environment. The r or l column of a tabular can contain only short text so using english environment does not make sense and it will have no effect; what you are asking is equivalent to

\hbox{\begin{english}...\end{english}}

So in this case, you need to use \textenglish command. However, when you have p columns, you can use the english environment to typeset your text from left to right.

  • 1
    It is usual to answer with an MWE so that op and other readers can proof your answer without having to code themselfes ... – Mensch Nov 11 '15 at 0:15
  • ok, i think I get it. Use p{}. This fixes the RTL problem in this question. But it leads me to another problem. I will post as a separate question. – Tim Nov 11 '15 at 10:50
1

For this purpose you can just use primitives \beginL and \endL which are used from bidi to write left-to-right inside right-to-left sentences, you can take a look at The e-TeX Short Reference Manual.

\documentclass[11pt,oneside]{article}
\newif\ifteacher
\teachertrue
% \teacherfalse
\usepackage{environ}
\usepackage{polyglossia}
\setmainlanguage[numerals=mashriq]{arabic}
\setotherlanguage{english}
\newfontfamily\arabicfont[Script=Arabic, Scale=1.00]{Times New Roman}
\newfontfamily\englishfont[Script=Latin]{Times New Roman}

\NewEnviron{forteacher}
{%
\ifteacher
\beginL
\BODY\par
\endL
\else
\fi
}

\begin{document}

\begin{tabular}{rl}
ااا  ببب &
\textenglish{aaa bbb} 
\end{tabular}

\begin{tabular}{rl}
ااا  ببب &
\beginL
aaa bbb%
\endL
\end{tabular}

\begin{tabular}{rl}
ااا  ببب &
\begin{forteacher}
aaa bbb
\end{forteacher}
\end{tabular}

\end{document}

enter image description here

  • 1) so bidi is broken at this point? and also (2) I think this solution only works for tables with single line rows. If I change to paragraphs, it breaks again. – Tim Nov 10 '15 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.