# Is there any way to create extensions for latex

I wonder whether or not there is a platform to create extensions for latex. ANd if there is, here is the extension I want: My main language is turkish. And turkish is agglutinative language. For instance when american says "As you can see in figure 2.5 bla bla", we say "Figure 2.5'te" means "in figure 2.5" and this "te" changes according to the statement before it. Examples: 1'de, 2'de 3'te, 4'te ... 9'da... so total number of adding is 4 => "te/ta/de/da"..

Now my extension should do this:

\myExtension{\ref{fig:myFigure}} (I am making up this syntax for now)
function myExtension{
take the last number of the figure label (lastNumber)
if (lastNumber == 1) then myAddition="de";
.
.
if (lastNumber == 9) then myAddition="da";
}


Is there any platform that I can do it? Thanks in advance.

• Welcome to TeX.SX! Does tex.stackexchange.com/questions/98330/… help? – egreg Dec 11 '14 at 13:59
• @egreg thanks a lot! but where I am suppose to copy this code in latex? I am a programmer but I use latex only for my paper, so I am not familiar with it:) ? thanks... – WhoCares Dec 11 '14 at 14:04
• Copy from \usepackage{xparse} to \ExplSyntaxOff in your document, before \begin{document}, if you're using my answer. Similarly for the other ones. – egreg Dec 11 '14 at 14:07
• thanks. I can compile it with no error. But, I type \turkishref instead of \ref then gives me error. What I am doing wrong? B.T.W, my paper's latex scheme has more than one .tex files and I just compile the file that includes \begin{document} one. Other files (I suppose) are included to in it. – WhoCares Dec 11 '14 at 14:21
• You might like to spend a little time reading the Wikibook Latex guide. Checkout the introduction for the basic structure and the macros chapter for how to define extensions. – Thruston Dec 11 '14 at 15:25

\def\myref#1{\ref{#1}%