Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to create a customized "proof" environment attached to a theorem. It looks like this: What it should look like.

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:

  1. When the text within the proof exceeds one page, then there appears a small gap between theorem and proof.
  2. 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.

share|improve this question
    
You can do this very simple by defining a single command which ends up the first framed environment and start the next one. –  Marco Daniel Jun 27 '13 at 16:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.