I have the following piece of code:



    I want to display an accent in this text (i.e. más)    

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

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 \'. – yo' 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.

| improve this answer | |

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

\usepackage[T1]{fontenc} % recommended for languages with accents

más mañana

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.

| improve this answer | |

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.