3

I want to use the restatable package with a custom environment. It almost works except when I restate with \name* it does not use the original label.

Before you ask, I'm not using newtheorem because its formatting doesn't agree with me needs and using amsthm, to my dismay, is not an option.

Here's a minimal example:

\documentclass{article} \usepackage{thmtools} \newcounter{main} \newcommand{\envheader}[2]{% \refstepcounter{main}\par\smallskip \textbf{{#2}~\thesection.\themain.} \if\relax\detokenize{#1}\relax\else{({#1})}\fi %% Name of the theorem } \newenvironment{theorem}[1][]{\envheader{#1}{Theorem}\itshape\/}{\smallskip} \newenvironment{lemma}[1][]{\envheader{#1}{Lemma}\itshape\/}{\smallskip} \begin{document} \begin{restatable}{theorem}{mytheorem}\label{thm:mytheorem} How you doin'? \end{restatable} \mytheorem* \end{document} 

Here's what I get:

Minimal example output

0

1 Answer 1

4
+50

restatable expects that the internal counter has the same name as the environment, so you should use theorem instead of main. Side remark: your definition will not prevent page breaks between the theorem title and the body.

\documentclass{article} \usepackage{thmtools} \newcounter{theorem} \newcommand{\envheader}[2]{% \refstepcounter{theorem}\par\smallskip \textbf{{#2}~\thesection.\thetheorem.} \if\relax\detokenize{#1}\relax\else{({#1})}\fi %% Name of the theorem } \newenvironment{theorem}[1][]{\envheader{#1}{Theorem}\itshape\/}{\smallskip} \newenvironment{lemma}[1][]{\envheader{#1}{Lemma}\itshape\/}{\smallskip} \begin{document} \begin{restatable}{theorem}{mytheorem}\label{thm:mytheorem} How you doin'? \end{restatable} \mytheorem* \end{document} 

enter image description here

3
  • 1
    That works but I'd like to use the same counter for theorem and lemma. I tried to create a theorem counter and do \setcounter{theorem}{\value{main}}, in the environment definition, but it doesn't seem to work... Commented Apr 19, 2019 at 18:16
  • That's a new question so better ask a new question. Commented Apr 19, 2019 at 18:57
  • I'd say it's a related question that's definitely implied by my example. Commented Apr 19, 2019 at 18:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.