包 acro,法語中的單字性別女性和男性

包 acro,法語中的單字性別女性和男性

我正在用法語寫一份文檔,我必須用包包處理單字的性別形式acro。我想製作類似的東西

tridimensionnelles (3D)(女性形式)或 bidimensionnels(2D)(男性形式)

用程式碼:

\documentclass[12pt,twoside,openright]{book}
\usepackage[version=3]{acro} %list of abbreviations

\acsetup{
    list/template = longtable,
    list/display = used,
    uppercase/list,
    format/alt
}
\DeclareAcronym{2d}{
    short   = 2D,
    long    = bidimensionnel,
    alt-format = tridimensionnelles}
\DeclareAcronym{3d}{
    short   = 3D,
    long    = tridimensionnel,
    alt = tridimensionnelles}

\begin{document}
\ac{2d} is masculine gender form.
\newline
\aca{3d} is the feminine gender form, but there is not the short form (3D).
\end{document}

我可以生成類似的文本

在此輸入影像描述

但括號裡的3D沒有出現。

您對使用軟體包處理性別形式有什麼想法嗎acro

答案1

acro具有用於定義任意新屬性的接口\DeclareAcroProperty,以及新命令,\NewAcroCommand詳細資訊請參閱文檔中的章節29. 屬性30.自己的縮寫命令

然而,為了定義多個屬性和內部接口,我認為\DeclareAcroEnding可以稍微誤用以獲得良好的效果。 \DeclareAcroEnding{feminine}{}{}定義*-feminine以及和的*-feminine-form等價物最初都是空的。當女性形式與男性形式不同時,可以設定附加字母,或者當其差異更大時,可以使用整體來說明它。*-plural*-plural-formlong-feminine=leslong-feminine-form=tridimensionelles

然後我們需要添加新的\ac變體來應用這些屬性,例如

\NewAcroCommand \acF {m}
  { \acrofeminine \UseAcroTemplate {first} {#1} }
\NewAcroCommand \AcF {m}
  { \acrofeminine \acroupper \UseAcroTemplate {first} {#1} }

(請注意,我使用它是為了避免與強製完整外觀的F現有 -type 命令發生衝突)。\acf其他變體需要單獨明確定義,但可以基於找到的定義在來源中

\documentclass[12pt,twoside,openright]{book}
\usepackage{acro}[=v3]

\DeclareAcroEnding{feminine}{}{}

\DeclareAcronym{2d}{
    short   = 2D,
    long    = bidimensionnel,
    long-feminine=les,
}
\DeclareAcronym{3d}{
    short   = 3D,
    long    = tridimensionnel,
    long-feminine-form=tridimensionnelles,
}

\NewAcroCommand \acF {m}
  { \acrofeminine \UseAcroTemplate {first} {#1} }
\NewAcroCommand \AcF {m}
  { \acrofeminine \acroupper \UseAcroTemplate {first} {#1} }

\begin{document}
\ac{2d} \acreset{2d} \acF{2d}

\acF{3d} \acreset{3d} \ac{3d}

\printacronyms[heading=none]
\end{document}

程式碼輸出

對於陰性複數,我認為我們必須\DeclareAcroEnding{feminineplural}{s}{s}使用與plural結尾相同的預設值來聲明一個單獨的結尾。不幸的是,我不知道如何繼承feminine結尾,所以這將需要一些重複,即使複數只是附加一個 s。

\documentclass[12pt,twoside,openright]{book}
\usepackage{acro}[=v3]

\DeclareAcroEnding{feminine}{}{}
\DeclareAcroEnding{feminineplural}{s}{s}

\DeclareAcronym{2d}{
    short   = 2D,
    long    = bidimensionnel,
    long-feminine=les,
    long-feminineplural=less
}

\NewAcroCommand \acpF {m}
  { \acrofeminineplural \UseAcroTemplate {first} {#1} }

\begin{document}
\acp{2d} \acreset{2d} \acpF{2d}

\printacronyms[heading=none]
\end{document}

程式碼輸出


可能可以建立比利用稍微好一點的介面\DeclareAcroEnding,但不能沒有大量樣板程式碼或依賴介面expl3

答案2

當您有一個首字母縮略詞可能採用兩種任意不同的形式(無論是短/長/第一個/複數/等中的一個還是全部)時,懶惰的解決方案是定義兩個緊密相連的首字母縮寫。

首字母縮略詞的屬性uselist允許首字母縮略詞2d,並且如果已被使用,則2dB允許2d認為其自身已被使用2dB,即使它本身未被使用,反之亦然。

\DeclareAcronym{2d}{
    short   = 2D,
    long    = bidimensionnel,
    uselist = {2dB},
}
\DeclareAcronym{2dB}{
    short   = 2D,
    long    = bidimensionnelB,
    uselist = {2d},
}

這兩個首字母縮寫可以有或多或少的差異(如果必要的話甚至根本沒有差異),並且在文本中不會共享共同的第一個用法。如有必要,可以將其擴展到任意數量的首字母縮寫。

不過,像這樣配對首字母縮略詞有一些注意事項:

  • 重置使用仍然保留在首字母縮寫本地,並且\acreset{2d}只會重置2d,如果已使用過,2dB仍會記住它已使用過。

  • \acsetup{single=true}如果兩者都使用但其中之一隻使用一次,將會出現意外的行為。

  • 由於我們有兩個首字母\printacronyms縮寫詞,除非它們的列表形式相同(例如,如果它們共享短/長形式但複數屬性不同),否則將列出這兩個縮寫。這可以透過標記縮寫之一並使用excludein 來解決\printacronyms

    \DeclareAcronym{2d}{
        short   = 2D,
        long    = bidimensionnel,
        uselist = {2dB},
    }
    \DeclareAcronym{2dB}{
        short   = 2D,
        long    = bidimensionnelB,
        uselist = {2d},
        tag = {B-form},
    }
    
    \begin{document}
    \ac{2d}    
    \ac{2dB}
    
    \printacronyms[heading=none,exclude={B-form}]
    \end{document}
    

    2dB然而,如果最終僅在文件中使用並\acsetup{list/display=used}進行設置,這也可能會產生意想不到的後果。

相關內容