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";
   return label+"'"+myAddition

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

I have seen at Changing the suffix according to the figure number but it seems to me that there is useless complicatedness here. Maybe, the following six lines are sufficient:

   \expandafter\ifx\csname r@#1\endcsname\relax \else
   \expandafter\expandafter\expandafter\myrefA\csname r@#1\endcsname \fi
\def\myrefB#1#2{\def\tmp{#1}\ifx\relax#2\myrefC \else\expandafter\myrefB\expandafter#2\fi}
\def\myrefC{'\ifcase\tmp\space da\or de\or de\or te\or te\or te\or te\or te\or te\or da\fi}
| improve this answer | |

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.