词汇表包某些标签的条件格式

词汇表包某些标签的条件格式

我正在回忆录课上使用词汇表包撰写生物学论文。长基因名称的首字母缩写有两种形式:当提到 DNA 上的基因时,符号为斜体形式,当提到蛋白质形式时,符号为普通文本。如下所示:

\newcommand{\glsgene} etc
if \glsgene{
    print(full name (italic `short'))
    add label to the acronym list
} else{
    \gls as usual
}

我已经在以下 MWE 中解释了这一点。如何在 latex 中对此进行编码?非常感谢!

\documentclass[a4paper, oneside, 12 pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[acronym,nomain,nonumberlist]{glossaries}  
\makeglossaries
\glsdisablehyper %disables links 
\newacronym{RING}{RING}{really interesting new gene}
\begin{document}
\newpage
\printglossary[type=\acronymtype]
\hrule

Current acronym style: \gls{RING}

To refer to RING gene on DNA, it should be printed as `really interesting new gene (\textit{RING})'. Please note that the full name is in normal text whereas the symbol/short name is in italics.

When I mean RING in the protein form, it should be printed as `really interesting new gene (RING)' --- everything in normal text.

Of course, I have to specify what form I am referring to when using it for the first time. But the entry should be automatically included in the acronym list regardless of DNA or protein versions, so I don't miss any acronyms. Maybe some sort of 'if'

The full name in the list of acronyms will be printed in normal text regardless of DNA or protein form. 

\end{document}

答案1

下面的 MWE 定义在使用 之前\glsgene临时更改\acronymfont为。更改用括号括起来。这需要设置样式以确保用于格式化短格式。(默认情况下这只是执行其参数。)\textit\glslong-short\acronymfont

\documentclass[a4paper, oneside, 12 pt]{memoir}
\usepackage[utf8]{inputenc}
\usepackage[acronym,nomain,nonumberlist]{glossaries}  
\makeglossaries
\glsdisablehyper %disables links 

\setacronymstyle{long-short}
\newacronym{RING}{RING}{really interesting new gene}

\newcommand{\glsgene}[2][]{{\let\acronymfont\textit\gls[#1]{#2}}}

\begin{document}
\newpage
\printglossary[type=\acronymtype]
\hrule

First use: \gls{RING}.

Next use: \gls{RING}, \glsgene{RING}.

Reset\glsresetall

First use: \glsgene{RING}.

Next use: \glsgene{RING}, \gls{RING}.

\end{document}

得出的结果为:

结果图像

相关内容