martes, 7 de febrero de 2012

Acentos en español en LaTeX en Ubuntu y Windows

Resumen:


Instala latex-ucs (sudo apt-get install latex-ucs) ésto te permitirá usar eñes y tildes (o cualquier carácter UTF8).

\usepackage[spanish]{babel} % Division de sílabas y títulos en español.
\usepackage[utf8]{inputenc} % Para poner acentos y eñes directamente.
\usepackage{ucs} % Altenativamente al anterior.
\usepackage{amsmath} % La American Mathematical Society creó este paquete de "Higher Mathematics".



Text encoding

Most of the modern computer systems allow you to input letters of national alphabets directly from the keyboard. In order to handle variety of input encoding used for different groups of languages and/or on different computer platforms LaTeX employs the inputenc package:
\usepackage[encoding]{inputenc}
inputenc package tells LaTeX what the text encoding format of your .tex files is. The encoding depends on your operating system but often a software's encoding can be changed from the settings (this happens at least with some editors, the PuTTY terminal and TeXmaker). You may choose whichever encoding you like, but you must say so in the preamble, so for example, if you prefer to use the ISO-8859-1, write
\usepackage[latin1]{inputenc}

Most modern operating systems use Unicode (utf-8) as a default encoding for text. On such system (for example Ubuntu) you can use:
\usepackage[utf8]{inputenc}

The supported encoding by the LaTeX team is utf8 and covers a fairly specific/limited range of unicode input characters. It only defines those symbols that are known to be available with the current font encodingutf8x is not officially supported, but covers a much broader range of input symbols.
You might encounter a situation where using \usepackage[utf8]{inputenc} might result in error:
! Package inputenc Error: Unicode char \u8:ũ not set up for use with LaTeX.
This is due to the utf8 definition not necessarily having a mapping of all the character glyphs you are able to enter on your keyboard. Such characters are for example ŷ Ŷ ũ Ũ ẽ Ẽ ĩ Ĩ. In such case, you need to use the utf8x option to define more character combinations. This might break up compatibility with some packages like csquotes.
When using the inputenc package, you should consider that other people might not be able to display your input files on their computer, because they use a different encoding. For example, the German umlaut ä on OS/2 is encoded as 132, on Unix systems using ISO-LATIN 1 it is encoded as 228, while in Cyrillic encoding cp1251 for Windows this letter does not exist at all; therefore you should use this feature with care. The following encodings may come in handy, depending on the type of system you are working on:
Operating systemEncodings
Western LatinCyrillic
Macapplemacmaccyr
Unixlatin1koi8-ru
Windowsansinewcp1251
DOS, OS/2cp850cp866nav

2 comentarios:

  1. Hola!, googleando encontré este blog.

    Tengo un problema al escribir los acentos en Latex, ya he intentado agregar los paquetes [latin1] con ISO8859-1 ó [utf8] con UTF-8. El problema es que al escribir el 2° acento, este queda como "comillas" por lo que tengo que reabrir el programa (Uso el Texmaker en Ubuntu 11.10).

    ResponderEliminar