.png)
Dado el siguiente MWE, ¿hay alguna manera de cambiar la ubicación del formulario abreviado en el primer uso (completo), de modo que no siempre aparezca después de imprimir el formulario largo?
\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}
Si no es así, ¿podría haber un nuevo conjunto de comandos para usar dentro del \DeclareAcronym
bloque? Entonces la declaración podría verse así
\DeclareAcronym{grad}{
short=$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$,
long=gradient\short of \ac{rho}
}
¿Dónde \short
se reemplazaría con un espacio (tenga en cuenta que no hay espacio antes \short
) seguido de la forma corta entre paréntesis? Se podrían agregar comandos similares para otros argumentos según \DeclareAcronym
sea necesario.
Respuesta1
En el futuro, la \DeclareAcroFirstStyle
macro podría proporcionar una interfaz para lograr esto, pero con las opciones disponibles actualmente no pude resolver algo, tal como está, pude encontrar dos formas de hacerlo, pero ambas con problemas potenciales que interfieren con otros.acro
características.
Al utilizar la \acifused{<id>}{<true>}{<false>}
macro podemos adaptar la long
entrada de \DeclareAcronym{grad}{<keys>}
para cambiar su apariencia según se rho
haya utilizado el acrónimo. Desafortunadamente, no parece particularmente fácil agregar texto a la primera aparición; en lugar de eso, tuve que definir un first-style
que solo imprimiera el formato largo e incluyera el formato corto en el formato largo.
\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,
}
Si bien esto genera las primeras apariciones como se desea, no funciona tan bien con \acl{grad}
, lo que seguirá generando una forma corta entre corchetes.
\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}
Alternativamenteacro
permite la creación manual de \ac
comandos tipo -, que podemos usar para construir algo específico para el grad
acrónimo que ensamblará manualmente la forma larga o corta adecuada según si se han utilizado los acrónimos rho
y grad
(en el código siguiente ).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
Esto tiene la ventaja de dejar la long
versión intacta y \acgrad
se usa en lugar de \ac{grad}
con una mínima dificultad adicional, pero cualquiera de las variantes para hacer el equivalente de \Ac{grad}
, \acp{grad}
etc. debe definirse manualmente para que compartan la primera apariencia adecuada.
Comparando estas dos estrategias
\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}
Respuesta2
Como nadie proporcionó una respuesta con el acro
paquete, aquí hay una solución usando glossaries-extra
. Esto define un estilo personalizado ofother
que verifica si el user1
campo se ha configurado. Si es así, entonces el valor se toma como etiqueta para el otro símbolo y se hace "de ..." (de lo contrario, no hace nada). Esto se hace con el \ofother
comando personalizado, que toma la etiqueta como argumento:
\newcommand*{\ofother}[1]{%
\ifglshasfield{user1}{#1}%
{\space of \glsentrylong{\glscurrentfieldvalue}
(\glsxtrshort{\glscurrentfieldvalue})}%
{}%
}
El ofother
estilo personalizado que utiliza este comando es:
\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}%
}
Esto utiliza el enlace posterior al enlace para agregar \ofother{\glslabel}
después del primer uso.
Puede configurar diferentes estilos según la categoría de la entrada. Por ejemplo:
\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}
Sin embargo, como \ofother
no hace nada si user1
no se ha configurado, se les puede dar el mismo estilo con solo la abbreviation
categoría predeterminada:
\setabbreviationstyle{ofother}
\newabbreviation{rho}{$\rho$}{electron charge density}
\newabbreviation
[user1=rho]
{grad}
{$\bm{\nabla}$\hspace{-1.2pt}$\bm{\rho}$}
{gradient}
Aquí tienes un documento completo:
\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}
Esto produce:
El primer uso de grad
no se desarma rho
. Si es necesario desarmarlo al mismo tiempo, esto solo requiere una modificación menor en \ofother
:
\newcommand*{\ofother}[1]{%
\ifglshasfield{user1}{#1}%
{\space of \glsentrylong{\glscurrentfieldvalue}
(\glsxtrshort{\glscurrentfieldvalue}\glsunset{\glscurrentfieldvalue})}%
{}%
}
Si desea una lista de todos los símbolos, el método más simple es utilizar \printunsrtglossary
el cual enumerará todas las entradas definidas en el orden de definición:
\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}
Haymuchos estilos de glosario predefinidossi no te gusta el valor predeterminado.
Si desea utilizar hyperref
asegúrese de que esté cargado antes glossaries-extra
:
\usepackage[colorlinks]{hyperref}
\usepackage[shortcuts]{glossaries-extra}
(En general, hyperref
debe cargarse al final. Esta es una de las pocas excepciones).
Si obtiene algún "error de secuencia de control no definido" en el ejemplo anterior, verifique que tenga versiones actualizadas deglossaries
yglossaries-extra
.
Respuesta3
Con la actualización de ayer a v2.8 acro
tiene la propiedad post
que permite anteponer algo a un acrónimo. También está el comando \aciffirst{true}{false}
con el que puedes probar si se utiliza la sigla la primera vez:
\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}