5

I'm trying to restate/repeat/recall an algorithm in an appendix with the same numbering, etc., but I haven't found an easy way to do it. I'm using the algorithm environment and algorithm2e package.

Ideally, I want something like the restatable environment in the thmtools package, but for algorithms instead of theorems. The answer here illustrates this with lemmas. Does this or something like it exist?

Edit: Here is a MWE using restatable:

\begin{restatable}{algorithm}{solver}  
\caption{Problem Solver}

Solve problem.

\end{restatable}

\appendix  
\section*{Appendix}

\solver*

This gives something like:

Algorithm 1: Problem Solver

1 Solve problem.

Appendix

Algorithm 2: Problem Solver

1 Solve problem.

However, I would like both to say "Algorithm 1".

BambOo
  • 8,801
  • 2
  • 20
  • 47
  • How many are we talking? If < 200, you could store them all in saveboxes. – John Kormylo Jul 11 '16 at 13:29
  • Haven't tried this. Can you simply put your algorithm environment inside a restatable theorem environment? – Ethan Bolker Jul 11 '16 at 13:50
  • @JohnKormylo Algorithm doesn't seem to work with saveboxes. I get "not in outer par mode" error which I assume is because algorithm is a floating environment. – user109801 Jul 13 '16 at 18:15
  • 1
    @EthanBolker This almost works just writing "\begin{restatable}{algorithm}{algname}". However, using "\algname" to restate assigns a new number to the restated algorithm (even using and compiling multiple times). – user109801 Jul 13 '16 at 18:21
  • You can use a minipage inside a savebox, or use \setbox\mysavebox=\vbox{...}. An MWE would be useful here. – John Kormylo Jul 13 '16 at 21:32
  • Any updates on this demand ? Did you manage to find a solution yourself ? – BambOo Jun 07 '20 at 14:58
  • See my answer here: https://tex.stackexchange.com/q/690161/208544 – mbert Aug 28 '23 at 16:14

0 Answers0