0

I don't understand why the following code fails with the error

ERROR: File ended while scanning use of \thmt@collect@body.

Indeed when I define

before upper={\begin{thm}[my title]}

it works, but when I use

before upper={\begin{restatable}[my title]{thm}{myrestatecommand}}

it fails, while the code should be equivalent. Any idea why?

MWE:

\documentclass{article}

\usepackage{mathtools}
\usepackage{amssymb, amsthm, amsmath, thm-restate}
\usepackage{thmtools} %%
\usepackage{hyperref}

\newtheorem{thm}{Theorem}[section]
\providecommand*\thmautorefname{Theorem}
\newtheorem{corollary}[thm]{Corollary}
\providecommand*\corollaryautorefname{Corollary}
\newtheorem{lemma}[thm]{Lemma}
\providecommand*\lemmaautorefname{Lemma}

\usepackage{lipsum}
\usepackage[most]{tcolorbox}

% Works:
\NewTColorBox[auto counter, number within=section]{theorem}{}{ %
    blank,
    breakable,
    before upper={\begin{thm}[my title]},
      after upper={\end{thm}},
}

% Fails:
\NewTColorBox[auto counter, number within=section]{theoremRestate}{}{ %
    blank,
    breakable,
    before upper={\begin{restatable}[my title]{thm}{myrestatecommand}},
      after upper={\end{restatable}},
}

\begin{document}

%% Works:
\begin{restatable}[my title]{thm}{myrestatecommanda}
  This theorem works
\end{restatable}

%% Works:
%% Does not work:
\begin{theorem}
  This theorem does not work
\end{theorem}

%% Does not work:
\begin{theoremRestate}
  This theorem does not work
\end{theoremRestate}

\end{document}
3
  • Actually, theorem doesn't really work for me either, at least it doesn't generate a tcolorbox. You could just create a new environment which uses tcolorbox. Commented Apr 11, 2019 at 16:32
  • @JohnKormylo Well what's the fundamental difference between restatable and thm? And I really want to be able to restate theorems, so I don't see how tcolorbox can do that for me.
    – tobiasBora
    Commented Apr 11, 2019 at 16:37
  • It appears that restateable is based on \NewEnviron while thm is based on \newenvironment. IIRC, you cannot nest Environs. You might be able to get it to work using a savebox. Commented Apr 11, 2019 at 16:52

1 Answer 1

3

If your goal is just to restate tcolorbox theorems, this is possible with keytheorems (disclaimer, I wrote the package).

\documentclass{article}

\usepackage{mathtools}
\usepackage{amssymb}
\usepackage{keytheorems}
\usepackage{kantlipsum}
\usepackage[most]{tcolorbox}
\usepackage{hyperref}

\newkeytheorem{thm}[
  name=Theorem,
  parent=section,
  tcolorbox-no-titlebar={
    breakable,
    %<other options>,
    }
  ]
\newkeytheorem{lemma}[
  sibling=thm,
  tcolorbox={
    breakable,
    %<other options>,
    }
  ]

\begin{document}

\begin{thm}[store=my:thm]
\kant[1-2]
\end{thm}

\begin{lemma}
\kant[3-4]
\end{lemma}

\getkeytheorem{my:thm}

\end{document}

First page

first page

Second page

second page

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.