0

I am trying to insert a listing in LyX in an enumeration ("\item ..."). My document is in French, with UTF8-encoding for the accents. However, when I click on the button "Program listing" in the Insert menu, LyX adds to the latex code:

\inputencoding{latin9} 
    \begin{lstlisting} 
    \end{lstlisting} 
\inputencoding{utf8}

When I try to compile, it failed if I had accents in the document after the code listing ("The control sequence marked should not appear between \csname and \endcsname.")

However, if I insert manually (Ctrl+L) just the environment lstlisting (or even just lstinline, which is my objective) without any encoding option, it compiles perfectly, but it doesn't look as some code in LyX.

What can I do? Indeed, I would like to have the nice look of the code in LyX.

Thank you.

The log: https://pastebin.com/TBvd7vqS

The minimal .lyx file: https://pastebin.com/42cBkzdx

The .tex produced: https://pastebin.com/gyDef1Uj

  • 1
    You might get more help if you post minimal example .lyx and .tex files. See here: wiki.lyx.org/FAQ/MinimalExample – scottkosty Apr 11 at 22:27
  • Thanks for your comment! I edited my post to provide a minimal example. Are there other things I could do? – jd6 Apr 12 at 6:49
  • 1
    Nice clean mwe, thanks. The .lyx file compiles without error for me. I get this PDF: dropbox.com/s/41gqps1uaock3vs/mwe.pdf. I have a different system though, Ubuntu with TeX Live. Hopefully someone else has an idea what's going wrong. If you don't get help here, consider joining lyx-fr@lists.lyx.org. Probably users on that list have familiarity with UTF-8 (and hopefully listings?). Or lyx-users@lists.lyx.org – scottkosty Apr 12 at 12:52
  • 1
    Thank you for the answer! I will wait a few days to see if anyone has any ideas, before joining lists.lyx.org – jd6 Apr 12 at 13:50
  • I found an alternative. I replaced pdflatex with luatex in the settings, and now it works with luatex. But I am still interested in finding a solution with pdf latex. – jd6 Apr 13 at 12:54

Your Answer

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

Browse other questions tagged or ask your own question.