Monday, September 30, 2013

Membuat Bingkai untuk Teorema

Ada kalanya kita ingin definisi, dalil (teorema), dll. disajikan berbingkai agar tampak lebih indah. 
Bagaimana caranya? 

Berikut ini salah satu contoh struktur yang dapat dibuat.
\documentclass{scrartcl}
\title{Bingkai}
\usepackage[utf8]{inputenc}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{chngcntr}
\usepackage{bm}
\usepackage{bbold}
% counters
\newcounter{theorem}
\newcounter{lemma}

% names for the structures
\newcommand\theoname{Teorema}
\newcommand\lemmname{Definisi}

\makeatletter
% mdf key for the eventual notes in the structures
\def\mdf@@mynote{}
\define@key{mdf}{mynote}{\def\mdf@@mynote{#1}}

% style for theorems
\mdfdefinestyle{mytheo}{
settings={\refstepcounter{theorem}},
linewidth=1pt,
innertopmargin=1.5\baselineskip,
roundcorner=10pt,
backgroundcolor=blue!05,
linecolor=teal,
singleextra={
  \node[xshift=10pt,thick,draw=teal,fill=cyan!30,rounded corners,anchor=west] at (P-|O) %
  {\strut{\bfseries\theoname~\thetheorem}\ifdefempty{\mdf@@mynote}{}{~(\mdf@@mynote)}};
},
firstextra={
  \node[xshift=10pt,thick,draw=teal,fill=cyan!30,rounded corners,anchor=west] at (P-|O) %
  {\strut{\bfseries\theoname~\thetheorem}\ifdefempty{\mdf@@mynote}{}{~(\mdf@@mynote)}};
}
}

% style for lemmas
\mdfdefinestyle{mylemm}{
settings={\refstepcounter{lemma}},
linewidth=1pt,
innertopmargin=1.5\baselineskip,
roundcorner=10pt,
backgroundcolor=red!05,
linecolor=red!70!black,
singleextra={
  \path let \p1=(P), \p2=(O) in
  node[thick,draw=teal!60!pink,fill=teal!05!pink,rounded corners] at (P-|0.5*\x2+0.5*\x1,0) %
  {\strut{\bfseries\lemmname~\thelemma}\ifdefempty{\mdf@@mynote}{}{~(\mdf@@mynote)}};
},
firstextra={
  \path let \p1=(P), \p2=(O) in
  node[thick,draw=teal!60!pink,fill=teal!05!pink,rounded corners] at (P-|0.5*\x2+0.5*\x1,0) %
  {\strut{\bfseries\lemmname~\thelemma}\ifdefempty{\mdf@@mynote}{}{~(\mdf@@mynote)}};
}
}

% some auxiliary environments
\newmdenv[style=mytheo]{theor}
\newmdenv[style=mylemm]{lemm}

% the actual environments
\newenvironment{theorem}[1][]
  {\begin{theor}[mynote=#1]}
  {\end{theor}\bigskip}
\newenvironment{lemma}[1][]
  {\begin{lemm}[mynote=#1]}
  {\end{lemm}\bigskip}

\makeatother

\begin{document}
...
\end{document}

Pada bagian inti dokumen, misalnya, dituliskan ini:

Adjie Gumarang Pujakelana 2013

maka beginilah hasilnya: 

-->

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...