Mdframed Example Tikz

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

The mdframed package

Examples for framemethod=TikZ

Marco Daniel 1.9b 2013/07/01

In this document I collect various examples for framemethod=TikZ. Some presented


examples are more or less exorbitant.

Contents
1 Loading 1 Example 3 – framed picture which is
centered . . . . . . . . . . . . . . 2
2 Examples 1 Example 4 – Gimmick . . . . . . . . . 3
Example 1 – round corner . . . . . . . 2 Example 5 – complex example with TikZ 4
Example 2 – hidden line + frame title 2 Example 6 – Theorem environments . 6

1 Loading
In the preamble only the package mdframed width the option framemethod=TikZ is loaded. All other
modifications will be done by \mdfdefinestyle or \mdfsetup.
Note
Every \global inside the examples is necessary to work with my own created environment
tltxmdfexample*.

2 Examples
All examples have the following settings:

\mdfsetup{skipabove=\topskip,skipbelow=\topskip}
\newrobustcmd\ExampleText{%
An \textit{inhomogeneous linear} differential equation has the form
\begin{align}
L[v ] = f,
\end{align}
where $L$ is a linear differential operator, $v$ is the dependent
variable, and $f$ is a given non−zero function of the independent
variables alone.
}
Example 1 – round corner 2 Examples

Example 1 – round corner

\global\mdfdefinestyle{exampledefault}{%
outerlinewidth=5pt,innerlinewidth=0pt,
outerlinecolor=red,roundcorner=5pt
}
\begin{mdframed}[style=exampledefault]
\ExampleText
\end{mdframed}

An inhomogeneous linear differential equation has the form

L[v] = f, (1)

where L is a linear differential operator, v is the dependent variable, and f is a given


non-zero function of the independent variables alone.

Example 2 – hidden line + frame title

\global\mdfapptodefinestyle{exampledefault}{%
topline=false,leftline=false,}
\begin{mdframed}[style=exampledefault,frametitle={Inhomogeneous linear}]
\ExampleText
\end{mdframed}

Inhomogeneous linear
An inhomogeneous linear differential equation has the form

L[v] = f, (2)

where L is a linear differential operator, v is the dependent variable, and f is a given


non-zero function of the independent variables alone.

Example 3 – framed picture which is centered

\begin{mdframed}[userdefinedwidth=6cm,align=center,
linecolor=blue,middlelinewidth=4pt,roundcorner=5pt]
\textit{CTAN lion drawing by Duane Bibby; thanks to \url{www.ctan.org}}
\IfFileExists{ctan−lion.png}%
{\includegraphics[width=\linewidth]{ctan−lion.png}}%

2013/07/01 revision: 212 mdframed-example-tikz 2


Example 4 – Gimmick 2 Examples

{\rule{\linewidth}{4cm}}%
\end{mdframed}

CTAN lion drawing by Duane


Bibby; thanks to www.ctan.org

Example 4 – Gimmick

\mdfsetup{splitbottomskip=0.8cm,splittopskip=0cm,
innerrightmargin=2cm,innertopmargin=1cm,%
innerlinewidth=2pt,outerlinewidth=2pt,
middlelinewidth=10pt,backgroundcolor=red,
linecolor=blue,middlelinecolor=gray,
tikzsetting={draw=yellow,line width=3pt,%
dashed,%
dash pattern= on 10pt off 3pt},
rightline=false,bottomline=false}
\begin{mdframed}
\ExampleText
\end{mdframed}

An inhomogeneous linear differential equation has the form

L[v] = f, (3)

where L is a linear differential operator, v is the dependent variable, and f is a


given non-zero function of the independent variables alone.

2013/07/01 revision: 212 mdframed-example-tikz 3


Example 5 – complex example with TikZ 2 Examples

Example 5 – complex example with TikZ

