頭字語パッケージ - 頭字語の最初の出現を次の引用/括弧と結合します

頭字語パッケージ - 頭字語の最初の出現を次の引用/括弧と結合します

私はパッケージを使用していますacronym。私のテキストには次のようなことがよく起こります:

1. We first use a \ac{NA} \citep{exocom2019} and then the text continues.

2. We learn a \ac{VL} (i.e., something we did not know before).

テキストでは次のようになります。

  1. まず新しい頭字語 (NA) (Exocom、2019) を使用し、その後にテキストが続きます。

  2. 私たちは貴重な教訓(VL)(つまり、これまで知らなかったこと)を学びます。

acronymパッケージ内で括弧を結合できるようにこれを行う方法はありますか? ある意味では、出力は次のようになります。

  1. まず新しい頭字語 (NA; Exocom、2019) を使用し、その後にテキストが続きます。

  2. 私たちは貴重な教訓(VL、つまり、これまで知らなかったこと)を学びます。

この問題に対する別の良い解決策や回避策をお持ちの方がいらっしゃいましたら、ぜひお知らせください。

PS: 要求に応じて例を更新し、コードを追加してみました。お役に立てれば幸いです。

PPS: MWE について

--- mwe.tex ---

\documentclass[12pt]{book}

\usepackage[printonlyused]{acronym} % used for the nice acronyms
\usepackage[style=authoryear-comp,citestyle=authoryear,natbib=true,backend=bibtex,maxbibnames=99,maxcitenames=1]{biblatex} %NEW BIB: needed so that bibentry works

\bibliography{mweBib}

\begin{document}

\begin{acronym}
    \acro{NA}{New Acronym} 
    \acro{VL}{Valuable Lesson} 
\end{acronym}

1. We first use a \ac{NA} \citep{exocom2019} and then the text continues.

2. We learn a \ac{VL} (i.e., something we did not know before).
\end{document}

--- mweBib.bib ---

@inproceedings{exocom2019,
  title={My title},
  author={Exocom},
  year={2019},
  booktitle = {Proc. Stackexchange}
}

- - 指示 - -

latexmk -pvc mwe.tex

答え1

これはパッケージで実行可能ですacro:

  • オプションを設定しcite/group = true、頭字語の定義に引用を追加することで、引用はすでに組み込まれています。

  • デフォルトのテンプレートを再定義することで、1 回限りの追加が可能になります。

      \RenewAcroTemplate{long-short}{%
        \acroiffirstTF{%
          \acrowrite{long}%
          \acspace(%
            \acroifT{foreign}{\acrowrite{foreign}, }%
            \acrowrite{short}%
            \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}%
            \acaddition % <<< new
            \acrogroupcite
          )%
        }{%
          \acrowrite{short}%
          \acaddition % <<< new
        }%
      }
    

    …そしてコマンド\ac

      \providecommand\acaddition{}
      \RenewAcroCommand\ac{mo}{%
        \IfNoValueF{#2}{\def\acaddition{, #2}}%
        \UseAcroTemplate{first}{#1}%
      }
    

    および の仲間によって定義されたコマンドは\NewAcroCommandグループに対してローカルなので、その後の定義について心配する必要はありません\acaddition

完全な例:

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

\documentclass{article}

\usepackage[style=authoryear-comp,citestyle=authoryear]{biblatex}
\addbibresource{\jobname.bib}


\begin{filecontents}{\jobname.bib}
@inproceedings{exocom2019,
  title={My title},
  author={Exocom},
  year={2019},
  booktitle = {Proc. Stackexchange}
}
\end{filecontents}

\usepackage{acro}

\RenewAcroTemplate{long-short}{%
  \acroiffirstTF{%
    \acrowrite{long}%
    \acspace(%
      \acroifT{foreign}{\acrowrite{foreign}, }%
      \acrowrite{short}%
      \acroifT{alt}{ \acrotranslate{or} \acrowrite{alt}}%
      \acaddition % <<< new
      \acrogroupcite
    )%
  }{%
    \acrowrite{short}%
    \acaddition % <<< new
  }%
}

\providecommand\acaddition{}
\RenewAcroCommand\ac{mo}{%
  \IfNoValueF{#2}{\def\acaddition{, #2}}%
  \UseAcroTemplate{first}{#1}%
}

\acsetup{
  cite/group = true
}

\DeclareAcronym{NA}{
  short = NA ,
  long = New Acronym ,
  cite = exocom2019
}
\DeclareAcronym{VL}{
  short = VL ,
  long = Valuable Lesson
}

\begin{document}

\begin{enumerate}
  \item We first use a \ac{NA} and then the text continues.
  \item We learn a \ac{VL}[i.e., something we did not know before].
\end{enumerate}

\end{document}

関連情報