I'm a fan of python, and in the sadly common case where one creates new theorems, definitions, etc within the actual proofs of other theorems, I would like the "inner theorems" to be indented.
To this end, I've discovered this solution, which provides a frame as well as indenting it. However, that solution frames/indents everything, even base level theorems, which ended up being sort of ugly. Is there a way to make it frame/indent only when you're nesting it in another proof, short of defining separate environments and doing it manually?
Not sure if it's important, but in case it is, my current setup is:
\usepackage[amsmath,thmmarks,framed]{ntheorem}
\theorembodyfont{\small}
\usepackage{framed}
\usepackage{color}
\definecolor{gray}{rgb}{0.6,0.6,0.6}
\renewcommand*\FrameCommand{{\color{gray}\vrule width 5pt \hspace{10pt}}}
\theoremstyle{plain}
\newframedtheorem{thm}{Theorem}[page]
\newframedtheorem{lem}[thm]{Lemma}
\newframedtheorem{cor}[thm]{Corollary}
\newframedtheorem{prop}[thm]{Proposition}
\theoremheaderfont{\normalfont\itshape}
\newframedtheorem{rem}[thm]{Remark}
\newframedtheorem{ques}[thm]{Question}
\theoremstyle{nonumberplain}
\theoremheaderfont{\normalfont\itshape}
\newframedtheorem{proof}{Proof:}
Edit: my end solution was an lualatex modification of stuff posted in the checkmarked answer. Because he edited it out, I'll vaguely requote the general idea here:
Define two versions of your environments,
thm
andfrthm
, and within theproof
definition, redefine\thm
to\frthm
and\endthm
toendfrthm
. This is not as nice a solution as the previous one, but it will technically work.
This is a MWE of that idea, written in lualatex for automation ( you'll have to modify the tex.print
itself to change implementation-specific details like defining \newtheorem
differently).
\documentclass[11pt,openany]{memoir}
\usepackage{cool}
\usepackage{luacode}
\usepackage{etoolbox}
\usepackage[amsmath,thmmarks,framed]{ntheorem}
\usepackage{framed}
\usepackage{color}
\definecolor{gray}{rgb}{0.6,0.6,0.6}
\begin{luacode}
prefix = "fr"
function createEnvironments(environs)
for sh, lo in pairs(environs) do
tex.print("\\newtheorem{" .. sh .. "}{" .. lo .. "}")
tex.print("\\newframedtheorem{" .. prefix .. sh .. "}{" .. lo .. "}")
end
end
function redefineEnvironments(environs)
for sh, lo in pairs(environs) do
tex.print("\\def\\" .. sh .. "{\\" .. prefix .. sh .. "}" )
tex.print("\\def\\end" .. sh .. "{\\end" .. prefix .. sh .. "}")
end
end
\end{luacode}
\begin{luacode}
--your list of shortcut="Environment"; fill in this table!
environList = { lem="Lemma" , prop="Proposition",proof="Proof"}
createEnvironments(environList)
\end{luacode}
\renewcommand*\FrameCommand{{\color{gray}\vrule width 5pt \hspace{10pt}}}
\appto\proof{% ... within the proof environment, we redefine the commands to point to the framed environments
\directlua{redefineEnvironments(environList)}
}
\begin{document}
\begin{lem}
Layer 1
\end{lem}
\begin{proof}
Layer 0 stuff
\begin{prop}
Layer 1 starts getting embedded
\begin{lem}
This is an artefact: once you get into the first proof you start nesting no matter what
\end{lem}
\end{prop}
Layer 0 stuff
\begin{lem}
Another layer 1
\end{lem}
Can put layer 0 stuff here
\begin{proof}
Layer 1 proof
\begin{prop}
Layer 2
\end{prop}
\begin{proof}
We conclude with a layer 2 proof
\end{proof}
\end{proof}
\end{proof}
\end{document}
Explanation: I realized that making every theorem a framedtheorem had bad typesetting side-effects. This new version creates both and redefines the former to the latter within the proof
environment, where nesting is both likely to occur. Of course, you can do the same within any other environment.