\tikzset{titregris/.style =
{draw=gray, thick, fill=white, shading = exersicetitle, %
text=gray, rectangle, rounded corners, right,minimum height=.7cm}}
\pgfdeclarehorizontalshading{exersicebackground}{100bp}
{color(0bp)=(green!40); color(100bp)=(black!5)}
\pgfdeclarehorizontalshading{exersicetitle}{100bp}
{color(0bp)=(red!40);color(100bp)=(black!5)}
\newcounter{exercise}
\renewcommand∗\theexercise{Exercise~n\arabic{exercise}}
\makeatletter
\def\mdf@@exercisepoints{}%new mdframed key:
\define@key{mdf}{exercisepoints}{%
\def\mdf@@exercisepoints{#1}
}
\mdfdefinestyle{exercisestyle}{%
outerlinewidth=1em,outerlinecolor=white,%
leftmargin=−1em,rightmargin=−1em,%
middlelinewidth=1.2pt,roundcorner=5pt,linecolor=gray,
apptotikzsetting={\tikzset{mdfbackground/.append style ={%
shading = exersicebackground}}},
innertopmargin=1.2\baselineskip,
skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
skipbelow={−1em},
needspace=3\baselineskip,
frametitlefont=\sffamily\bfseries,
settings={\global\stepcounter{exercise}},
singleextra={%
\node[titregris,xshift=1cm] at (P−|O) %
{~\mdf@frametitlefont{\theexercise}\hbox{~}};
\ifdefempty{\mdf@@exercisepoints}%
{}%
{\node[titregris,left,xshift=−1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}\hbox{~}};}%
},
firstextra={%
\node[titregris,xshift=1cm] at (P−|O) %
{~\mdf@frametitlefont{\theexercise}\hbox{~}};
\ifdefempty{\mdf@@exercisepoints}%
{}%
{\node[titregris,left,xshift=−1cm] at (P)%
{~\mdf@frametitlefont{\mdf@@exercisepoints points}\hbox{~}};}%
},
}
\makeatother

\begin{mdframed}[style=exercisestyle]
\ExampleText
\end{mdframed}

\begin{mdframed}[style=exercisestyle,exercisepoints=10]
\ExampleText
\end{mdframed}

2013/07/01 revision: 212 mdframed-example-tikz 4


Example 5 – complex example with TikZ 2 Examples

Exercise n1
An inhomogeneous linear differential equation has the form

L[v] = f, (4)

where L is a linear differential operator, v is the dependent variable, and f is a given non-zero
function of the independent variables alone.

Exercise n2 10points
An inhomogeneous linear differential equation has the form

L[v] = f, (5)

where L is a linear differential operator, v is the dependent variable, and f is a given non-zero
function of the independent variables alone.

2013/07/01 revision: 212 mdframed-example-tikz 5


Example 6 – Theorem environments 2 Examples

Example 6 – Theorem environments

\mdfdefinestyle{theoremstyle}{%
linecolor=red,middlelinewidth=2pt,%
frametitlerule=true,%
apptotikzsetting={\tikzset{mdfframetitlebackground/.append style={%
shade,left color=white, right color=blue!20}}},
frametitlerulecolor=green!60,
frametitlerulewidth=1pt,
innertopmargin=\topskip,
}
\mdtheorem[style=theoremstyle]{definition}{Definition}
\begin{definition}[Inhomogeneous linear]
\ExampleText
\end{definition}
\begin{definition∗}[Inhomogeneous linear]
\ExampleText
\end{definition∗}

Definition 1: Inhomogeneous linear

An inhomogeneous linear differential equation has the form

L[v] = f, (6)

where L is a linear differential operator, v is the dependent variable, and f is a given non-zero
function of the independent variables alone.

Definition: Inhomogeneous linear

An inhomogeneous linear differential equation has the form

L[v] = f, (7)

where L is a linear differential operator, v is the dependent variable, and f is a given non-zero
function of the independent variables alone.

2013/07/01 revision: 212 mdframed-example-tikz 6

You might also like