# Vowel Harmony and Reference Numbers

I am preparing a document in Turkish which is an agglutinative language with two dimensional vowel harmony. This means that there are a lot of suffixes and they change form depending on how the word they are attached to sounds. Automatic reference numbers are simply incompatible with this aspect of Turkish.

Here is a simple example. Suppose I want to say something like "According to theorem 3.1..." which translates to "Teorem 3.1'e göre..." in Turkish. The code to get this ouptut is obviously

Teorem \ref{theorem_tag}'e göre...


However If the numbering changes and, say, the number becomes 3.6 then the output becomes "Teorem 3.6'e göre..." which is false. It should be "Teorem 3.6'ya göre..." due to vowel harmony and some other mechanism.

Is it possible to implement a command \ref_suffix{theorem_tag}{'a} which outputs the correct form of the suffix? Vowel harmony, devoicing and other suffix changing rules are algorithmically very simple and there are no irregularities, at least in the case of numbers.

Edit: Following egreg's request, here are the rules of vowel harmony in Turkish. Notation: Let X and Y be sets of vowels. A rule of the form X -> Y means if the vowel of a syllable is from X then the vowel of the following syllable should be from Y. The rules are

{a,ı,o,u} -> {a,ı,o,u},

{a,e,ı,i} -> {a,e,ı,i},

{o,ö,u,ü} -> {a,e,u,ü}.

• Welcome to TeX.SX! Could you explain these rules? Commented Apr 29, 2014 at 8:51
• In essence, he wants something that is a very extensive version of like english single/plural. In english, you say 'one book' and 'two books', but of book is coming from a \command, then you get 'one books'. In the turkish, the idea is that the '6' is expecting a different lettering than the '1', he wants to put something to automatically create the right text for the number. Commented Apr 29, 2014 at 11:18
• I can't see how to adapt it to this case: I think this depends on the vowel of the numeral. Does it? And I can't see what rule provides 'ya. Commented Apr 29, 2014 at 20:06
• I think you need to add a reference for Turkish number names in your question... So the macro should 1. figure out the name of the last number of the ref (e.g. 3.11->11->on bir) 2. lookup what's the last vowel in its name (bir -> i) 3. produce the appropriate suffix (i->e-> 'e) Commented May 20, 2014 at 10:20

You can condition the form of the suffix on the value of the theorem counter using an if-then control structure, e.g. using the package ifthen. Here's a MWE:

\documentclass{article}

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

\usepackage{amsthm}
\usepackage{ifthen}

\newtheorem{theorem}{Teorem}

\newcommand{\harmony}[1]{%
\ifthenelse{\equal{\ref{#1}}{1}}{\ref{#1}'e}{}%
\ifthenelse{\equal{\ref{#1}}{6}}{\ref{#1}'ya}{}%
}

\begin{document}

Teorem \harmony{thm} göre, so-and-so. Teorem \harmony{thm'} göre, this-and-that.

\begin{theorem}\label{thm}
Lorem ipsum
\end{theorem}

\setcounter{theorem}{5}

\begin{theorem}\label{thm'}
Lorem ipsum
\end{theorem}

\end{document}


Obviously, this is only feasible if you can set a reasonably low upper bound on the total number of your theorems (in which case the solution is not really general/productive) or if the Turkish number system is very systematic vis-á-vis vowel harmony (unfortunately, I know no Turkish). In principle, the ifthen package allows for more complex comparisons in the conditional antecedent than the equal macro I've used here.

• Thank you for the answer. However this approach is not really feasible as there are many suffixes and many numbers --I'd like to implement this up to 1000. I need a way to process the counter as a string and modify the suffix accordingly. Later I found that the packages refcount, etoolbox and xstring have everything I need. Commented May 20, 2014 at 11:46
• I see. If you manage to come up with a general solution, do post it! I suppose this (or something similar) will be an issue also in some other languages with complex morphology. Commented May 20, 2014 at 12:09