测试类“llncs”

测试类“llncs”

显然llncs.cls与(证明已定义)冲突amsthm,所以我尝试测试该类是否已加载。建议的代码基于其中引用的问题。它确实检查article正确(如果proof注释掉),但不是llncs。有什么建议吗?

%\documentclass{article}
\documentclass{<path>/llncs}
\usepackage{xparse}

% https://tex.stackexchange.com/a/43568/112708
% http://texdoc.net/texmf-dist/doc/latex/base/source2e.pdf

\makeatletter
\@ifclassloaded{llncs}
{
  \edef\ClassloadedisI{llncs}
}
{
  \edef\ClassloadedisI{other~than~llncs}
  %\usepackage{amsthm}
}
\makeatother

\ExplSyntaxOn
\seq_new:N \l_pclist_classes_seq
\seq_new:N \l_pclist_packages_seq
\seq_new:N \l_pclist_other_seq
\clist_map_inline:cn { @filelist }
{
  \tl_if_in:nnTF { #1 } { .cls }
  {
    \tl_set:Nn \l_tmpa_tl { #1 }
    \tl_remove_once:Nn \l_tmpa_tl { .cls }
    \seq_put_right:NV \l_pclist_classes_seq \l_tmpa_tl
  }
  {
    \tl_if_in:nnTF { #1 } { .sty }
    {
      \tl_set:Nn \l_tmpa_tl { #1 }
      \tl_remove_once:Nn \l_tmpa_tl { .sty }
      \seq_put_right:NV \l_pclist_packages_seq \l_tmpa_tl
    }
    {
      \seq_put_right:Nn \l_pclist_other_seq { #1 }
    }
  }
}
\seq_if_in:NnTF \l_pclist_classes_seq { llncs }
{ \def\ClassloadedisII{llncs} }
{
  \def\ClassloadedisII{other~than~llncs}
    %\usepackage{amsthm}
}
\seq_log:N \l_pclist_classes_seq % Document Class: llncs 2018/03/10 v2.20 
%\seq_show:N \l_pclist_packages_seq
%\seq_show:N \l_pclist_other_seq
\ExplSyntaxOff

\begin{document}

This document uses class
\begin{enumerate}
\item \ClassloadedisI. 
\item \ClassloadedisII.
\end{enumerate}  

\begin{proof}is in the pudding\end{proof}

\end{document}

答案1

你必须剥去这条路。

\documentclass{../mar2018/llncs2018/llncs}
%\documentclass{article}
\usepackage{xparse}

\ExplSyntaxOn
\seq_new:N \l_pclist_classes_seq
\seq_new:N \l_pclist_packages_seq
\seq_new:N \l_pclist_other_seq
\clist_map_inline:cn { @filelist }
{
  \tl_if_in:nnTF { #1 } { .cls }
  {
    \tl_set:Nn \l_tmpa_tl { #1 }
    \tl_remove_once:Nn \l_tmpa_tl { .cls }
    \seq_set_split:NnV \l_tmpa_seq { / } \l_tmpa_tl
    \seq_put_right:Nx \l_pclist_classes_seq { \seq_item:Nn \l_tmpa_seq { -1 } }
  }
  {
    \tl_if_in:nnTF { #1 } { .sty }
    {
      \tl_set:Nn \l_tmpa_tl { #1 }
      \tl_remove_once:Nn \l_tmpa_tl { .sty }
      \seq_put_right:NV \l_pclist_packages_seq \l_tmpa_tl
    }
    {
      \seq_put_right:Nn \l_pclist_other_seq { #1 }
    }
  }
}
\seq_if_in:NnTF \l_pclist_classes_seq { llncs }
 { \tl_set:Nn \Classloadedis {llncs} }
 {
   \tl_set:Nn \Classloadedis {other~than~llncs}
   \usepackage{amsthm}
 }
%\seq_show:N \l_pclist_classes_seq % Document Class: llncs 2018/03/10 v2.20 
%\seq_show:N \l_pclist_packages_seq
%\seq_show:N \l_pclist_other_seq
\ExplSyntaxOff

\begin{document}

This document uses class \Classloadedis.


\begin{proof}is in the pudding\end{proof}

\end{document}

相关内容