是否有与之等效的 LaTeX3 版本\@ifpackageloaded
?
答案1
没有。但你可以轻松构建它。
\prg_new_conditional:Nnn \mhchem_package_if_loaded:n { p, T, F , TF }
{
\use:c { @ifpackageloaded } { #1 } { \prg_return_true: } { \prg_return_false: }
}
这将定义条件
\mhchem_package_if_loaded:nTF
\mhchem_package_if_loaded:nT
\mhchem_package_if_loaded:nF
和谓语形式
\mhchem_package_if_loaded_p:n
用于布尔表达式。
一个测试:
\documentclass{article}
\usepackage{expl3}
\ExplSyntaxOn
\prg_new_conditional:Nnn \mhchem_package_if_loaded:n { p, T, F , TF }
{
\use:c { @ifpackageloaded } { #1 } { \prg_return_true: } { \prg_return_false: }
}
% now let's test it
\mhchem_package_if_loaded:nTF { expl3 }
{ \typeout{Yes~expl3} }
{ \typeout{No~expl3} }
\mhchem_package_if_loaded:nT { expl3 }
{ \typeout{Yes~expl3} }
\mhchem_package_if_loaded:nTF { kantlipsum }
{ \typeout{Yes~kantlipsum} }
{ \typeout{No~kantlipsum} }
\mhchem_package_if_loaded:nF { kantlipsum }
{ \typeout{No~kantlipsum} }
\bool_if:nTF
{
\mhchem_package_if_loaded_p:n {expl3}
||
\mhchem_package_if_loaded_p:n {kantlipsum}
}
{ \typeout{Yes~expl3~or~kantlipsum} }
{ \typeout{No~expl3~or~kantlipsum} }
\bool_if:nTF
{
\mhchem_package_if_loaded_p:n {expl3}
&&
\mhchem_package_if_loaded_p:n {kantlipsum}
}
{ \typeout{Yes~expl3~and~kantlipsum} }
{ \typeout{No~expl3~and~kantlipsum} }
\stop
相关控制台输出:
Yes expl3
Yes expl3
No kantlipsum
No kantlipsum
Yes expl3 or kantlipsum
No expl3 and kantlipsum