2

I write a document in Lyx and use a minted environment. I added a python code inside a Tex code box, but after compilation, Lyx "reverses" the order of the words inside the " " marks.

This is the code I wrote:

\begin{minted}[linenos=true, numbersep=5pt, fontsize=\small]{python}
Total = 0
I = 0
while I < 100:
    x = int(input("enter a number"))
    if x < 0:
        continue
    Total += x
    I += 1
print(Total)
\end{minted}

and this is the result after compilation: enter image description here

as you can see, the order is reversed. I tried "playing" with the order, to "trick" Lyx to reverse it again, but it's still not perfect.

how can I solve this?

3
  • 1
    Try adding \begin{LTR} before \begin{minted}, and \end{LTR} after \end{minted}. Usually LyX do it by default if you use the minted environment from the GUI and don't use ERT, but if IRCC you use the latter.
    – Udi Fogiel
    Jun 3 at 0:14
  • worked perfectly! Thanks! Jun 3 at 0:28
  • 1
    you’re welcome!
    – Udi Fogiel
    Jun 3 at 0:29

1 Answer 1

4

As Udi suggested in the comments

Try adding \begin{LTR} before \begin{minted}, and \end{LTR} after \end{minted}. Usually, LyX does it by default if you use the minted environment from the GUI and don't use ERT, but if IRCC you use the latter.

2
  • 2
    You can accept your own answer.
    – Udi Fogiel
    Jun 3 at 0:31
  • apparently only after 2 days. But I hope whoever encounters this problem in the future, will see your answer. Thanks again! Jun 3 at 0:37

You must log in to answer this question.

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