3

I find the \newtheoremstyle of amsthm very handy. As far as I know, LNCS class have only \spnewtheorem which allows to change only the head font and the body font. In contrast, \newtheoremstyle allows to change more (e.g.: puncuation after theorem head, amount of space before/after the theorem environment).
Is there an LNCS class command that gives more control similar to \newtheoremstyle of amsthm?

Here is an mwe.

  \documentclass{llncs}
  \spnewtheorem{mytheorem}{Theorem}{\bfseries}{}

  %\documentclass{article}
  %\usepackage{amsthm}
  %\newtheorem{theorem}{Theorem}
  %\newtheoremstyle{freethm}% <name>
  %{3pt}% <Space above>
  %{3pt}% <Space below>
  %{}% <Body font>
  %{}% <Indent amount>
  %{\bfseries}% <Theorem head font>
  %{}% <Punctuation after theorem head>
  %{.5em}% <Space after theorem headi>
  %%{\bfseries}% <Theorem head spec (can be left empty, meaning `normal')>
  %{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}.\\}
  %\theoremstyle{freethm}
  %\newtheorem{mytheorem2}{Theorem}

  \begin{document}
  \begin{theorem}[LNCS/asmthm style]
  A nice theorem.
  \end{theorem}
  \begin{mytheorem}[LNCS spnewtheorem]
  Another nice theorem.
  \end{mytheorem}
  %\begin{mytheorem2}[amsthm newtheoremstyle]
  %Another nice theorem.
  %\end{mytheorem2}
  \end{document}

This gives the following output:
enter image description here

When I uncomment the line \usepackage{amsthm}, I get the error "Command \proof already defined.". I suppose this is because llncs.sty includes and redefines many theorem environments (and also proof environment) of amsthm. Anyway, it seems possible to ignore this error. But, when the \newtheoremstyle command is uncommented, I get error that are impossible to ignore.

5
  • is there some reason you can't use amsthm with that class? Commented Aug 16, 2021 at 8:16
  • @DavidCarlisle My understanding is that llncs.sty redefines theorem environment of amsthm. So, I don't know a way to use amthm with that class. If you can point out a way to do this, that will be a perfect answer. Commented Aug 17, 2021 at 2:44
  • I don't have the class and you provided no link and no test document. If you provided a small test document using amsthm with llncs.cls and said what error you got, someone could debug. Commented Aug 17, 2021 at 8:00
  • @DavidCarlisle, Sure. Please see the updated question (mwe added). Commented Aug 17, 2021 at 9:45
  • if I uncomment your newtheoremstyle I get ! You can't use `macro parameter character #' in vertical mode. even in article class, without using llncs at all Commented Aug 17, 2021 at 9:57

2 Answers 2

2

You may use amsthm, provided you remove the proof environment as defined by the document class.

\documentclass[runningheads]{llncs}
\usepackage[T1]{fontenc}

\let\proof\relax\let\endproof\relax
\usepackage{amsthm}

\newtheoremstyle{freethm}% <name>
 {3pt}% <Space above>
 {3pt}% <Space below>
 {\itshape}% <Body font>
 {}% <Indent amount>
 {\bfseries}% <Theorem head font>
 {}% <Punctuation after theorem head>
 {\newline}% <Space after theorem headi>
 {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}.} % Head spec

\theoremstyle{freethm}
\newtheorem{mytheorem}{Theorem}



\begin{document}

\title{Contribution Title\thanks{Supported by organization x.}}

\author{First Author}

\authorrunning{F. Author}

\institute{Some University, Someplace\\\email{[email protected]}}

\maketitle

\begin{abstract}
The abstract should briefly summarize the contents of the paper in
150--250 words.

\keywords{First keyword  \and Second keyword \and Another keyword.}
\end{abstract}

\section{First Section}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\begin{theorem}[Standard]
This is a theorem in the standard style.
\end{theorem}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\begin{mytheorem}[Free]
This is a theorem in the free style.
\end{mytheorem}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\end{document}

enter image description here

If you want to preserve the proof environment as defined by the class, you can do as follows:

\documentclass[runningheads]{llncs}
\usepackage[T1]{fontenc}

% save the proof environment defined by the class
\let\lncsproof\proof \let\lncsendproof\endproof \let\lncsqed\qed
% remove the definitions in order to load amsthm
\let\proof\relax\let\endproof\relax

\usepackage{amsthm}

% restore the class defined proof
\let\proof\lncsproof \let\endproof\lncsendproof \let\qed\lncsqed

\newtheoremstyle{freethm}% <name>
 {3pt}% <Space above>
 {3pt}% <Space below>
 {\itshape}% <Body font>
 {}% <Indent amount>
 {\bfseries}% <Theorem head font>
 {}% <Punctuation after theorem head>
 {\newline}% <Space after theorem headi>
 {\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}.}

\theoremstyle{freethm}
\newtheorem{mytheorem}{Theorem}



\begin{document}

\title{Contribution Title\thanks{Supported by organization x.}}

\author{First Author}

\authorrunning{F. Author}

\institute{Some University, Someplace\\\email{[email protected]}}

\maketitle

\begin{abstract}
The abstract should briefly summarize the contents of the paper in
150--250 words.

\keywords{First keyword  \and Second keyword \and Another keyword.}
\end{abstract}

\section{First Section}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\begin{theorem}[Standard]
This is a theorem in the standard style.
\end{theorem}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\begin{mytheorem}[Free]
This is a theorem in the free style.
\end{mytheorem}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\begin{proof}
This is a proof in the standard style.\qed
\end{proof}

Please note that the first paragraph of a section or subsection is
not indented. The first paragraph that follows a table, figure,
equation etc. does not need an indent, either.

\end{document}

enter image description here

On the other hand, if you don't restore and remove the \qed at the end of the proof, you get

enter image description here

which seems much alike the other picture (and is easier to maintain because you don't need to manually add \qed).

3
  • Isn't \let\proof\relax\let\endproof\relax relaxing the proof environment defined by llncs? I suppose this is not acceptable when explicitly asked to write with the llncs class (isn't it?). Anyway, your solution works. Commented Aug 17, 2021 at 10:34
  • @CyriacAntony I added how to restore the original proof environment (although I don't think it's necessary, read the comments).
    – egreg
    Commented Aug 17, 2021 at 10:45
  • Great. Thank you. Commented Aug 17, 2021 at 10:52
0

Your \newtheoremstyle declaration gives errors even if used with article class. There appears to be a spurious final line using # that has been copied from a \newcommand or similar construct.

If I fix that, then the code works unchanges with a copy of llncs that I found at

https://www.win.tue.nl/~setalle/tex/llncs.cls

if you ndefine the proof environment to let amsthm define it.

%\documentclass{article}
\documentclass{llncs}

\let\proof\undefined
\let\endproof\undefined
\usepackage{amsthm}

 % \spnewtheorem{mytheorem}{Theorem}{\bfseries}{}

\newtheoremstyle{mytheorem}% <name>
{3pt}% <Space above>
{3pt}% <Space below>
{}% <Body font>
{}% <Indent amount>
{\bfseries}% <Theorem head font>
{}% <Punctuation after theorem head>
{.5em}% <Space after theorem headi>
{\bfseries}% <Theorem head spec (can be left empty, meaning `normal')>


%??????{\thmname{#1}\thmnumber{ #2}\thmnote{ (#3)}.\\}

\newtheorem{ztheorem}{theorem}

  \begin{document}
 
  \begin{ztheorem}[LNCS spnewtheorem]
  Another nice theorem.
  \end{ztheorem}
  \end{document}
2
  • Please see the modified question. Code needed for amsthm is added (but commented out). The code runs perfectly when the lines for LNCS are commented out and lines for amsthm are uncommented. Commented Aug 17, 2021 at 10:11
  • 1
    The line marked with “theorem head spec” is wrong; the ninth argument to \newtheoremstyle should either be empty or contain something like in the next line with \thmname, \themnumber and \thmnote.
    – egreg
    Commented Aug 17, 2021 at 10:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .