LaTeX forum ⇒ Graphics, Figures & TablesAdd a Frame to a Proof

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

Add a Frame to a Proof

Postby TesTT » Wed Feb 13, 2013 12:02 am

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 5263 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.

Tags:

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Wed Feb 13, 2013 9:39 pm

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).

  1. \documentclass{article}
  2.  
  3. \usepackage{amsmath,amsthm}
  4. % upright instead of italic text in the theorem:
  5. % \theoremstyle{definition}
  6. % new theorem:
  7. \newtheorem{thm}{Theorem}
  8.  
  9. % closed box instead of open box for the qed symbol:
  10. \newcommand*\closedbox{%
  11. \leavevmode\hbox to.77778em{\hfil\rule{.675em}{.675em}\hfil}}
  12. \let\qedsymbol\closedbox
  13.  
  14.  
  15. \usepackage[framemethod=tikz]{mdframed}
  16. % new mdframed style that places the edges at the corners:
  17. \mdfdefinestyle{proof}{
  18. skipabove = .5\baselineskip ,
  19. skipbelow = .5\baselineskip ,
  20. leftmargin = 0pt ,
  21. rightmargin = 0pt ,
  22. innermargin = 0pt ,
  23. innertopmargin = .5em ,
  24. innerleftmargin = .5em ,
  25. innerrightmargin = 0pt ,
  26. innerbottommargin = 0pt ,
  27. hidealllines = true ,
  28. singleextra = {
  29. \draw (O) -- ++(0,.675em) (O) -- ++(.675em,0) ;
  30. \draw (P-|O) -- ++(0,-.675em) (P-|O) -- ++(.675em,0) ;
  31. },
  32. firstextra = {
  33. \draw (P-|O) -- ++(0,-.675em) (P-|O) -- ++(.675em,0) ;
  34. },
  35. secondextra = {
  36. \draw (O) -- ++(0,.675em) (O) -- ++(.675em,0) ;
  37. },
  38. }
  39. % put the new mdframed style around the proof environment:
  40. \surroundwithmdframed[style=proof]{proof}
  41.  
  42. \usepackage{lipsum}% dummy text
  43.  
  44. \begin{document}
  45.  
  46. \begin{thm}
  47. \lipsum[2]
  48. \end{thm}
  49.  
  50. \begin{proof}
  51. \lipsum[2]
  52. \end{proof}
  53.  
  54. \end{document}


proof.png
proof.png (46.46 KiB) Viewed 5257 times


Regards
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Postby TesTT » Thu Feb 14, 2013 2:31 pm

Thanks a lot for your reply. But is there an equivalent for Miktex?

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Thu Feb 14, 2013 9:00 pm

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
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Postby TesTT » Sat Feb 16, 2013 9:01 pm

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 5225 times

User avatar
cgnieder
Site Moderator
Posts: 1988
Joined: Sat Apr 16, 2011 7:27 pm

Postby cgnieder » Sat Feb 16, 2013 9:39 pm

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
Clemens
------------------------------
chemmacros · chemformula · leadsheets · xsim

TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Postby TesTT » Sun Feb 17, 2013 3:47 am

Thanks for the tip. It works perfectly now. :)

TesTT
Posts: 12
Joined: Wed Aug 15, 2012 6:52 pm

Postby TesTT » Sun Feb 17, 2013 3:56 am

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 5217 times


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests