頭字語の初使用時に短縮形の位置を変更しますか? (acro.sty を使用)

頭字語の初使用時に短縮形の位置を変更しますか? (acro.sty を使用)

次の MWE の場合、長い形式が印刷された後に省略形式が常に表示されないように、最初に使用されるときの省略形式 (完全形式) の位置を変更する方法はありますか?

\documentclass[]{article}
\usepackage{acro,bm}
\DeclareAcronym{rho}{
    short=$\rho$,
    long=electron charge density
}
\DeclareAcronym{grad}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient of \ac{rho}
}

\begin{document}

first use of grad:
\ac{grad}

would rather have:
gradient (\acs{grad}) of \acf{rho}

\end{document}

ここに画像の説明を入力してください

そうでない場合、ブロック内で使用する新しいコマンドセットがあるでしょうか\DeclareAcronym? 代わりに、宣言は次のようになります。

\DeclareAcronym{grad}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient\short of \ac{rho}
}

\shortは、スペース( の前にスペースがないことに注意してください\short)とそれに続く括弧付きの短縮形で置き換えられますか?\DeclareAcronym必要に応じて、 の他の引数にも同様のコマンドを追加できます。

答え1

マクロ\DeclareAcroFirstStyleは将来的にこれを実現するためのインターフェースを提供する可能性がありますが、現在利用可能なオプションでは、何かを解決することができませんでした。現状では、2つの方法を見つけることができましたが、どちらも他の機能に干渉する可能性のある問題がありました。acro特徴。

マクロを利用することで、頭字語が使用されているかどうかに応じて、のエントリの外観を変更する\acifused{<id>}{<true>}{<false>}ことができます。残念ながら、最初の外観にテキストを追加するのはそれほど簡単ではないようです。代わりに、長い形式のみを印刷し、短い形式を長い形式に含める を定義する必要がありました。long\DeclareAcronym{grad}{<keys>}rhofirst-style

\DeclareAcroFirstStyle{conditional}{inline}{
    only-long=true
}
\DeclareAcronym{grad}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient \acifused{rho}{of \ac{rho} (\acs{grad})}{(\acs{grad}) of \acl{rho} (\acs{rho})},
    first-style=conditional,
}

これは望みどおりに最初の出現を生成しますが、 ではうまく動作しません。 は、\acl{grad}括弧で囲まれた短縮形を生成するため、

\documentclass{article}
\usepackage{acro,bm}

\DeclareAcroFirstStyle{conditional}{inline}{
only-long=true
}

\DeclareAcronym{rho}{
    short=$\rho$,
    long=electron charge density,
}
\DeclareAcronym{grad}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient \acifused{rho}{of \ac{rho} (\acs{grad})}{(\acs{grad}) of \acl{rho} (\acs{rho})},
    first-style=conditional,
}
\DeclareAcronym{gradtwo}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient of \acs{rho}
}

\begin{document}
\ac{grad}

\acuse{rho}
\acf{grad}

\ac{grad}

\acl{grad}

\acreset{rho}
\acl{grad}
\end{document}

ここに画像の説明を入力してください


あるいはacro\acは、 のようなコマンドを手動で作成することを可能にします。これを使用して、と(以下のコードでは)gradの両方の頭字語が使用されているかどうかに応じて、適切な長い形式または短い形式を手動で組み立てる、頭字語専用のものを構築できます。rhogradgradtwo

\ExplSyntaxOn
\NewDocumentCommand \acgrad {s}
{
    \acro_begin:
    \acro_reset_specials:
    \acro_check_and_mark_if:nn {#1}{gradtwo}
    \acro_if_acronym_used:nTF {gradtwo}
    {
        \acro_short:n {gradtwo}
    }{
        \acro_if_acronym_used:nTF {rho}
        {
            \acro_long:n {gradtwo}~(\acro_short:n {gradtwo})
        }{
            gradient~(\acro_short:n {gradtwo})~of~\acro_long:n {rho}~(\acro_short:n {rho})
        }
    }
    \acro_end:
}
\ExplSyntaxOff

これには、バージョンを変更しないという利点がありlong\acgradの代わりに最小限の追加の問題で使用されますが、など\ac{grad}と同等のことを実行するバリアントは、適切な初見を共有するために手動で定義する必要があります。\Ac{grad}\acp{grad}

これら2つの戦略を比較すると

\documentclass[]{article}
\usepackage{acro,bm}

\DeclareAcroFirstStyle{conditional}{inline}{
only-long=true
}

\DeclareAcronym{rho}{
    short=$\rho$,
    long=electron charge density,
}
\DeclareAcronym{grad}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient \acifused{rho}{of \ac{rho} (\acs{grad})}{(\acs{grad}) of \acl{rho} (\acs{rho})},
    first-style=conditional,
}
\DeclareAcronym{gradtwo}{
    short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
    long=gradient of \acs{rho}
}

\ExplSyntaxOn
\NewDocumentCommand \acgrad {s}
{
    \acro_begin:
    \acro_reset_specials:
    \acro_check_and_mark_if:nn {#1}{gradtwo}
    \acro_if_acronym_used:nTF {gradtwo}
    {
        \acro_short:n {gradtwo}
    }{
        \acro_if_acronym_used:nTF {rho}
        {
            \acro_long:n {gradtwo}~(\acro_short:n {gradtwo})
        }{
            gradient~(\acro_short:n {gradtwo})~of~\acro_long:n {rho}~(\acro_short:n {rho})
        }
    }
    \acro_end:
}
\ExplSyntaxOff

\begin{document}
\ac{grad}

\acuse{rho}
\acf{grad}

\ac{grad}

%\acreset{rho}
\acl{grad}

\hrule

\acreset{rho}
\acgrad

\acreset{gradtwo}
\acgrad

\acgrad

\acl{gradtwo}
\end{document}

ここに画像の説明を入力してください

答え2

パッケージに関する回答が誰も提供していないのでacro、 を使用した解決策を示します。これは、フィールドが設定されているかどうかを確認するglossaries-extraカスタム スタイルを定義します。設定されている場合は、値が他のシンボルのラベルとして取得され、「of ...」が実行されます (そうでない場合は何も実行されません)。これは、ラベルを引数として受け取るcustom コマンドを使用して実行されます。ofotheruser1\ofother

\newcommand*{\ofother}[1]{%
 \ifglshasfield{user1}{#1}%
 {\space of \glsentrylong{\glscurrentfieldvalue}
  (\glsxtrshort{\glscurrentfieldvalue})}%
 {}%
}

ofotherこのコマンドを使用するカスタムスタイルは次のとおりです。

\newabbreviationstyle{ofother}
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\the\glsshorttok},
    sort={\the\glslabeltok},
    first={\the\glslongtok\space(\the\glsshorttok)},
    description={\the\glslongtok\protect\ofother{\the\glslabeltok}}
  }%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \csdef{glsxtrpostlink\glscategorylabel}{%
      \glsxtrifwasfirstuse
      {%
        \ofother{\glslabel}%
      }%
      {}%
    }%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}
{%
  \GlsXtrUseAbbrStyleFmts{long-short}%
}

\ofother{\glslabel}これは、最初の使用後に追加するために post-link フックを使用します。

エントリのカテゴリに応じて異なるスタイルを設定できます。例:

\setabbreviationstyle[symbol]{long-short}    
\setabbreviationstyle[of]{ofother}

\newabbreviation[category=symbol]{rho}{$\rho$}{electron charge density}
\newabbreviation
 [category=of,user1=rho]
 {grad}
 {$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$}
 {gradient}

ただし、が設定されていない\ofother場合は何も行われないためuser1、デフォルトのカテゴリだけで同じスタイルを指定できますabbreviation

\setabbreviationstyle{ofother}

\newabbreviation{rho}{$\rho$}{electron charge density}
\newabbreviation
 [user1=rho]
 {grad}
 {$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$}
 {gradient}

完全な文書は次のとおりです:

\documentclass{article}

\usepackage{bm}
\usepackage[shortcuts]{glossaries-extra}

\newcommand*{\ofother}[1]{%
 \ifglshasfield{user1}{#1}%
 {\space of \glsentrylong{\glscurrentfieldvalue}
  (\glsxtrshort{\glscurrentfieldvalue})}%
 {}%
}

\newabbreviationstyle{ofother}
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\the\glsshorttok},
    sort={\the\glslabeltok},
    first={\the\glslongtok\space(\the\glsshorttok)},
    description={\the\glslongtok\protect\ofother{\the\glslabeltok}}
  }%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \csdef{glsxtrpostlink\glscategorylabel}{%
      \glsxtrifwasfirstuse
      {%
        \ofother{\glslabel}%
      }%
      {}%
    }%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}
{%
  \GlsXtrUseAbbrStyleFmts{long-short}%
}

