# How to use spanish accents?

I'm trying to add spanish accents to my document ( my Thesis )

\documentclass[11pt, spanish]{report}
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\begin{document}

Hola! Cómo estás ?

\end{document}


This piece of code doesn't seem to work on my Mac ( OS X Lion ), And I get:

Hola! Cmo ests?


in the pdf output.

Any ideas ?

-
When I compile it I get the accents. – N.N. Nov 4 '11 at 8:08
Same here, I seem to have no problem compiling this will accents. I'm on Lion too, TeXLive-2011. – qubyte Nov 4 '11 at 8:13
Check the log file for warnings. – Thorsten Donig Nov 4 '11 at 8:30
No problem with your code with MikTeX. Look at you .log file and may be will find some clue there. By the way, if you include spanish as option for documentclass, you don't need to include in babel. And if you just use one language, don't need \selectlanguage command. – Ignasi Nov 4 '11 at 8:34
Make sure that the source file is saved with the same encoding as you use for input (UTF-8 here). – Thorsten Donig Nov 4 '11 at 8:39

You could choose another way of input encoding by the selinput package from the oberdiek bundle. It chooses the right encoding by some glyphs from your language correspondingly to the encoding of the source file.

\documentclass[11pt,spanish]{article}
\usepackage[T1]{fontenc}
\usepackage{selinput}
\SelectInputMappings{%
aacute={á},
ntilde={ñ},
Euro={€}
}
\usepackage{babel}

\begin{document}
Hola! Cómo estás ?
\end{document}

-

Gando, I just compile this code with pdflatex in an iMac (Mountain Lion OS X):

\documentclass[11pt, spanish]{report}
\usepackage[spanish]{babel}
\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
\begin{document}

¡Hola! ¿Cómo estás ?

\end{document}


and got this output:

-
would you post a smaller image? Half of the page is white! :-s. So that nobody needs to scroll half page to come to the next answer. ;-) Thanks! By the way, cool answer! – loved.by.Jesus Oct 17 '15 at 18:13

Try this:

\documentclass[11pt, spanish]{report}

\usepackage[spanish]{babel}

\usepackage[latin1]{inputenc}

\begin{document}

Hola! Cómo estás ?

\end{document}


It should work with the additional package

-

You can also use escape codes for any accent you want to make. In general, it might be easier to fix the encoding once than have to escape every accented character, but for the occasional foreign name I use the table here http://en.wikibooks.org/wiki/LaTeX/Special_Characters.

Specifically, I would write:

!Hola!, ?c\'{o}mo est\'{a}s?


Do note, that with the letter i a dotless version needs to be used, as otherwise in addition to the accent, the regular i dot would be rendered.

S\'{\i}.


Note, to get the initial question mark and exclamation point, you type a backtick character immediately after.

-

For avoid that problem try this:

\documentclass[11pt]{report}
\usepackage[spanish]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\begin{document}

¡Hola! ¿Cómo estás?

\end{document}


If this doesn't compile right then perhaps the problem are not in the packages or the codification.

-