8

I need to add a command \setRTL from the bidi package to write right-to-left text, at the beginning of every frame.

Another answer does not solve the issue; any suggestions?

\documentclass{beamer} 
\usefonttheme{serif}
\usetheme{Madrid}

\usepackage{etoolbox}  % no longer needed; loaded by Beamer from v3.36

\usepackage{bidi}

\AtBeginEnvironment{frame}{\setRTL}

\begin{document}
    \begin{frame}{frame title}
        hello world

        \begin{enumerate}
            \item first item
            \item second item
        \end{enumerate}
    \end{frame}
\end{document}

enter image description here

Coby Viner
  • 1,939
Salim Bou
  • 17,021
  • 2
  • 31
  • 76

1 Answers1

10

You cannot directly hook into the begin of Beamer's frame environment with the usual etoolbox \AtBeginEnvironment, as hinted at elsewhere.

Replacing your \AtBeginEnvironment with \BeforeBeginEnvironment, is actually sufficient. That is:

\BeforeBeginEnvironment{frame}{\setRTL}

This may, however, have undesirable side-effects, since it hooks in prior to the environment's definition.

One alternative is the following (hooking into @checkframetitle), adapted from another similar answer, however it will not affect the slide's title:

\makeatletter
    \pretocmd\beamer@checkframetitle{\setRTL}
\makeatother

Finally, you could instead hook into the earlier @framenotesbegin, which would affect the slide title (obtaining an equivalent result to the \BeforeBeginEnvironment approach):

\makeatletter
    \pretocmd\beamer@framenotesbegin{\setRTL}
\makeatother
Coby Viner
  • 1,939