# showexpl doesn't work with accents

It seems that showexpl removes the accents when it is processing them.

How can I make it to use accented letters?

Is there a replacement or a similar package that is more robust?

\documentclass{article}
\usepackage[T1]{fontenc}

\usepackage{listings}
\usepackage{showexpl}
\lstset {
literate=%
{á}{{\'{a}}}1
{é}{{\'{e}}}1
{í}{{\'{i}}}1
{ó}{{\'{o}}}1
{ú}{{\'{u}}}1
{ñ}{{\~{n}}}1
{Ñ}{{\~{N}}}1
}

\begin{document}

\begin{lstlisting}
á é í ó ú a e i o u
\end{lstlisting}

\begin{LTXexample}
á é í ó ú a e i o u
\end{LTXexample}

\end{document}


-
Since showexpl uses the listings package, this is a duplicate of Having problems with listings and UTF-8. Can it be fixed?. –  Alan Munn Jul 23 '14 at 14:54
@AlanMunn: not really. The accents disappear also in an ansinew encoded files. Also the example shows that in lstlisting itself the accents works. –  Ulrike Fischer Jul 23 '14 at 16:04
@UlrikeFischer reading too fast I guess. You're absolutely right. –  Alan Munn Jul 23 '14 at 16:17

showexpl has to write the code to a temporary file. It uses an internal command of listings for this. But accent doesn't survive if you use the literate option too. Put the code in some external file and then use

\LTXinputExample{test-code}

-
The problem with that solution is that breaks the idea of using showexpl. As I wanted to keep the code I'm showing within the same file, and without duplicity. In that case, I may just copy paste the code, but that solution is not maintainable. –  adn Jul 23 '14 at 18:54
Well you can use an enviroment like filcontents* from the filecontents package or VerbatimOut from fancyvrb to output the code on-the-fly. In many (but not all) cases this should work fine. If your file is utf8 encoded: check carefully the encoding of the output file. Writing utf8 is a bit tricky. See e.g. tex.stackexchange.com/questions/47462/…. You could also make a feature request for showexpl. –  Ulrike Fischer Jul 24 '14 at 8:02

Run xelatex and everything will be fine without using the literate option:

\documentclass{article}
\usepackage{fontspec}
\setmonofont[Scale=0.88]{DejaVu Sans Mono}
\usepackage{listings}
\usepackage{showexpl}
\begin{document}

\begin{lstlisting}
áéíóúaeiou
\end{lstlisting}

\begin{LTXexample}
áéíóúaeiou
\end{LTXexample}

\end{document}


-
+1: showexpl automatically loads listings. –  kiss my armpit Jul 23 '14 at 16:41