\setabbreviationstyle{ofother}

\newabbreviation{rho}{$\rho$}{electron charge density}
\newabbreviation
 [user1=rho]
 {grad}
 {$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$}
 {gradient}

\begin{document}
First use: \ac{grad}.

Next use: \ac{grad}.

Here's \ac{rho}.

Reset all.\glsresetall

First use again: \ac{rho} and \ac{grad}.

\end{document}

これにより、次のものが生成されます。

最初の使用: 電子電荷密度 (ρ) の勾配 (∇ρ)。次の使用: ∇ρ。これが電子電荷密度 (ρ) です。すべてをリセットします。もう一度最初の使用: 電子電荷密度 (ρ) と電子電荷密度 (ρ) の勾配 (∇ρ)。

の最初の使用では はgrad設定解除されませんrho。 を同時に設定解除する必要がある場合は、 に小さな変更を加えるだけです\ofother

\newcommand*{\ofother}[1]{%
 \ifglshasfield{user1}{#1}%
 {\space of \glsentrylong{\glscurrentfieldvalue}
  (\glsxtrshort{\glscurrentfieldvalue}\glsunset{\glscurrentfieldvalue})}%
 {}%
}

すべてのシンボルのリストが必要な場合、最も簡単な方法は、\printunsrtglossary定義されたすべてのエントリを定義順にリストする を使用することです。

\documentclass{article}

\usepackage{bm}
\usepackage[shortcuts]{glossaries-extra}

\newcommand*{\ofother}[1]{%
 \ifglshasfield{user1}{#1}%
 {\space of \glsentrylong{\glscurrentfieldvalue}
  (\glsxtrshort{\glscurrentfieldvalue}\glsunset{\glscurrentfieldvalue})}%
 {}%
}

\newabbreviationstyle{ofother}
{%
  \renewcommand*{\CustomAbbreviationFields}{%
    name={\the\glsshorttok},
    sort={\the\glslabeltok},
    first={\the\glslongtok\space(\the\glsshorttok)},
    description={\the\glslongtok\protect\ofother{\the\glslabeltok}}
  }%
  \renewcommand*{\GlsXtrPostNewAbbreviation}{%
    \csdef{glsxtrpostlink\glscategorylabel}{%
      \glsxtrifwasfirstuse
      {%
        \ofother{\glslabel}%
      }%
      {}%
    }%
    \glshasattribute{\the\glslabeltok}{regular}%
    {%
      \glssetattribute{\the\glslabeltok}{regular}{false}%
    }%
    {}%
  }%
}
{%
  \GlsXtrUseAbbrStyleFmts{long-short}%
}

\setabbreviationstyle{ofother}

\newabbreviation{rho}{$\rho$}{electron charge density}
\newabbreviation
 [user1=rho]
 {grad}
 {$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$}
 {gradient}

\begin{document}
First use: \ac{grad}.

Next use: \ac{grad}.

Here's \ac{rho}.

Reset all.\glsresetall

First use again: \ac{rho} and \ac{grad}.

\printunsrtglossary[title=Symbols,nogroupskip]

\end{document}

シンボルのリストを含む文書の画像

がある多数の定義済み用語集スタイルデフォルトが気に入らない場合。

使用したい場合は、hyperref事前にロードされていることを確認してくださいglossaries-extra:

\usepackage[colorlinks]{hyperref}
\usepackage[shortcuts]{glossaries-extra}

(通常はhyperref最後にロードする必要があります。これは数少ない例外の 1 つです。)

上記の例で「未定義の制御シーケンスエラー」が発生した場合は、最新バージョンであることを確認してください。glossariesそしてglossaries-extra

答え3

昨日の v2.8 へのアップデートでは、頭字語の先頭に何かを追加できるacroプロパティが追加されました。また、頭字語が初めて使用されたかどうかをテストできるpostコマンドもあります。\aciffirst{true}{false}

\documentclass{article}
\usepackage{acro,bm}

\DeclareAcronym{rho}{
  short = $\rho$,
  long  = electron charge density
}
\DeclareAcronym{grad}{
  short = $\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
  long  = gradient ,
  post  = \aciffirst{ of \ac{rho}}{}
}

\begin{document}

first use of grad:
\ac{grad}

\acs{grad}

\end{document}

ここに画像の説明を入力してください

関連情報