
후에Joseph Wright의 블로그 게시물, 나는 mhchem
에서 사용하고 싶었습니다 chemfig
. 패키지에 약어를 포함하기로 결정하기 전까지는 모든 것이 순조롭게 진행되었습니다 acro
. 다음 MWE를 사용하면 두문자어가 사용된 것으로 정의되지만 두문자어 목록에는 포함되지 않습니다.
\documentclass{article}
\usepackage{acro}
\usepackage{chemfig}
\usepackage[version=4]{mhchem}
\DeclareAcronym{boc}{short=Boc,long=\textit{tert}-butyloxycarbonyl}
% From http://www.texdev.net/2012/08/25/exploring-chemfig-customising-appearance/
\makeatletter
\def\CF@node@content{%
\expandafter\expandafter\expandafter%\expandafter\expandafter%
\printatom\expandafter\expandafter\expandafter%\expandafter\expandafter%
{\csname atom@\number\CF@cnt@atomnumber\endcsname}%
\ensuremath{\CF@node@strut}%
}
\makeatother
\renewcommand*{\printatom}[1]{{\ce{#1}}}
\begin{document}
\sffamily
\acifused{boc}{Boc is used}{Boc is not used}
\chemfig{\acs{boc}HN-R-NH2}
\acifused{boc}{Boc is used}{Boc is not used}
\printacronyms
\end{document}
블로그 게시물의 코드가 제거되면 모든 것이 다시 잘 작동 \ce
하지만 \chemfig
. 그리고 \chemfig
제가 원하던 수학 세리프체 대신 산세리프 텍스트체를 사용하게 만들었습니다.
\expandafter
매크로 주위에 5개의 s를 사용해 보았습니다 \printatom
. 이로 인해 약어 문제가 해결되었으며 글꼴은 여전히 주변 산세리프 텍스트 글꼴과 동일하지만 구문 분석이 \ce
더 이상 올바르게 수행되지 않습니다. 아래첨자가 아닌 2에 주목하세요:
acro
두 가지를 모두 얻고 mhchem
내부에서 작업하는 방법에 대한 제안은 chemfig
높이 평가됩니다.
답변1
재정의로 인해 \acs
명령이 두 번 이상 처리되지만 첫 번째 처리는 교육받은 추측이므로 acro의 쓰기 명령이 실행되지 않고 내용을 측정하기 위해서만 수행되므로 \acro@used@once
aux 파일에는 필요 하지만 \acro@used@twice
실제 조판에서만 필요합니다.
align
내부 (테스트됨) 및 아마도 tabularx
콘텐츠를 두 번 처리하는 다른 환경에서 acro를 사용하는 경우에도 유사한 동작이 발생합니다 . 그래서 imho 그것은 버그입니다. acro는 이 경우를 확인해야 합니다.
작성자에게 알려야 합니다. 해결 방법으로 다음을 시도해 볼 수 있습니다. acro의 관점에서 보면 이 키가 두 번 사용되었다는 점에 유의하세요. 따라서 "단일" 발생에 대한 특별한 스타일은 작동하지 않습니다.
\documentclass{article}
\usepackage{acro}
\usepackage{chemfig,amsmath}
\usepackage[version=4]{mhchem}
\DeclareAcronym{boc}{short=Boc,long=\textit{tert}-butyloxycarbonyl}
%% From http://www.texdev.net/2012/08/25/exploring-chemfig-customising-appearance/
\makeatletter
\def\CF@node@content{%
\expandafter\expandafter\expandafter%\expandafter\expandafter%
\printatom\expandafter\expandafter\expandafter%\expandafter\expandafter%
{\csname atom@\number\CF@cnt@atomnumber\endcsname}%
\ensuremath{\CF@node@strut}%
}
\ExplSyntaxOn
\cs_set_protected:Npn \acro@used@twice #1#2#3#4
{
\bool_if:cF {g__acro_#1_in_list_bool}
{\acro@used@once {#1}{#2}{#3}{#4}}
\cs_gset_nopar:cpn {acro@#1@twice} {#1}
\tl_if_empty:nF {#2#3#4}
{ \seq_gput_right:cn {g__acro_#1_pages_seq} { {#2}{#3}{#4} } }
}
\ExplSyntaxOff
\makeatother
\renewcommand*{\printatom}[1]{{\ce{#1}}}
\begin{document}
\sffamily
\acifused{boc}{Boc is used}{Boc is not used}
\chemfig{\acs{boc}HN-R-NH2}
\acifused{boc}{Boc is used}{Boc is not used}
\printacronyms
\end{document}