1

i know that this answer is a duplicate but the solution proposed to other question doesn't work for me.

So, i declared my language and my style and then add a "literate={è}{{\`{e}}}{1}" (or "literate={è}{{\`e}}1", i tried a lot of combinations) to use "\`e" as "e" accented. But this doesn't work for me. for example:

\lstset{
   language=Arduino,
   style=myArduino,
   literate={è}{{\`{e}}}{1},
}

and then:

\begin{lstlisting}[style=myArduino, caption="funzione "loop", captionpos=b]
    // quando il bluetooth \`e connesso posso procedere ad inizializzare...
\end{lstlisting}

that should produce an output with the "\`e" substituted by the è, but that doesn't happen and i get "\`e" as output.

now, how i can write the accented letters like "\`e" and get the è as output?

(i have an english keyboard that don't have accented letters)

thanks a lot.

  • 3
    Use quando il bluetooth è connesso. The purpose of literate is to transform è into \`e, not conversely. – egreg Feb 14 at 0:34
  • Any keyboard is capable of producing è – egreg Feb 14 at 10:11
  • sorry, in common latex i use \`e as è, but in lstlisting it doesn't work, i can't produce the è with my keyboard and i can't copy past it every time. there is a solution for this? – simone viozzi Feb 14 at 15:19
  • What strange keyboard is it? – egreg Feb 14 at 16:31
  • 1
    It's necessary to know what operating system you are on. – egreg Feb 14 at 16:39
1

You could try the escapeinside feature

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstset{breaklines = true, frame = trBL, tabsize = 4, basicstyle = \small \ttfamily, keywordstyle = \color{blue}, stringstyle = \color{red}, rulecolor = \color{black}}
\usepackage[usenames, dvipsnames]{color}

\begin{document}

\begin{lstlisting}[language = Python, caption = funzione ``loop", captionpos = b, escapeinside = {(*@}{@*)}]
mellin_parameter = {'number_of_gl_points': 8, 'x_axis_intersection': 1.9, 'phi': (3.0 * numpy.pi) / 4.0, 'extension': False}
with open(input_path.replace('pretable/', 'mellin_parameter.pickle'), 'wb') as pf:
    pickle.dump(mellin_parameter, pf) ## accented (*@ \`{e} @*)
\end{lstlisting}

\end{document}

which would produce

escape in lstlisting

  • 1
    i resolved the issue using a text editor and replacing the \`e with the è, but this is a good method to do it within latex. thanks – simone viozzi Feb 25 at 14:16

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.