9

Possible Duplicate:
Check all hyphenations within a document

I'm having problems with hyphenation patterns in babel's spanish. I'm using MikTeX on Windows and it seems very difficult to solve this problem, at least with my current MikTeX configuration. So, it would be extremely helpful if LaTeX tells me "hey, I've just finished and these are the words I hyphenated, look if they are wrong" when it finish building the document.

Is there a way to accomplish this?

Paulo Bu
  • 191
  • Welcome to TeX.sx! Your answer was migrated here from [so]. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or edit your answer. Regarding your question, are you getting wrong hyphenations? – egreg May 31 '12 at 16:08
  • Thanks, I already registered here. About the question, I'm indeed getting wrong hyphenations, not according with Spanish rules. – Paulo Bu May 31 '12 at 16:27
  • Please, show a minimal example. Are you loading \usepackage[spanish]{babel}? – egreg May 31 '12 at 16:32
  • Yes, I am loading that package in that way and so far I've researched and this is the proper action to take, the problem is with MikTex engine. I've currently give up to solve it the right way, that's why I'm trying to figure out which are the words MikTex is hyphenating to see which of them are wrong and fix them manually. – Paulo Bu May 31 '12 at 16:36
  • You probably are running MiKTeX with version 2.8 (or less), which didn't enable many languages. While it's possible to enable Spanish hyphenation, the best is to update to version 2.9 that will do it by default. – egreg May 31 '12 at 16:40
  • You may use the answer in the question

    Check all hyphenations within a document!

    – TeXtnik May 31 '12 at 16:42
  • You're right, I've just checked and realized I'm using MikTex Revision 2.7. I won't be able to update to version 2.9 right now, I've checked and there are the files spanish.sty and spanish.ldf which are the files that handles hyphenation (I think). Is there a way to include them manually with commands on the .tex file? Thank you very much for helping me with this (kind of obscure) problem :) – Paulo Bu May 31 '12 at 16:48
  • 1
    You have to enable Spanish hyphenation from the MiKTeX control panel. Sorry, but I'm no MiKTeX user; maybe others can help better. – egreg May 31 '12 at 16:54
  • @zunbeltz that question looks exactly like mine. Thank you very much. – Paulo Bu May 31 '12 at 16:55
  • @PauloBu The right way to solve your problem is not to do hyphenation by hand after checking all hyphens, but to enable Spanish rules to begin with. With your present setting you get Spanish hyphenated with American English rules. – egreg May 31 '12 at 23:13

2 Answers2

8

If you add

\tracingparagraphs1

to your document the Tex dumps all kinds of information about its line breaking, including where it used hyphenation.

\documentclass{article}

\textwidth0.3\textwidth

\tracingparagraphs1

\begin{document}
aascac alskcj a awfd acdcnaskca kajhdacnaks kajhd kdcks  jksdh skjd ksj 
aaonescac alskcj a awfd acdtwocnaskca kajhdacnaks kajhd kdcks  jksdh skjd ksj 
aascac alskcj a awfd acdcnaskca kajhdacnaks kajhd kdcks  jksdh skjd ksj 
aascac alskcj a awfd acdcnaskca kajhdacnaks kajhd kdcks  jksdh skjd ksj 

\end{document}

In the log you will see:

awfd acd-c-naskca ka-jh-dac-
@\discretionary via @@10 b=* p=50 d=*
@@11: line 11.3- t=13444 -> @@10
naks ka-jhd kd-cks jksdh

which means a line broke as kajhdac-naks with other hyphens being considered.

That test file has three hyphens as you can see from searching the log fiel with (for example)

egrep -C1 "^@.discretionary" hyph.log

which produces

acdt-woc-naskca ka-jh-dac-
@\discretionary via @@4 b=* p=50 d=*
@@5: line 5.3- t=12330 -> @@4
--
awfd acd-c-naskca ka-jh-dac-
@\discretionary via @@7 b=* p=50 d=*
@@8: line 8.3- t=12887 -> @@7
--
awfd acd-c-naskca ka-jh-dac-
@\discretionary via @@10 b=* p=50 d=*
@@11: line 11.3- t=13444 -> @@10
David Carlisle
  • 757,742
  • But that does give you all attempts TeX made while finding the optimal solution but not only those that actually appear in the document in the end. For that you would to traverse the path back on each paragraph ... well TeX is turing complete, so ... :-) – Frank Mittelbach May 31 '12 at 18:48
  • Ah yes, I could never read that output:-) For the purposes it may be good enough, especially if no one posts anything better... (Although it may be that the OP just hadn't got the right hyphenation tables in the format) – David Carlisle May 31 '12 at 19:29
4

The releases of MiKTeX prior to 2.9 enabled by default only a small number of hyphenation rules: English, German (old and new orthography) and French.

Enabling hyphenation rules is different from choosing the languages for a document: the simple

\usepackage[spanish]{babel}

doesn't guarantee that correct hyphenation will be performed, unless the language was enabled beforehand and formats have been rebuilt. In the case the language is not enabled, you get the following message in the .log file written during the LaTeX run

No hyphenation patterns were loaded for the language `Spanish'
I will use the patterns loaded for \language=0 instead

The instruction for enabling languages can be found at the following link

http://docs.miktex.org/2.7/manual/hyphenation.html

enter image description here

After checking the desired languages (spanish, in your case, but also all the others that you need), press "Apply" and then go to the "General" panel

enter image description here

Press the "Update Formats" button. If all's well, a LaTeX run on your document should not present the message any more and the correct Spanish hyphenation will be used.

egreg
  • 1,121,712