chemfig 내부에서 acro 및 mhchem 사용

chemfig 내부에서 acro 및 mhchem 사용

후에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에 주목하세요:

mhchem에서 구문 분석되지 않은 내용

acro두 가지를 모두 얻고 mhchem내부에서 작업하는 방법에 대한 제안은 chemfig높이 평가됩니다.

답변1

재정의로 인해 \acs명령이 두 번 이상 처리되지만 첫 번째 처리는 교육받은 추측이므로 acro의 쓰기 명령이 실행되지 않고 내용을 측정하기 위해서만 수행되므로 \acro@used@onceaux 파일에는 필요 하지만 \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}

관련 정보