Tuesday, January 13, 2015

Framed theorems in Latex

I just added framed theorems to my Latex repertoire. I've been using amsthm for marking theorems for a long time, but since I encountered notes that had colored frames around the theorems, I decided that I'd add them to my latex header file. The part of the header file that relates to theorems is now is thus:

\usepackage{amsthm}
\usepackage[framemethod=tikz]{mdframed}
\renewcommand{\qedsymbol}{\textbf{Q.E.D}}

\mdfdefinestyle{theoremstyle}{%
roundcorner=5pt, % round corners, makes it friendlier
leftmargin=1pt, rightmargin=1pt, % this helps with box warnings
hidealllines=true, % even friendlier
align = center, %
}

\theoremstyle{plain}
\newtheorem*{setn}{Setning}
\newtheorem*{hsetn}{Hjálparsetning}

\theoremstyle{definition}
\newtheorem*{skgr}{Skilgreining}
\newtheorem*{daemi}{Dæmi}
\newtheorem*{frumsenda}{Frumsenda}
\newtheorem*{lausn}{Lausn}


\theoremstyle{remark}
\newtheorem*{ath}{Athugasemd}
\newtheorem*{innsk}{Innskot}

\surroundwithmdframed[style=theoremstyle,backgroundcolor = green!20]{skgr}
\surroundwithmdframed[style=theoremstyle,backgroundcolor=blue!10]{setn}
\surroundwithmdframed[style=theoremstyle,backgroundcolor = orange!20]{daemi}
\surroundwithmdframed[style=theoremstyle,backgroundcolor = red!20]{ath}

(All my notes are in Icelandic, of course, This allows me to mark my theorems, my definitions, remarks and examples specially in the TeX, and to spot them easily, which is a lot of help when using the notes in open book exams.
First I tried using mdtheorem and newmdtheoremenv, but neihter would give me what I want (couldn't get it to be unnumbered without ntheorem, and that messed up the amsthm,... etc), so the ultimate solution was just to not use the built in features of mdtheorem, and just saying directly what I wanted (a colored box around my theorems). I hope this is useful to others.

No comments:

Post a Comment