3

I am typesetting (lualatex) a document in a couple of languages. The main language is English. If I use other languages I usually use commands such as \foreigntextquote{french}{text} and \foreignlanguage{german}{text}, hoping that this sorts out a couple of things and in particular hyphenation. I could also manage, with some help, the hyphenation of Ancient Greek (polutonikogreek).

My main issue now is that some languages that are not written in the Latin alphabet are sometimes used in transliteration. For example in Arabic, I would sometimes (usually in the main body of the text) write, yaštariku instead of يشترك or al-mutaʿallim instead of المتعلّم.

But, how can I manage to get these transliterations hyphenated?

They are not a "known" language (at least not in transliteration). I do not know whether there are established rules, and I assume that even if there are that they have not been integrated into babel. Sometimes the words even have a dash by themselves (due to the article al-), which is a known problem (but there are also some solutions).

But generally, my questions is this: Since I cannot declare in my preamble all words I will use in transliteration (the command \hyphenation{...} would be too lang; this would just be insane), I would like to know if there is a way to perhaps randomly hyphenate those words which babel does not know how to hyphenate or an easy way to create a new hyphenation language and declare its rules? Or is there any other recommendation how to hyphenate all these transliterated words?

Without a solution, my document has a number of words that are written into the margins or lines whose inter-word space is too large.

This should actually be a pressing problem for typesetting in all humanities, for publishers tend to use transliteration in their publications. I don't know how the publishers handle that.

  • 1
    Since you are using luatex, I presume you can define a function to insert discretionaries with the help of some regexps. Also, with luatex it should be possible to create a new language with their corresponding patterns. Sorry for not being more specific - I think in a couple of week I could work those ideas out. – Javier Bezos Apr 26 '15 at 19:13
  • @JavierBezos : I will see if I can do something along the lines you suggested. If there is anything I can help you with in "working those ideas out" please let me know. – ClintEastwood Apr 27 '15 at 6:20
2

Here is rather crude solution, which just inserts a \- between a vowel and some consonants:

\documentclass{article}

\usepackage{luacode}

\begin{luacode*}
function insdisc (s)
    -- add more letters if necessary
  s = s:gsub( [[([aeiou])([bcfgklmnpqtxz])]] , '%1\\-%2' )
    -- but don't leave a single char alone:
  s = s:gsub( '^(.)\\%-', '%1')
  s = s:gsub( '\\%-(.)$', '%1')
  return s
end
\end{luacode*}

\def\insdisc#1{\directlua{tex.print(insdisc(\luastring{#1}))}}

\begin{document}

\hsize1mm

Text \insdisc{umiq'utzexopab} umiq'utzexopab text text text text text
text text text text text text text text text text text text.

\end{document}
  • wow! what you call "crude" I'd call "simple" or even "elegant". At first, I had problems with ellipsis package, but this just led me to no longer use it. – ClintEastwood May 6 '15 at 10:26
  • I just had the issue that \insdisc tried to hyphenate other LaTeX commands, e.g., in \insdisc{blabla \texquote{abcdefg} blabla} it tried to hyphenate \textquote which, of course, resulted in an error message. Any way to keep that from happening? – ClintEastwood May 18 '15 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.