3

I am writing a document with theorems and proofs. Since, some reader may not be interested by the proofs I want to highlight them so they can be skipped easily.

The best idea I came up with is to put a bar in the left margin of the proof (if you have any better ideas I am interested).

The problem is that some proofs may take more than one page and contain figures and/or tables. Currently I found a solution in a previous post which uses the package framed and the command \leftbar. It works for several pages but not for figures and tables.

\documentclass{article}

\usepackage{xcolor}
\usepackage{framed}

\renewenvironment{leftbar}[1][\hsize]
{%
    \def\FrameCommand
    {%
        {\color{black}\vrule width 0.5pt}%
        \hspace{0pt}%must no space.
        \fboxsep=\FrameSep\colorbox{white}%
    }%
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}
{\endMakeFramed}

 \newenvironment{proof}[1][Proof]{\leftbar\begin{trivlist}\item[\hskip\labelsep {\bfseries#1}]}{\end{trivlist}\endleftbar}

\def\fact{It is  practically a big lie  that LaTeX makes  you focus on
  the content without bothering about the layout.}

\begin{document}

\begin{proof}
  \fact
\end{proof} % Works

%\begin{proof}
%  \fact
%  \begin{figure}
%    \centering My figure
%    \caption{Test figure}
%  \end{figure}
%\end{proof} % Does not works

\end{document}

I don't really understand how environments work. Do you know if it's possible to make this work for proofs which include tables or figures?

(if you know why the bar starts one line before the proof and finish one line after I am also interested but it is not my main concern)

Thanks in advance.

  • 1
    The main problem is that figure is a floating environment, so may well be moved out of the area used by the proof. By the way, you want to try the mdframed package instead, but that won't solve the floating problem. – Andrew Swann Apr 8 '14 at 9:47
  • To clarify, for me it is not a problem if the figure does not have the bar in the left margin. However, I am not sure it will help... – Zach Apr 8 '14 at 10:15
  • Related Questions: 1. Changbars to indicate location of conditional text, and 2. Environments for visually setting text apart. You could perhaps adapt the solution from there. I'd recommend you consider using an mdframed environment for the proofs. – Peter Grill Apr 8 '14 at 13:03
4

Place the proof inside the figure environment, or else the "fact" may end up in a different location than the figure.

EDITED to allow for multi-figures and page breaks in proofs (by using the \captionof{figure}{} approach).

\documentclass{article}
\usepackage{caption}
\usepackage{xcolor}
\usepackage{framed}
\usepackage{lipsum}
\renewenvironment{leftbar}[1][\hsize]
{%
    \def\FrameCommand
    {%
        {\color{black}\vrule width 0.5pt}%
        \hspace{0pt}%must no space.
        \fboxsep=\FrameSep\colorbox{white}%
    }%
    \MakeFramed{\hsize#1\advance\hsize-\width\FrameRestore}%
}
{\endMakeFramed}

 \newenvironment{proof}[1][Proof]{\leftbar\begin{trivlist}\item[\hskip\labelsep {\bfseries#1}]}{\end{trivlist}\endleftbar}

\def\fact{It is  practically a big lie  that LaTeX makes  you focus on
  the content without bothering about the layout.}
\def\gappar{\vspace{1em}\par}
\begin{document}
\begin{proof}
  \fact
\end{proof} % Works

\begin{figure}[ht]
\begin{proof}
  \fact\gappar
   \centering\fbox{My figure}
    \caption{Test figure}
\end{proof} % Now it works
\end{figure}

\begin{proof}
  \fact\gappar
    {\centering\fbox{My figure 1}
    \captionof{figure}{Test figure 1}\gappar}
   \lipsum[4]\gappar
    {\centering\fbox{My figure 2}
    \captionof{figure}{Test figure 2}\gappar}
    QED
\end{proof} % Now it works
\end{document}

enter image description here

  • I am afraid it will just work for one figure and if the proof is smaller than one page. – Zach Apr 8 '14 at 14:23
  • @Zach The figure environment in general will only work for a single page. If you wanted a faux environment, you could load the caption package, use the \includegraphics without the \begin{figure}...\end{figure} wrapper, and use \captionof{figure}{my caption} to underlay the caption. If you can't follow what I'm saying, say so, and I will revise my answer to show it. – Steven B. Segletes Apr 8 '14 at 14:41
  • @Zach Please see my edit. – Steven B. Segletes Apr 8 '14 at 15:29
  • Indeed, using captionof and replacing all the figure and table environments in my proof by center environments worked. It may not be the most elegant solution but currently that suits me perfectly. Thanks ! – Zach Apr 8 '14 at 15:47
2

I have another solution where the word "Proof" is placed before the bar, and the bar can break across pages. It essentially uses the ntheorem and framed packages. Here is the code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage{lipsum}
\usepackage[svgnames, x11names]{xcolor}
%\usepackage[showframe,nomarginpar]{geometry}%
%\usepackage{fancybox}
\usepackage{xspace}
\usepackage{framed}
\usepackage[framed]{ntheorem}

\theoremstyle{nonumberplain}
\theorembodyfont{\upshape\small}
\theoremheaderfont{\color{IndianRed3}\sffamily\bfseries}%
\newlength{\FrameIndent}
\settowidth{\FrameIndent}{Proof\hspace{2\fboxsep}}%
\def\FrameCommand{%
\hspace*{\FrameIndent}\textcolor{IndianRed3}{\vrule width 0.6pt}\hspace{\fboxsep}
}%

\newframedtheorem{proof}{\llap{Proof\hspace{4\fboxsep}}\hspace{-\parindent}}%%{Proof}%

\begin{document}

\lipsum[1-3]

\begin{proof}
  \lipsum[4-6]
\end{proof} %

\end{document} 

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.