# How to display accents inside verbatim command

I have the following piece of code:

\newenvironment{mylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}

\newenvironment{mytinylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\tiny\bfseries}
{\end{list}}

\begin{mylisting}
\begin{verbatim}
I want to display an accent in this text (i.e. más)
\end{verbatim}
\end{mylisting}


The word "más" should be displayed with accent but I got:
m'as

The verbatim environment is ignoring the accent.

BTW According to my config, the accent is displayed just using ' before the letter.

Anyone knows how to solve this issue?

-
Please add a suitable preamble, in order to make the example compilable. –  egreg Feb 12 '12 at 17:36
Maybe have a look at the alltt package -- it provides environment alltt that is supposed to behave exactly like verbatim, but it escapes all <backslash> and {...}. That way, you could surely write \'{a} to get the symbol, since alltt will expand the command \'. –  tohecz Feb 12 '12 at 19:53

The semantics of the verbatim environment is that it displays your input verbatim (i.e., without any processing). So even if you have a setup, for example babel, where it is possible to enter accents using abbreviations such as 'a such shortcuts are disabled within verbatim.

Thus, if you do require input processing and you only selected verbatim to get a typewriter font, then the obvious solution is to simply choose such a font directly in your definition, e.g., via {\ttfamily ...} or \texttt{...}. If on the other hand you are looking for some environment that obeys spacing alltt may help. It might be that shortcuts do not work but normal commands are executed so \'a will generate the correct glyph.

-

If one loads the package inputenc with the proper option for the encoding of the file, then verbatim text will be printed correctly even with accented letters

If the file is UTF-8 encoded, then

\documentclass{article}
\usepackage[T1]{fontenc} % recommended for languages with accents
\usepackage[utf8]{inputenc}

\begin{document}
\begin{verbatim}
más mañana
\end{verbatim}


will be printed correctly. Of course the input encoding depends on the operating system, but mostly on the editor settings. Check yours: you might need latin1 instead of utf8.

-