I am trying to create a customized "proof" environment attached to a theorem. It looks like this:
So there is first the theorem, and then a gray bar starts on the inner margin. It ends, when the proof of the theorem is finished. It should also be possible to give a theorem without proof of cause.
The document you see above was created from the following code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% HEADER
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,twoside,11pt]{article}
\special{papersize=210mm,297mm}
%% Language %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[USenglish]{babel}
\usepackage[T1]{fontenc}
\usepackage[ansinew]{inputenc}
\usepackage{lmodern} % Type1-font for non-english texts and characters
%% Math Symbols %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
%% Other Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{color} % colors
\usepackage{framed} % frames
\usepackage{mdframed} % better frames
\usepackage{fancyhdr} % Fancy headings
%% Style Definitions %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\numberwithin{equation}{section}
% My Theorem Style ============================================================
\newtheoremstyle{myThmStyle}% name of the theorem
{6pt}% habovespacei
{6pt}% hbelowspacei
{\itshape}% font
{}% hindenti
{}% hheadfonti
{}% hheadpuncti
{ }% hheadspacei
{\thmname{\normalfont\large\textsc{#1}\normalsize} \thmnote{#3:} \thmnumber{ \hfill \normalfont(#2)}\\[1pt]}
% Frame Styles ================================================================
\definecolor{thmBgColor}{RGB}{250,250,250}
\definecolor{thmLnColor}{RGB}{200,200,200}
\mdfdefinestyle{MDFStyGrayScreen}{%
linecolor=thmLnColor,
backgroundcolor=thmBgColor,
linewidth=1pt,
topline=true,
bottomline=true,
rightline=false,
leftline=false,
outerlinewidth=2pt,
roundcorner=0pt,
innertopmargin=4pt, %\baselineskip
innerbottommargin=4pt, %\baselineskip,
innerrightmargin=3pt,
innerleftmargin=3pt,
skipabove=\topskip,
skipbelow=\topskip,
nobreak=true
}
% Thorems =====================================================================
\theoremstyle{myThmStyle}
\newtheorem{myTheorem}[equation]{theorem}
% Proof environment ===========================================================
% (attached to theorem)
\newenvironment{myTheoremEnvEx}[1][\hsize]
{%
\def\FrameCommand
{%
{\color{thmLnColor}\vrule width 8pt}%
\hspace{0pt}%must no space.
\fboxsep=5pt\colorbox{white}%
}%
\vspace{-\topskip}
\vspace{-\topskip}
\vspace{-1pt}
\MakeFramed{\hsize#1\advance\hsize-\width\noindent\FrameRestore}%
}
{\endMakeFramed}
\setlength{\FrameSep}{0pt}
% Theorem environment =========================================================
\newenvironment{theorem}[1]
{
\begin{mdframed}[style=MDFStyGrayScreen]
\begin{myTheorem}#1
}
{
\end{myTheorem}
\end{mdframed}
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DOCUMENT
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
\section{Section A}
\label{sec:SectionA}
\begin{theorem}[about something important] \label{thm:important}
This is some important theorem with equations
\[
1 + 1 = 0 \;,
\]
and text.
\end{theorem}
Some text with reference to theorem \eqref{thm:important}.
\begin{theorem}[about something important] \label{thm:veryImportant}
This is some important theorem with equations
\[
1 + 1 = 0 \;,
\]
and text.
\end{theorem}%
\begin{myTheoremEnvEx}
Proof of something important... The proof may exceed several pages. The proof may exceed several pages. The proof may exceed several pages.
The proof may exceed several pages. The proof may exceed several pages. The proof may exceed several pages.
\end{myTheoremEnvEx}
\end{document}
There are two things that do not work yet:
- When the text within the proof exceeds one page, then there appears a small gap between theorem and proof.
- The gray bar of the proof is currently always on the left side. But I want it to be on the inner margin (left for right pages and right for left pages).
The first problem is certainly due to my dirty bugfix
\vspace{-\topskip}
\vspace{-\topskip}
\vspace{-1pt}
within \newenvironment{myTheoremEnvEx}[1][\hsize]
.
Can you help me with this? I'd also be happy to see better solutions.
Best Answer
This is somewhat of an old question but I was interested in how to put a line down the margin, where the side changes depending on the parity of the page number.
Rather than using the mdfamed package I have used tcolorbox as I am more used to using it. For answer this question, tcolorbox has one particularly useful switch,
toggle left and right
, that can be used to swap the role of left and right in various instances. This is what is used to address point #2 in the OPs question.Apart from this it is fairly straightforward except for the creation of a new theorem "style" for use by
\newtcbtheorem
to cater for the particular style required by the question. This is done by the linewith the associated macro
\tcb@theo@widetitle
doing the actual work. This the outputfrom the following code (updated for
tcolorbox
version 1.14, withbreakable
added to the theorem style to allow it also to break over pages)