As in the following question, I'm working in LyX in Hebrew, by using the "use non-TeX fonts (via XeTeX/LuaTeX)" option. When I insert a math equation LyX automatically wraps it with \LRE{}. This causes some problems with spacing and has no benefits (formulas also look just fine without it). Is there a way to tell LyX to stop automatically adding \LRE{} around equations?

  • If you put \renewcommand{\LRE}[1]{#1} in your preamble (Document > Settings > LaTeX Preamble), does that do what you want (check the PDF output)? I don't believe it's easy to stop LyX from inserting LRE. If you happen to be on Linux I don't think it would be too difficult to stop LyX from inserting LRE in the source code and recompile.
    – scottkosty
    Aug 22, 2021 at 13:48
  • @scottkosty that seems to cancel the \LRE command altogether. However I do want it to apply when I combine English text in my file. Is there a way to remove it from the equations only?
    – 35T41
    Aug 22, 2021 at 16:13
  • Ah I understand now. I'm not sure how to do that.
    – scottkosty
    Aug 22, 2021 at 17:21

1 Answer 1


Currently it i not possible from preventing LyX from enclosing equations with \LRE, it might be fixed in the future.

If I understand your problem correctly, you want to avoid some vertical spacing the the \LRE is causing when surrounding display equations. The following code will redefine \LRE to check if the first token of its argument is \[, if so it will do nothing, otherwise it will behave as usual (note that it will cause problems in situations like \textenglish{\[a+b=c\] Hello there}, but I don't think there is a situation where you need to type something like that).

        \expandafter\ifx\LRE@gobble #1{}{}\stopgobblehere\[

In LyX you should add that to Document > Settings > LaTeX Preamble.

Another possibility is using expl3 syntax


        \tl_set:Ne \l_tmpa_tl { \tl_head:n { #1 } }
        \tl_if_eq:NnTF \l_tmpa_tl { \[ }
            { #1 }
            { \protect\pLRE{#1} }


You can add a conditional for inline equation, but I don't think \LRE i causing spacing problems around inline equations.

You must log in to answer this question.

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