如何创建附加在定理上的框架证明?

如何创建附加在定理上的框架证明?

我正在尝试创建一个附加到定理的自定义“证明”环境。它看起来像这样: 它看起来应该是什么样子。

因此,首先是定理,然后内边距开始出现灰色条。当定理证明完成后,灰色条结束。也应该有可能在不证明原因的情况下给出定理。

您上面看到的文档是根据以下代码创建的:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% 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}

有两件事还没有起作用:

  1. 当证明中的文本超过一页时,定理和证明之间就会出现一个小的间隙。
  2. 目前校样的灰色条总是位于左侧。但我希望它位于内边距(右页为左侧,左页为右侧)。

第一个问题肯定是由于我的错误修复不当造成的

\vspace{-\topskip}
\vspace{-\topskip}
\vspace{-1pt}

之内\newenvironment{myTheoremEnvEx}[1][\hsize]

你能帮我吗?我也很高兴看到更好的解决方案。

答案1

这是一个有点老的问题,但我感兴趣的是如何在页边距上放一条线,该线的边会根据页码的奇偶校验而变化。

而不是使用mdfamed 包我用过彩色盒子因为我更习惯使用它。为了回答这个问题,彩色盒子有一个特别有用的开关,toggle left and right,可用于在各种情况下交换左和右的角色。这就是用来解决 OP 问题中的第 2 点的。

除此之外,除了创建新的定理“样式”以\newtcbtheorem满足问题所需的特定样式外,它相当简单。这是通过以下行完成的

\tcbset{theorem style/theorem wide name and number/.code={
                \let\tcb@theo@title=\tcb@theo@widetitle}
}

相关的宏\tcb@theo@widetitle负责实际工作。这是输出

示例输出

来自以下代码(已更新至tcolorbox1.14 版,并breakable添加了定理样式以允许其跨页)

\documentclass[a4paper,twoside,11pt]{article}

\usepackage{amsmath,amsthm,amsfonts}
\usepackage{lipsum}

%% Other Packages %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,theorems}
\usepackage{changepage}% for use of \ifoddpage below

% Theorems ==============
\definecolor{thmBgColor}{RGB}{250,250,250}
\definecolor{thmLnColor}{RGB}{200,200,200}

\makeatletter
% define a new theorem style
\def\tcb@theo@widetitle#1#2#3{\hbox to \textwidth{\textsc{\large#1}\normalsize\space#3\hfil(#2)}}
\tcbset{
  theorem style/theorem wide name and number/.code={ \let\tcb@theo@title=\tcb@theo@widetitle},
  proofbox/.style={skin=enhancedmiddle,breakable,parbox=false,boxrule=0mm,
    check odd page, toggle left and right, colframe=thmLnColor,
    leftrule=8pt, rightrule=0mm, boxsep=0mm,arc=0mm, outer arc=0mm,
    left=3mm,right=0mm,top=0mm,bottom=0mm, toptitle=0mm,
    bottomtitle=0mm,colback=white,
    before={\par\vskip-2pt},after={\par\smallbreak},
  },
}
\newtcolorbox{ProofBox}{proofbox}
\makeatother

\newtcbtheorem[use counter=equation, number within=section]{mytheorem}{Theorem}%
  {theorem style=theorem wide name and number,enhanced,breakable,
  arc=0mm,outer arc=0mm,parbox=false,
  boxrule=0mm,toprule=2pt,bottomrule=2pt,left=1mm,right=1mm,
  titlerule=0mm,toptitle=0mm,bottomtitle=0mm,top=0mm,
  colback=thmBgColor,colframe=thmLnColor,
  title style={color=thmBgColor}, coltitle=black,
  attach title to upper={\par\noindent},
  before={\par\vfill\smallbreak\noindent}, after={\par},
  fonttitle=\normalfont\large,
  }{thm}

\newenvironment{theorem}[2][]{\noindent\mytheorem{#1}{#2}}{\endmytheorem}

\let\realproof\proof
\let\realendproof\endproof
\renewenvironment{proof}[1][Proof]{\ProofBox\strut\textsc{#1}\space}{\endProofBox}

%% Style Definitions
\numberwithin{equation}{section}

\begin{document}
\quad\clearpage % to make it easier to get a screenshot with two pages

\section{Section A}
\label{sec:SectionA}

\begin{theorem}[about something important]{important}
This is some important theorem with equations
\[
    1 + 1 = 0 \;,
\]
and text.
\end{theorem}

\begin{proof}
  \lipsum*[1-8] Theorem \eqref{thm:important}.
\end{proof}

\begin{theorem}[about something important]{veryImportant}
This is some important theorem with equations
\[
    1 + 1 = 0 \;,
\]
and text.

It continues for some more lines, so that a page break occurs during
its statement.
\end{theorem}

\begin{proof}[Proof of something important]
\lipsum[1]
\end{proof}

\end{document}

相关内容