自定义 \eqref 或 \ref 后缀

自定义 \eqref 或 \ref 后缀

我正在准备土耳其语讲稿。我们说“(1)'den”\eqref{eqn1}'den) 为了“来自(1)”( From \eqref{eqn1}),后缀取决于方程编号。我想\eqrefden为此类带后缀的引用定义一个新命令,后缀设置如下形式:

  • “(1)'den”, “(2)'den”, “(3)'ten”, “(4)'ten”, “(5)'ten”, “(6)'dan”, “(7)'den”, “(8)'den”, “(9)'dan”, “(10)'dan”
  • 从 (*1)--(*9) 定义为 (1)--(9)
  • “(20)'den”、“(30)'dan”、“(40)'tan”、“(50)'den”、“(60)'tan”、“(70)'ten”、“(80)'den”、“(90)'dan”
  • 最后,“(100)'den”

我正在手动执行此操作。但是当我需要在某处添加方程式时,我会再次更改它们。如果我可以从中得到这个想法\eqref,我可以将它用于\ref\subref,以及其他可能的后缀。

非常感谢。 布卡普兹

编辑. 感谢引用

在此处输入图片描述

下面我给出了一个完整的包和一个 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-后缀.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

几乎直接概括根据图号更改后缀

\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}

如果您想要后缀,可以使用\turkishref\turkisheqref

在此处输入图片描述

相关内容