
expl3 구문을 떠나지 않고도 다음을 실현하는 선호되는 방법이 있습니까?
\documentclass{article}
\usepackage{expl3}
\usepackage[french]{babel}
\begin{document}
\ExplSyntaxOn
% suppose I am within a package here -- else the definition could just be made
% outside of the expl3 scope
\group_begin:
\char_set_catcode_active:N \:
% now expl3 syntax isn't possible any more
\gdef \c_colon_active_tl {:}
\endgroup
% just for showing things are working as expected:
a \c_colon_active_tl {} ~ vs~ a:
\ExplSyntaxOff
\end{document}
답변1
닭이 먼저냐 달걀이 먼저냐의 문제는 다음의 \lowercase
트릭으로 해결할 수 있습니다:
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\group_begin:
\char_set_catcode_active:N \^^@
\char_set_lccode:nn { `^^@ } { `: }
\tl_to_lowercase:n { \group_end:
\tl_const:Nn \c_colon_active_tl { ^^@ }
}
\tl_show_analysis:N \c_colon_active_tl
출력은 다음과 같습니다
The token list \c_colon_active_tl contains the tokens:
> : (active character=undefined).
(TeX Live 2017 이전 릴리스의 경우 이 기능이 작동하려면 \usepackage{l3tl-analysis}
추가가 필요합니다 .)\usepackage{xparse}
업데이트 2020
이제 동일한 작업을 수행하는 훨씬 더 좋은 방법이 있습니다(단, 위의 코드는 최근 expl3
커널에서는 실행되지 않습니다).
\documentclass{article}
\usepackage{xparse}
\ExplSyntaxOn
\group_begin:
\char_set_active_eq:nN { `: } \scan_stop:
\tl_const:Nx \c_colon_active_tl { \char_generate:nn { `: } { 13 } }
\group_end:
\tl_analysis_show:N \c_colon_active_tl
이것은 보여줍니다
The token list \c_colon_active_tl contains the tokens:
> : (active character=undefined).
그러나 활성 콜론의 의미를 정의할 때 \c_colon_active_tl
활성 문자는 매크로이기 때문에 사용은 이를 사용합니다. \scan_stop:
(즉, ) 은 \relax
생성된 활성결장의 확장을 방지하기 위해 사용됩니다.