.png)
다음 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
는 나중에 이를 달성하기 위한 인터페이스를 제공할 수 있지만 현재 사용 가능한 옵션으로는 뭔가를 해결할 수 없었습니다. 현재로서는 두 가지 방법을 찾을 수 있지만 둘 다 다른 작업을 방해하는 잠재적인 문제가 있습니다.acro
특징.
매크로 를 활용하여 약어 사용 여부에 따라 항목 의 모양을 변경하도록 \acifused{<id>}{<true>}{<false>}
조정할 수 있습니다 . 불행하게도 첫 번째 모양에 텍스트를 추가하는 것이 특히 쉬운 것 같지는 않습니다. 대신 긴 형식만 인쇄하고 긴 형식에 짧은 형식을 포함하는 a를 정의해야 했습니다.long
\DeclareAcronym{grad}{<keys>}
rho
first-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
-like 명령 을 수동으로 생성할 수 있습니다 . 이 명령을 사용하면 및 (아래 코드에서 ) 두문자어가 모두 사용되었는지 여부에 따라 적절한 긴 형식 또는 짧은 형식을 수동으로 조합하는 약어용 \ac
으로 특별히 무언가를 구성하는 데 사용할 수 있습니다.grad
rho
grad
gradtwo
\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}
이 두 가지 전략 비교
\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
. 이는 필드가 설정되었는지 ofother
확인하는 사용자 정의 스타일을 정의합니다 . user1
그렇다면 그 값은 다른 기호에 대한 레이블로 간주되고 "..."가 완료됩니다(그렇지 않으면 아무 작업도 수행하지 않음). 이는 \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}
이것은 처음 사용 후 추가하기 위해 포스트 링크 후크를 사용합니다 .
항목 카테고리에 따라 다양한 스타일을 설정할 수 있습니다. 예를 들어:
\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
unset되지 않습니다 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
마지막에 로드해야 합니다. 이는 몇 가지 예외 중 하나입니다.)
위의 예에서 "정의되지 않은 제어 시퀀스 오류"가 발생하는 경우 최신 버전이 있는지 확인하십시오.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}