TransWikia.com

How do I repeat a theorem number with the llncs class?

TeX - LaTeX Asked on July 16, 2021

I am writing an article with the llncs class, and I am trying to repeat a theorem twice in different sections.

For example,

Section 1

Theorem 1.1. Let

And then later in the paper I want to recall the theorem by reprinting it

Section 4

We recall Theorem 1.1:

Theorem 1.1. Let

I used the solutions proposed in [1,2,3,4,5], and they seemed to clash and do not work with the llncs class.
Is there any way to use these solutions with respect to the llncs class?

[1]-How do I repeat a theorem number?

[2]-Using LaTeX, how can I restate a theorem, with the same theorem number, later in a paper?

[3]-Recalling a theorem

[4]-Repeat a Theorem

[5]- How to automatically repeat all the theorems?

One Answer

The llncs class uses a different way of defining theorem-like environments, so it's not a surprise that the other suggested methods don't work. Neither amsthm nor ntheorem based solution can work.

Here I assume the theorem to repeat precedes the repetition. I define a new environment reptheorem that stores the text; it has a mandatory argument that also sets a label with the same name.

In the example I also show that the optional argument is honored.

documentclass[envcountsect]{llncs}
usepackage{environ}

newcommand{repeattheorem}[1]{%
  begingroup
  renewcommand{thetheorem}{ref{#1}}%
  expandafterexpandafterexpandaftertheorem
  csname reptheorem@#1endcsname
  endtheorem
  endgroup
}

NewEnviron{reptheorem}[1]{%
  globalexpandafterxdefcsname reptheorem@#1endcsname{%
    unexpandedexpandafter{BODY}%
  }%
  expandaftertheoremBODYunskiplabel{#1}endtheorem
}

begin{document}

section{Title}

begin{reptheorem}{foo}[Somebody]
Let $x$ be a foo. Then $x$ is also a baz.
end{reptheorem}

section{Another}

repeattheorem{foo}

end{document}

enter image description here

A feature asked in comments prompted to write “more modern code” for the job.

documentclass[envcountsect]{llncs}
usepackage{amsmath}

newcommand{replabel}{label} % will be redefined in restatements

ExplSyntaxOn

NewDocumentCommand{repeattheorem}{m}
 {
  group_begin:
  renewcommand{thetheorem}{ref{#1}}
  renewcommand{replabel}[1]{tag{ref{##1}}}
  prop_item:Nn g_reptheorem_prop { #1 }
  endtheorem
  group_end:
 }

NewDocumentEnvironment{reptheorem}{m+b}
 {
  prop_gput:Nnn g_reptheorem_prop { #1 } { theorem #2 endtheorem }
  theorem#2unskiplabel{#1}endtheorem
 }{}

prop_new:N g_reptheorem_prop

ExplSyntaxOff

begin{document}

section{Title}

begin{reptheorem}{foo}[Somebody]
Let $x$ be a foo. Then $x$ is also a baz.
begin{equation}replabel{fooeq}
1=1
end{equation}
with an equation.
end{reptheorem}

section{Another}

repeattheorem{foo}

end{document}

In theorems to be repeated, labels to equations (mandatory) should be set with replabel. This way we can change the meaning to use tag instead. The label command cannot be used, because amsmath (necessary for tag) would change back the meaning of label in a display.

enter image description here

Correct answer by egreg on July 16, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP