2

Apparently llncs.cls conflicts with amsthm (proof already defined), so I'm trying to test for whether that class is loaded. The proposed code is based on the question cited within. It does check article correctly (if proof commented out), but not llncs. Any suggestion?

%\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

You have to strip off the path.

\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}
| improve this answer | |
  • This solution seems to require that llncs.cls can be found using $PATH. Specifying \l_pclist_classes_seq {<path>/llncs} also works in my case. Helpless trying to work with the alternative case (condition on article, not llncs). PS: I couldn't get the \makeatletter+\proof\relax version to work. – Erwann Apr 12 at 23:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.