2

I am preparing Turkish lecture notes. We say "(1)'den" (\eqref{eqn1}'den) for "From (1)" (From \eqref{eqn1}), and the suffix depends on the equation number. I want to define a new command \eqrefden for such references with a suffix and the suffixes are set in the following form:

  • "(1)'den", "(2)'den", "(3)'ten", "(4)'ten", "(5)'ten", "(6)'dan", "(7)'den", "(8)'den", "(9)'dan", "(10)'dan"
  • from (*1)--(*9) it is defined as (1)--(9)
  • "(20)'den", "(30)'dan", "(40)'tan", "(50)'den", "(60)'tan", "(70)'ten", "(80)'den", "(90)'dan"
  • Finally, "(100)'den"

I am doing this maunually. But when I need to add an equation somewhere, I change all of them again. If I can get the idea from \eqref, I can use it for \ref and \subref, and for other possible suffixes.

Thank you very much. bkarpuz

Edit. Thanks to the solution by egref

enter image description here

I am giving below a complete package and a MWE.

MWE

\documentclass{article}

\usepackage{amsmath}
\usepackage{tr-suffix}

\begin{document}

\section*{\#'da, \#'nun, \#'yu, \#'ya}

\begin{itemize}
\item \eqrefnoda{eqn1}, \eqrefnoda{eqn2}, \eqrefnoda{eqn3}, \eqrefnoda{eqn4}, \eqrefnoda{eqn5}, \eqrefnoda{eqn6}, \eqrefnoda{eqn7}, \eqrefnoda{eqn8}, \eqrefnoda{eqn9}, \eqrefnoda{eqn10}, \eqrefnoda{eqn15}, \eqrefnoda{eqn20}, \eqrefnoda{eqn30}, \eqrefnoda{eqn40}, \eqrefnoda{eqn50}, \eqrefnoda{eqn60}, \eqrefnoda{eqn70}, \eqrefnoda{eqn80}, \eqrefnoda{eqn90}, \eqrefnoda{eqn100}, \eqrefnoda{eqn100}, \eqrefnoda{eqn1000}.
\item \eqrefnonun{eqn1}, \eqrefnonun{eqn2}, \eqrefnonun{eqn3}, \eqrefnonun{eqn4}, \eqrefnonun{eqn5}, \eqrefnonun{eqn6}, \eqrefnonun{eqn7}, \eqrefnonun{eqn8}, \eqrefnonun{eqn9}, \eqrefnonun{eqn10}, \eqrefnonun{eqn15}, \eqrefnonun{eqn20}, \eqrefnonun{eqn30}, \eqrefnonun{eqn40}, \eqrefnonun{eqn50}, \eqrefnonun{eqn60}, \eqrefnonun{eqn70}, \eqrefnonun{eqn80}, \eqrefnonun{eqn90}, \eqrefnonun{eqn100}, \eqrefnonun{eqn100}, \eqrefnonun{eqn1000}.
\item \eqrefnoyu{eqn1}, \eqrefnoyu{eqn2}, \eqrefnoyu{eqn3}, \eqrefnoyu{eqn4}, \eqrefnoyu{eqn5}, \eqrefnoyu{eqn6}, \eqrefnoyu{eqn7}, \eqrefnoyu{eqn8}, \eqrefnoyu{eqn9}, \eqrefnoyu{eqn10}, \eqrefnoyu{eqn15}, \eqrefnoyu{eqn20}, \eqrefnoyu{eqn30}, \eqrefnoyu{eqn40}, \eqrefnoyu{eqn50}, \eqrefnoyu{eqn60}, \eqrefnoyu{eqn70}, \eqrefnoyu{eqn80}, \eqrefnoyu{eqn90}, \eqrefnoyu{eqn100}, \eqrefnoyu{eqn100}, \eqrefnoyu{eqn1000}.
\item \eqrefnoya{eqn1}, \eqrefnoya{eqn2}, \eqrefnoya{eqn3}, \eqrefnoya{eqn4}, \eqrefnoya{eqn5}, \eqrefnoya{eqn6}, \eqrefnoya{eqn7}, \eqrefnoya{eqn8}, \eqrefnoya{eqn9}, \eqrefnoya{eqn10}, \eqrefnoya{eqn15}, \eqrefnoya{eqn20}, \eqrefnoya{eqn30}, \eqrefnoya{eqn40}, \eqrefnoya{eqn50}, \eqrefnoya{eqn60}, \eqrefnoya{eqn70}, \eqrefnoya{eqn80}, \eqrefnoya{eqn90}, \eqrefnoya{eqn100}, \eqrefnoya{eqn100}, \eqrefnoya{eqn1000}.
\end{itemize}


\begin{align}
\ast\label{eqn1}\\
\ast\label{eqn2}\\
\ast\label{eqn3}\\
\ast\label{eqn4}\\
\ast\label{eqn5}\\
\ast\label{eqn6}\\
\ast\label{eqn7}\\
\ast\label{eqn8}\\
\ast\label{eqn9}\\
\ast\label{eqn10}\\
\setcounter{equation}{14}\ast\label{eqn15}\\
\setcounter{equation}{19}\ast\label{eqn20}\\
\setcounter{equation}{29}\ast\label{eqn30}\\
\setcounter{equation}{39}\ast\label{eqn40}\\
\setcounter{equation}{49}\ast\label{eqn50}\\
\setcounter{equation}{59}\ast\label{eqn60}\\
\setcounter{equation}{69}\ast\label{eqn70}\\
\setcounter{equation}{79}\ast\label{eqn80}\\
\setcounter{equation}{89}\ast\label{eqn90}\\
\setcounter{equation}{99}\ast\label{eqn100}\\
\setcounter{equation}{999}\ast\label{eqn1000}
\end{align}

\end{document} 

tr-suffix.sty

%tr-suffix.sty
\RequirePackage{expl3,xparse}
\ProvidesExplPackage{tr-suffix}{2014/12/11}{0.1}{Turkish suffix for ref}

\@ifpackagelater { expl3 } { 2012/11/21 }
 { }
 {
  \PackageError { tr-suffix } { Support~package~expl3~too~old }
   {
    You~need~to~update~your~installation~of~the~bundles~'l3kernel'~and~
    'l3packages'.\MessageBreak
    Loading~tr-suffix~will~abort!
   }
  \tex_endinput:D
 }

\RequirePackage{refcount}

%%%\ref
\NewDocumentCommand{\refnoyu}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \tr_suffix_yu_get:n { #2 }
 }
\NewDocumentCommand{\refnoya}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \tr_suffix_ya_get:n { #2 }
 }
\NewDocumentCommand{\refnoda}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \tr_suffix_da_get:n { #2 }
 }
\NewDocumentCommand{\refnonun}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \tr_suffix_nun_get:n { #2 }
 }

%%%\eqref
\NewDocumentCommand{\eqrefnoyu}{m}
 {
  \eqref{#1}\tr_suffix_yu_get:n { #1 }
 }
\NewDocumentCommand{\eqrefnoya}{m}
 {
  \eqref{#1}\tr_suffix_ya_get:n { #1 }
 }
\NewDocumentCommand{\eqrefnoda}{m}
 {
  \eqref{#1}\tr_suffix_da_get:n { #1 }
 }
\NewDocumentCommand{\eqrefnonun}{m}
 {
  \eqref{#1}\tr_suffix_nun_get:n { #1 }
 }


%%%TR_Suffix_No'da
\seq_new:N \l__tr_suffix_da_seq
\tl_new:N \l__tr_suffix_da_tl
\cs_new_protected:Npn \tr_suffix_da_get:n #1
 {
  \seq_set_split:Nnx \l__tr_suffix_da_seq { . } { \getrefnumber { #1 } }
  \seq_pop_right:NN \l__tr_suffix_da_seq \l__tr_suffix_da_tl
  \tr_suffix_da:V \l__tr_suffix_da_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\NewDocumentCommand{\trsuffda}{m}
 {
  \tr_suffix_da:n { #1 }
 }

\cs_new:Npn \tr_suffix_da:n #1
 {
  \int_compare:nTF { #1 == 0 } { 'da } { \tr_suffix_da_nonzero:n { #1 } }
 }
\cs_new:Npn \tr_suffix_da_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'de}
    {2}{'de}
    {3}{'te}
    {4}{'te}
    {5}{'te}
    {6}{'da}
    {7}{'de}
    {8}{'de}
    {9}{'da}
    {10}{'da}
    {20}{'de}
    {30}{'da}
    {40}{'ta}
    {50}{'de}
    {60}{'da}
    {70}{'te}
    {80}{'de}
    {90}{'da}
    {100}{'de}
    {1000}{'de}
   }
   {
    \tr_suffix_da_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \tr_suffix_da:n { V }

\cs_new:Npn \tr_suffix_da_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \tr_suffix_da_complex_ten:n { #1 } }
   { \tr_suffix_da_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }
\cs_new:Npn \tr_suffix_da_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \tr_suffix_da_complex_hundred:n { #1 } }
   { \tr_suffix_da_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \tr_suffix_da_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \tr_suffix_da_complex_thousand:n { #1 } }
   { 'de }%{ \tr_suffix_da_nonzero:n { \int_mod:nn { #1 } { 1000 } } }
 }
\cs_new:Npn \tr_suffix_da_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \tr_suffix_da_complex_tenthousand:n { #1 } }
   { 'de }%{ \tr_suffix_da_nonzero:n { \int_mod:nn { #1 } { 10000 } } }
 }
\cs_new:Npn \tr_suffix_da_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \tr_suffix_da_complex_hundredthousand:n { #1 } }
   { 'de }%{ \tr_suffix_da_nonzero:n { \int_mod:nn { #1 } { 100000 } } }
 }
\cs_new:Npn \tr_suffix_da_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \tr_suffix_da_complex_million:n { #1 } }
   { 'da }%{ \tr_suffix_da_nonzero:n { \int_mod:nn { #1 } { 1000000 } } }
 }

%%%TR_Suffix_No'nun
\seq_new:N \l__tr_suffix_nun_seq
\tl_new:N \l__tr_suffix_nun_tl
\cs_new_protected:Npn \tr_suffix_nun_get:n #1
 {
  \seq_set_split:Nnx \l__tr_suffix_nun_seq { . } { \getrefnumber { #1 } }
  \seq_pop_right:NN \l__tr_suffix_nun_seq \l__tr_suffix_nun_tl
  \tr_suffix_nun:V \l__tr_suffix_nun_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\NewDocumentCommand{\trsuffnun}{m}
 {
  \tr_suffix_nun:n { #1 }
 }

\cs_new:Npn \tr_suffix_nun:n #1
 {
  \int_compare:nTF { #1 == 0 } { '{\i}n } { \tr_suffix_nun_nonzero:n { #1 } }
 }
\cs_new:Npn \tr_suffix_nun_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'in}
    {2}{'nin}
    {3}{'\"{u}n}
    {4}{'\"{u}n}
    {5}{'in}
    {6}{'n{\i}n}
    {7}{'nin}
    {8}{'in}
    {9}{'un}
    {10}{'un}
    {20}{'nin}
    {30}{'un}
    {40}{'{\i}n}
    {50}{'nin}
    {60}{'{\i}n}
    {70}{'in}
    {80}{'nin}
    {90}{'n{\i}}
    {100}{'\"{u}n}
    {1000}{'in}
   }
   {
    \tr_suffix_nun_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \tr_suffix_nun:n { V }

\cs_new:Npn \tr_suffix_nun_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \tr_suffix_nun_complex_ten:n { #1 } }
   { \tr_suffix_nun_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }
\cs_new:Npn \tr_suffix_nun_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \tr_suffix_nun_complex_hundred:n { #1 } }
   { \tr_suffix_nun_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \tr_suffix_nun_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \tr_suffix_nun_complex_thousand:n { #1 } }
   { 'in }%{ \tr_suffix_nun_nonzero:n { \int_mod:nn { #1 } { 1000 } } }
 }
\cs_new:Npn \tr_suffix_nun_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \tr_suffix_nun_complex_tenthousand:n { #1 } }
   { 'nin }%{ \tr_suffix_nun_nonzero:n { \int_mod:nn { #1 } { 10000 } } }
 }
\cs_new:Npn \tr_suffix_nun_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \tr_suffix_nun_complex_hundredthousand:n { #1 } }
   { 'nin }%{ \tr_suffix_nun_nonzero:n { \int_mod:nn { #1 } { 100000 } } }
 }
\cs_new:Npn \tr_suffix_nun_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \tr_suffix_nun_complex_million:n { #1 } }
   { 'nun }%{ \tr_suffix_nun_nonzero:n { \int_mod:nn { #1 } { 1000000 } } }
 }

%%%TR_Suffix_No'yu
\seq_new:N \l__tr_suffix_yu_seq
\tl_new:N \l__tr_suffix_yu_tl
\cs_new_protected:Npn \tr_suffix_yu_get:n #1
 {
  \seq_set_split:Nnx \l__tr_suffix_yu_seq { . } { \getrefnumber { #1 } }
  \seq_pop_right:NN \l__tr_suffix_yu_seq \l__tr_suffix_yu_tl
  \tr_suffix_yu:V \l__tr_suffix_yu_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\NewDocumentCommand{\trsuffyu}{m}
 {
  \tr_suffix_yu:n { #1 }
 }

\cs_new:Npn \tr_suffix_yu:n #1
 {
  \int_compare:nTF { #1 == 0 } { '{\i} } { \tr_suffix_yu_nonzero:n { #1 } }
 }
\cs_new:Npn \tr_suffix_yu_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'i}
    {2}{'yi}
    {3}{'\"{u}}
    {4}{'\"{u}}
    {5}{'i}
    {6}{'y{\i}}
    {7}{'yi}
    {8}{'i}
    {9}{'u}
    {10}{'u}
    {20}{'yi}
    {30}{'u}
    {40}{'{\i}}
    {50}{'yi}
    {60}{'{\i}}
    {70}{'i}
    {80}{'i}
    {90}{'{\i}}
    {100}{'\"{u}}
    {1000}{'i}
   }
   {
    \tr_suffix_yu_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \tr_suffix_yu:n { V }

\cs_new:Npn \tr_suffix_yu_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \tr_suffix_yu_complex_ten:n { #1 } }
   { \tr_suffix_yu_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }
\cs_new:Npn \tr_suffix_yu_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \tr_suffix_yu_complex_hundred:n { #1 } }
   { \tr_suffix_yu_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \tr_suffix_yu_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \tr_suffix_yu_complex_thousand:n { #1 } }
   { 'i }%{ \tr_suffix_yu_nonzero:n { \int_mod:nn { #1 } { 1000 } } }
 }
\cs_new:Npn \tr_suffix_yu_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \tr_suffix_yu_complex_tenthousand:n { #1 } }
   { 'i }%{ \tr_suffix_yu_nonzero:n { \int_mod:nn { #1 } { 10000 } } }
 }
\cs_new:Npn \tr_suffix_yu_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \tr_suffix_yu_complex_hundredthousand:n { #1 } }
   { 'i }%{ \tr_suffix_yu_nonzero:n { \int_mod:nn { #1 } { 100000 } } }
 }
\cs_new:Npn \tr_suffix_yu_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \tr_suffix_yu_complex_million:n { #1 } }
   { 'u }%{ \tr_suffix_yu_nonzero:n { \int_mod:nn { #1 } { 1000000 } } }
 }

%%%TR_Suffix_No'ya
\seq_new:N \l__tr_suffix_ya_seq
\tl_new:N \l__tr_suffix_ya_tl
\cs_new_protected:Npn \tr_suffix_ya_get:n #1
 {
  \seq_set_split:Nnx \l__tr_suffix_ya_seq { . } { \getrefnumber { #1 } }
  \seq_pop_right:NN \l__tr_suffix_ya_seq \l__tr_suffix_ya_tl
  \tr_suffix_ya:V \l__tr_suffix_ya_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\NewDocumentCommand{\trsuffya}{m}
 {
  \tr_suffix_ya:n { #1 }
 }

\cs_new:Npn \tr_suffix_ya:n #1
 {
  \int_compare:nTF { #1 == 0 } { 'a } { \tr_suffix_ya_nonzero:n { #1 } }
 }
\cs_new:Npn \tr_suffix_ya_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'e}
    {2}{'ye}
    {3}{'e}
    {4}{'e}
    {5}{'e}
    {6}{'ya}
    {7}{'ye}
    {8}{'e}
    {9}{'a}
    {10}{'a}
    {20}{'ye}
    {30}{'a}
    {40}{'a}
    {50}{'ye}
    {60}{'a}
    {70}{'e}
    {80}{'e}
    {90}{'a}
    {100}{'e}
    {1000}{'e}
   }
   {
    \tr_suffix_ya_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \tr_suffix_ya:n { V }

\cs_new:Npn \tr_suffix_ya_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \tr_suffix_ya_complex_ten:n { #1 } }
   { \tr_suffix_ya_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }
\cs_new:Npn \tr_suffix_ya_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \tr_suffix_ya_complex_hundred:n { #1 } }
   { \tr_suffix_ya_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \tr_suffix_ya_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \tr_suffix_ya_complex_thousand:n { #1 } }
   { 'de }%{ \tr_suffix_ya_nonzero:n { \int_mod:nn { #1 } { 1000 } } }
 }
\cs_new:Npn \tr_suffix_ya_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \tr_suffix_ya_complex_tenthousand:n { #1 } }
   { 'de }%{ \tr_suffix_ya_nonzero:n { \int_mod:nn { #1 } { 10000 } } }
 }
\cs_new:Npn \tr_suffix_ya_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \tr_suffix_ya_complex_hundredthousand:n { #1 } }
   { 'de }%{ \tr_suffix_ya_nonzero:n { \int_mod:nn { #1 } { 100000 } } }
 }
\cs_new:Npn \tr_suffix_ya_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \tr_suffix_ya_complex_million:n { #1 } }
   { 'da }%{ \tr_suffix_ya_nonzero:n { \int_mod:nn { #1 } { 1000000 } } }
 }
1
  • 1
    You'll nees some programming to do this, should be possible to do. Have a look at the refcount package, it can extract the number for a reference from the label (\ref does not just return the number), then that extracted number can be examined further. The etoolbox package can probably help you with the programming.
    – daleif
    Commented Sep 13, 2017 at 9:51

1 Answer 1

2

An almost straightforward generalization of Changing the suffix according to the figure number

\documentclass{article}
\usepackage[turkish]{babel}
\usepackage{refcount}
\usepackage{amsmath}
\usepackage{xparse}

\usepackage{multicol} % only needed for the test

\ExplSyntaxOn
\NewDocumentCommand{\turkishref}{sm}
 {
  \IfBooleanTF{#1}{\ref*{#2}}{\ref{#2}}
  \turksuf_suffix_get:n { #2 }
 }
\NewDocumentCommand{\turkisheqref}{m}
 {
  \eqref{#1}\turksuf_suffix_get:n { #1 }n
 }

\seq_new:N \l__turksuf_ref_seq
\tl_new:N \l__turksuf_ref_tl
\cs_new_protected:Npn \turksuf_suffix_get:n #1
 {
  \seq_set_split:Nnx \l__turksuf_ref_seq { . } { \getrefnumber { #1 } }
  \seq_pop_right:NN \l__turksuf_ref_seq \l__turksuf_ref_tl
  \turksuf_suffix:V \l__turksuf_ref_tl
 }
\cs_generate_variant:Nn \seq_set_split:Nnn { Nnx }

\NewDocumentCommand{\turkishsuffix}{m}
 {
  \turksuf_suffix:n { #1 }
 }

\cs_new:Npn \turksuf_suffix:n #1
 {
  \int_compare:nTF { #1 == 0 } { 'da } { \turksuf_nonzero:n { #1 } }
 }
\cs_new:Npn \turksuf_nonzero:n #1
 {
  \int_case:nnF { #1 }
   {
    {1}{'de}
    {2}{'de}
    {3}{'te}
    {4}{'te}
    {5}{'te}
    {6}{'da}
    {7}{'de}
    {8}{'de}
    {9}{'da}
    {10}{'da}
    {20}{'de}
    {30}{'da}
    {40}{'da}
    {50}{'de}
    {60}{'da}
    {70}{'de}
    {80}{'de}
    {90}{'da}
    {100}{'de}
    {1000}{'de}
   }
   {
    \turksuf_complex:n { #1 }
   }
 }
\cs_generate_variant:Nn \turksuf_suffix:n { V }

\cs_new:Npn \turksuf_complex:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10 } = 0 }
   { \turksuf_complex_ten:n { #1 } }
   { \turksuf_nonzero:n { \int_mod:nn { #1 } { 10 } } }
 }

\cs_new:Npn \turksuf_complex_ten:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100 } = 0 }
   { \turksuf_complex_hundred:n { #1 } }
   { \turksuf_nonzero:n { \int_mod:nn { #1 } { 100 } } }
 }
\cs_new:Npn \turksuf_complex_hundred:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000 } = 0 }
   { \turksuf_complex_thousand:n { #1 } }
   { 'de }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 1000 } } }
 }
\cs_new:Npn \turksuf_complex_thousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 10000 } = 0 }
   { \turksuf_complex_tenthousand:n { #1 } }
   { 'de }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 10000 } } }
 }
\cs_new:Npn \turksuf_complex_tenthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 100000 } = 0 }
   { \turksuf_complex_hundredthousand:n { #1 } }
   { 'de }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 100000 } } }
 }
\cs_new:Npn \turksuf_complex_hundredthousand:n #1
 {
  \int_compare:nTF { \int_mod:nn { #1 } { 1000000 } = 0 }
   { \turksuf_complex_million:n { #1 } }
   { 'da }%{ \turksuf_nonzero:n { \int_mod:nn { #1 } { 1000000 } } }
 }

% this is only for testing, not needed for production
\NewDocumentCommand\test{m}
 {
  \int_step_inline:nnnn { 0 } { 1 } { #1 }
   {
    \hrule
    ##1\turkishsuffix{##1}
    \begin{equation}\label{test##1}0=0\end{equation}
    \turkisheqref{test##1}\par
    \hrule
   }
 }
% end of removable stuff
\ExplSyntaxOff

\setlength{\parindent}{0pt} % just for the test

\begin{document}

\begin{multicols}{5}
\test{300}
\end{multicols}

\setcounter{figure}{12}
\begin{figure}
\caption{X}\label{A}
\end{figure}
\figurename~\turkishref{A}.

1234\turkishsuffix{1234}\\
1320\turkishsuffix{1320}\\
1330\turkishsuffix{1330}\\
1000\turkishsuffix{1000}\\
1003\turkishsuffix{1003}

\setcounter{section}{1}
\setcounter{subsection}{3}
\subsection{B}\label{B}

Subsection~\turkishref{B}

\end{document}

If you want the suffix, you use \turkishref or \turkisheqref.

enter image description here

5
  • What do sm and m refer to? Both could be m?
    – bkarpuz
    Commented Sep 13, 2017 at 14:23
  • 1
    @bkarpuz In the first case you can do \turkishref*, but only with hyperref (a reference that doesn't make a link). The specifier s means that the command has the *-variant.
    – egreg
    Commented Sep 13, 2017 at 15:06
  • @egreg I hope you are still around here man because I would like to use this turkishref.sty and turkishcite.sty (you prepared them many years ago for me) on overleaf? I include them into my overleaf project (of course uploading the files) however they return errors.
    – WhoCares
    Commented Mar 2, 2021 at 6:32
  • @WhoCares I guess you can upload them in your project. Ask Overleaf support team.
    – egreg
    Commented Mar 2, 2021 at 8:55
  • @egreg I have tried already. Doesn't work. I think there is some kind of compatibility problem, says: The control sequence at the end of the top line of your error message was never \def'ed. If you have misspelled it (e.g., \hobx'), type I' and the correct spelling (e.g., I\hbox'). Otherwise just continue, and I'll forget about whatever was undefined.` I would be grateful if you could take a quick look.
    – WhoCares
    Commented Mar 2, 2021 at 9:02

You must log in to answer this question.

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