6

Hyphenation of words with accents doesn't work. I'm writing my document in Portuguese so I have accents like '`~^ for some words but these words are not hyphenated. How do I solve this?

THIS WAS SOLVED BY: (1) updating my texlive installation. (2) adding the lines

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

to my document. Actually the last line is not necessary but the text font would be too ugly without it.

David
  • 327
  • 1
    Do you have \usepackage[portuguese]{babel} in your preamble? – jub0bs Aug 09 '14 at 14:31
  • 5
    And you'll want to be using \usepackage[T1]{fontenc} to allow hyphenation - see here and here. – greyshade Aug 09 '14 at 14:32
  • Both doesn't work. Does it have anything to do with the fact that I'm writing my chapters in separated files? I mean: \chapter{Mecânica Elementar} \input{mecanica_elementar} – David Aug 09 '14 at 14:35
  • 2
    no, splitting things into files with input should not make any difference. did you read the links and made sure none of the answers there help? if so, can you give a MWE for your specific case so we can test? – greyshade Aug 09 '14 at 14:40
  • i posted my document. – David Aug 09 '14 at 14:42
  • 2
    If you don't post also cenas we can't test many things… Just a lead: add \usepackage{lmodern}, for instance. – Bernard Aug 09 '14 at 14:48
  • it's only text like "adiabática" nothing more. But this word is not hyphenated, all the other are. – David Aug 09 '14 at 14:53
  • 1
    @David There must be something you're not telling us, because the word "adiabática" gets hyphenated as expected in the following MWE: \documentclass[10pt,a4paper]{book} \usepackage[utf8]{inputenc} \usepackage[T1]{fontenc} \usepackage[portuguese]{babel} \begin{document} adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática adiabática \end{document} – jub0bs Aug 09 '14 at 14:56
  • maybe i dont have this package \usepackage[portuguese]{babel} How do i install this? – David Aug 09 '14 at 15:09
  • @David The babel package should already be installed. Have you tried compiling the MWE in my previous comment? If you get no compilation error, then babel is already installed. – jub0bs Aug 09 '14 at 15:13
  • it gives me the error ! Font T1/cmr/m/n/10=ecrm1000 at 10.0pt not loadable: Metric (TFM) file not fou nd. – David Aug 09 '14 at 15:41

1 Answers1

2

(too long for a comment, hence posted as an answer)

The inability of TeX (and LaTeX, etc) to hyphenate words with accents -- if the accented words were constructed using accenting primitives and if the font encoding is the "original" or "old" TeX encoding -- has been known for a long time.

What to do? You should (a) if at all possible input the accented words directly, e.g., as adiabática, (b) use any font encoding other than OT1 (which, as you can probably guess, is the original font encoding method), and (c) load the babel or polyglossia packages with the appropriate language choices.

The MWE below was compiled using LuaLaTeX; if compiled under pdfLaTeX the first word would not get hyphenated. (That's a different shortcoming...)

enter image description here

\documentclass[a4paper]{article}
\usepackage{ifluatex}
\ifluatex
  \usepackage{fontspec}
\else
  \usepackage[utf8]{inputenc}
  \usepackage[T1]{fontenc}
\fi
\usepackage[portuguese]{babel}
\setlength\textwidth{1mm} % to force the use of every possible hyphenation point

\begin{document}
\noindent
adiabática adiabática
\end{document}
Mico
  • 506,678
  • thanks. this gives me the error ! Font T1/cmr/m/n/10=ecrm1000 at 10.0pt not loadable: Metric (TFM) file not fou nd. – David Aug 09 '14 at 15:43
  • @David - What exactly gives rise to the error you report? It can't be either my MWE -- its output is shown above, and it compiles without error -- or the code you've posted (with the instruction \input{cenas} commented out, since I don't have that file, and with a right curly brace, }, inserted after {autor). I suggest you post a new query with an actual MWE that gives rise to the font-related problem you're encountering. – Mico Aug 09 '14 at 15:50
  • it was strictly your your code in a blank tex file. – David Aug 09 '14 at 15:56
  • @David -- What's your TeX distribution (TeXLive?, MikTeX? something else?) and vintage? Do you use pdfLaTeX or the (by now very old and obsolete) version of LaTeX that can generate only dvi files? – Mico Aug 09 '14 at 16:14
  • I dont know. I installed texmaker in ubuntu with apt-get. and i use pdflatex – David Aug 09 '14 at 16:57
  • @David - I don't know ubuntu, but it looks like your installation of TeXLive didn't complete correctly; at the very least, some font-related files are missing. – Mico Aug 09 '14 at 18:10
  • I just updated my textlive installation. Now it says: ! Package babel Error: Unknown option `portuguese'. Either you misspelled it – David Aug 09 '14 at 18:23
  • @David - Sorry to hear that your travails continue. The spelling portuguese should most certainly be recognized as a package option. – Mico Aug 09 '14 at 18:26
  • Now that i pdated my textlive version, adding the line \usepackage[T1]{fontenc} worked for me without the need to use \usepackage[portuguese]{babel}. Thanks to all for your help. Why do I have such an ugly font now? Is there anyway I can change that? – David Aug 09 '14 at 18:43
  • about my last question: That is also solved already: i just add the line: \usepackage{lmodern}. Thank you all – David Aug 09 '14 at 18:50