×
Clique aqui e veja a página ShareLaTeX em Inglês

[edit] ShareLaTeX guides

[edit] LaTeX Basics

[edit] Mathematics

[edit] Figures and tables

[edit] References and Citations

[edit] Languages

[edit] Document structure

[edit] Formatting

[edit] Fonts

[edit] Presentations

[edit] Commands

[edit] Field specific

[edit] Class files

LaTeX supports many worldwide languages by means of some special packages. In this article is explained how to import and use those packages to create documents in Portuguese.

Contents

[edit] Introduction

Portuguese language has some accentuated words. For this reason the preamble of your file must be modified accordingly to support these characters and some other features.

\documentclass{article}
 
%encoding
%--------------------------------------
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
%--------------------------------------
 
%Portuguese-specific commands
%--------------------------------------
\usepackage[portuguese]{babel}
%--------------------------------------
 
%Hyphenation rules
%--------------------------------------
\usepackage{hyphenat}
\hyphenation{mate-mática recu-perar}
%--------------------------------------
 
\begin{document}
 
\tableofcontents
 
\vspace{2cm} %Add a 2cm space
 
\begin{abstract}
Este é um breve resumo do conteúdo do documento escrito em Português.
\end{abstract}
 
\section{Seção introdutória}
Esta é a primeira seção, podemos acrescentar alguns elementos adicionais 
e tudo será escrito corretamente. Além disso, se uma palavra é um caminho 
muito longo e tem de ser truncado, babel irá tentar truncar corretamente, 
dependendo do idioma.
 
\section{Segunda seção}
Esta seção é para ver o que acontece com comandos de texto que definem
 
\[ \lim x =  \theta + 152383.52 \]
 
\end{document}

PortugueseEx1.png

There are two packages in this document related to the encoding and the special characters. These packages will be explained in the next sections.

If your are looking for instructions on how to use more than one language in a single document, for instance English and Portuguese, see the International language support article.

  Open an example of the babel package in ShareLaTeX

[edit] Input encoding

Modern computer systems allow you to input letters of national alphabets directly from the keyboard. In order to handle a variety of input encodings used for different groups of languages and/or on different computer platforms LaTeX employs the inputenc package to set up input encoding. In this case the package properly displays characters in the Portuguese alphabet. To use this package add the next line to the preamble of your document:

\usepackage[utf8]{inputenc}


The recommended input encoding is utf-8. You can use other encodings depending on your operating system.

  Open an example of the babel package in ShareLaTeX

[edit] Font encoding

To proper LaTeX document generation you must also choose a font encoding which has to support specific characters for Portuguese language, this is accomplished by the fontenc package:

\usepackage[T1]{fontenc}


Even though the default encoding works well in Portuguese, using this specific encoding will avoid glitches with some specific characters. The default LaTeX encoding is OT1.

  Open an example of the babel package in ShareLaTeX

[edit] Language-specific packages and commands

To extended the default LaTeX capabilities, for proper hyphenation and translating the names of the document elements, import the babel package for the Portuguese language.

\usepackage[portuguese]{babel}


As you may see in the example at the introduction, instead of "abstract" and "Contents" the Portuguese words "Resumo" and "Conteúdo" are used.

If you need to use the Brazilian Portuguese localization use brazilian instead of portuguese as parameter when importing babel.

  Open an example of the babel package in ShareLaTeX

[edit] Hyphenation

Sometimes for formatting reasons some words have to be broken up in syllables separated by a - (hyphen) to continue the word in a new line. For example, matemática could become mate-mática. The package babel, whose usage was described in the previous section, usually does a good job breaking up the words correctly, but if this is not the case you can use a couple of commands in your preamble.

 \usepackage{hyphenat}
 \hyphenation{mate-mática recu-perar}

The first command will import the package hyphenat and the second line is a list of space-separated words with defined hyphenation rules. On the other side, if you want a word not to be broken automatically, use the {\nobreak word} command within your document.

  Open an example of the babel package in ShareLaTeX

[edit] Further reading

For more information see