2

I have a file mylanguage.tex that contains hyphenation patterns for mylanguage:

\newlanguage\mylanguage
\begingroup
\language\mylanguage
\patterns{
1b
}
\endgroup

And a test file foo.tex:

\documentclass{article}

\language=\mylanguage
\usepackage{testhyphens}

\begin{document}
\begin{checkhyphens}{}
foobar
\end{checkhyphens}
\end{document}

I expect the word foobar in foo.tex to be tokenized as foo-bar.

To compile everything, I do this:

xelatex -jobname=mylanguage -ini "&xelatex mylanguage\dump"
xelatex -fmt mylanguage foo

However, the first command outputs this error message:

Too late for \patterns.

The corresponding help message says:

All patterns must be given before typesetting begins.

I tried to ignore the error message and proceed, and indeed manage to output a PDF at the end, but my custom hyphenation pattern are ignored and I get foobar without hyphens in the output.

What am I doing wrong?

1
  • Thank you very much for this question. I used the solution here and it worked. However when I use babel (because titles for my language is already exists in babel) it does not work. Do you have any idea with this? Commented Jan 2, 2022 at 10:45

1 Answer 1

2

You can input the xelatex.ini source rather than recycling the format.

Change your mylanguage.tex to

\let\DUMP\dump
\let\dump\relax
\input xelatex.ini
\newlanguage\mylanguage
\begingroup
\language\mylanguage
\patterns{
1b
}
\endgroup
\let\dump\DUMP
\let\DUMP\undefined
\dump

then a commandline of

xelatex -etex -ini  mylanguage

shows your new language as 85:

...
Hyphenation trie of length 437140 has 9487 ops out of 35111
  1 for language 85
  143 for language 84

...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .