Graphics, Figures & TablesAdd a Frame to a Proof

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Add a Frame to a Proof

Post by TesTT »

Hey,

In university I learned to write theorems and proofs as shown in the attached picture. Now I started typing my own lecture notes and was wondering how one could accomplish such a "frame" around the edges of the proof.

Thanks for your help. :)
Attachments
theorem-frame.jpg
theorem-frame.jpg (49.4 KiB) Viewed 10092 times
Last edited by localghost on Wed Feb 13, 2013 11:22 am, edited 1 time in total.
Reason: Preferably no external links (see Board Rules). Attachments go onto the forum server where possible.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Add a Frame to a Proof

Post by cgnieder »

I'd do this kind of things with mdframed. when used with framemethod=tikz the corners of the environment can be accessed with TikZ. Details on the package can be read in the documentation (mdframed).

Code: Select all

\documentclass{article}

\usepackage{amsmath,amsthm}
% upright instead of italic text in the theorem:
% \theoremstyle{definition}
% new theorem:
\newtheorem{thm}{Theorem}

% closed box instead of open box for the qed symbol:
\newcommand*\closedbox{%
  \leavevmode\hbox to.77778em{\hfil\rule{.675em}{.675em}\hfil}}
\let\qedsymbol\closedbox


\usepackage[framemethod=tikz]{mdframed}
% new mdframed style that places the edges at the corners:
\mdfdefinestyle{proof}{
  skipabove         = .5\baselineskip ,
  skipbelow         = .5\baselineskip ,
  leftmargin        = 0pt ,
  rightmargin       = 0pt ,
  innermargin       = 0pt ,
  innertopmargin    = .5em ,
  innerleftmargin   = .5em ,
  innerrightmargin  = 0pt ,
  innerbottommargin = 0pt ,
  hidealllines      = true ,
  singleextra       = {
    \draw (O) -- ++(0,.675em) (O) -- ++(.675em,0) ;
    \draw (P-|O) -- ++(0,-.675em) (P-|O) -- ++(.675em,0) ;
  },
  firstextra        = {
    \draw (P-|O) -- ++(0,-.675em) (P-|O) -- ++(.675em,0) ;
  },
  secondextra       = {
    \draw (O) -- ++(0,.675em) (O) -- ++(.675em,0) ;
  },
}
% put the new mdframed style around the proof environment:
\surroundwithmdframed[style=proof]{proof}

\usepackage{lipsum}% dummy text

\begin{document}    

\begin{thm}
 \lipsum[2]
\end{thm}

\begin{proof}
 \lipsum[2]
\end{proof}

\end{document}
proof.png
proof.png (46.46 KiB) Viewed 10086 times
Regards
site moderator & package author
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Re: Add a Frame to a Proof

Post by TesTT »

Thanks a lot for your reply. But is there an equivalent for Miktex?
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Add a Frame to a Proof

Post by cgnieder »

TesTT wrote:But is there an equivalent for Miktex?
I don't understand... why would it be any different with MiKTeX than any other TeX distribution? This code is independent of the TeX distribution as long it is up to date (and possibly complete).

Regards
site moderator & package author
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Re: Add a Frame to a Proof

Post by TesTT »

Well, I received the following error messages when I tried your code. Hence I assumed it could only be used with certain latex libraries (since you mentioned TikZ). :/
Attachments
tex_error_screen.jpg
tex_error_screen.jpg (182.99 KiB) Viewed 10054 times
User avatar
cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Add a Frame to a Proof

Post by cgnieder »

I guess you need to update your distribution. The current version of mdframed is 1.6d. Yours seems to be too old (can't say definitely -- you should be able to find the information in the log file, though).

Regards
site moderator & package author
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Re: Add a Frame to a Proof

Post by TesTT »

Thanks for the tip. It works perfectly now. :)
TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Re: Add a Frame to a Proof

Post by TesTT »

Just one little additional question: how can i indent the text after the first line (as shown in the screenshot), i.e. keep the red-shaded areas clear of any text?
Attachments
indent.jpg
indent.jpg (61.48 KiB) Viewed 10046 times
Post Reply