When smallcaps, bold, or italics are used for part of a hyphenated word in a right-to-left bidi environment, weird things happen.

The following is a MWE of what I'm noticing (compiled with XeLaTeX):


\setmainfont[Scale=MatchUppercase]{Libertinus Serif}



    This is all left-\textsc{to}-right, with some smallcaps.

    This is all right-to-left.

    This \emph{should} all be right-\textsc{to}-left, but isn't.

    This \emph{should} all be right-\emph{to}-left, but isn't.

    This \emph{should} all be right-\textbf{to}-left, but isn't.


This renders as follows, with "left-to-right," appearing as "-left,toright-":

rendering of the above code, with the formatted words "to" causing "left-to-right," to render as "-left,toright-"

Note that what I'm actually trying to do involves polyglossia and some LTR text in an RTL environment, but the underlying issue appears to come from the bidi package.

  • Does the same thing happen when no font changes are involved, but just "left-to-right"? Or, more specifically, what is the output with no font changes in "left-to-right"? Dec 4, 2022 at 20:41
  • @barbarabeeton If I understand your question correctly, this is addressed by the first line in the RTL environment, "This is all right-to-left." I.e., it displays as expected. (If you're asking something else, please clarify and I'll update the question accordingly.) Dec 4, 2022 at 20:42
  • I haven't used bidi very much, but I think you're expecting the output "right-to-left" if there are no font changes. Is that correct, and do you get that result? Dec 4, 2022 at 20:53
  • 1
    Oh. On rereading the example, I see my question is answered. Apologies for my inattention. Dec 4, 2022 at 21:32
  • don't use the standalone class for such examples. That is a rather complicated class with various side effects. Always use article. Apart from this I would suggest to try lualatex (with babel) instead of bidi. Dec 4, 2022 at 21:36

1 Answer 1


Per comments, this appears to just be a deficiency of bidi, and there's no hope to ever get it working right that way.

But with lualatex and babel, which do not use the bidi package (as opposed to xelatex and polyglossia, which do), a similar effect is obtainable.


\babelprovide[onchar=fonts ids]{hebrew}

\setmainfont[Scale=MatchUppercase]{Libertinus Serif}


    This is all left-\textsc{to}-right, with some smallcaps.

    איצט איז דא נישט קײן פראבלעם {\textdir TLT right-to-left} און דארף עס נישט זײן
     איצט איז דא נישט קײן פראבלעם {\textdir TLT right-\textsc{to}-left} און דארף עס נישט זײן
     איצט איז דא נישט קײן פראבלעם {\textdir TLT right-\emph{to}-left} און דארף עס נישט זײן

     איצט איז דא נישט קײן פראבלעם {\textdir TLT right-\textbf{to}-left} און דארף עס נישט זײן


This renders as follows, which is as expected:

various font styles in RTL environments rendered correctly now

  • The explicit directions aren’t necessary. Without \textdir TLT it works. Dec 5, 2022 at 15:31
  • Only because of the RTL script that was used. If I make an RTL environment with an LTR script, it reverses the order of characters as opposed to just the order of words, so I wasn't able to reproduce the effect nicely that way. I left the textdir specification in there to easily switch the example to an LTR script. Dec 7, 2022 at 22:44

You must log in to answer this question.

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