summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/mdframed/mdframed-example-tikz.tex
blob: bbf84bdcc62983865384dd8cb344b23fb2dde055 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
%%$Id: mdframed.dtx 375 2012-04-08 10:52:22Z marco $
\setcounter{errorcontextlines}{999}
\documentclass[parskip=false,english,11pt]{ltxmdf}
\ltxmdfsetifoot  $Id: mdframed.dtx 375 2012-04-08 10:52:22Z marco $

\usepackage{showexpl}
\lstset{style=lstltxmdf,explpreset={pos=b,rframe={}},}

\newcommand\Loadedframemethod{TikZ}
\usepackage[framemethod=\Loadedframemethod]{mdframed}

\title{The \Pack{mdframed} package}
\subtitle{Examples for \Opt{framemethod=\Loadedframemethod}}
\author{\href{mailto:marco.daniel@mada-nada.de}{Marco Daniel}}
\date{\mdfdateID$Id: mdframed.dtx 375 2012-04-08 10:52:22Z marco $}
\version{\mdversion}
\introduction{In this document I collect various examples for \Opt{framemethod=\Loadedframemethod}.
Some presented examples are more or less exorbitant.}

\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.
}

\newcounter{examplecount}
\setcounter{examplecount}{0}
\renewcommand\thesubsection{}
\newcommand\Examplesec[1]{%
\stepcounter{examplecount}%
\subsection{Example~\arabic{examplecount}~--~#1\relax}%
}

\begin{document}
\maketitle
\section{Loading}
In the preamble only the package \Pack{mdframed} width the option \Opt{framemethod=\Loadedframemethod} is loaded. All other modifications will be done by \Cmd{mdfdefinestyle} or \Cmd{mdfsetup}.

{\large\color{red!50!black}
\NOTE Every \Cmd{global} inside the examples is necessary to work with the package \Pack{showexpl}.}

\section{Examples}
All examples have the following settings:

\begin{tltxmdfexample}
\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.
}
\end{tltxmdfexample}
\clearpage
\ExampleText{round corner}
\begin{LTXexample}
\global\mdfdefinestyle{exampledefault}{%
     outerlinewidth=5pt,innerlinewidth=0pt,
     outerlinecolor=red,roundcorner=5pt
}
\begin{mdframed}[style=exampledefault]
\ExampleText
\end{mdframed}
\end{LTXexample}

\Examplesec{hidden line + frame title}
\begin{LTXexample}
\global\mdfapptodefinestyle{exampledefault}{%
 topline=false,leftline=false,}
\begin{mdframed}[style=exampledefault,frametitle={Inhomogeneous linear}]
\ExampleText
\end{mdframed}
\end{LTXexample}
\clearpage
\Examplesec{framed picture which is centered}
\begin{LTXexample}
\begin{mdframed}[userdefinedwidth=6cm,align=center,
                 linecolor=blue,middlelinewidth=4pt,roundcorner=5pt]
\includegraphics[width=\linewidth]{donald-duck}
\end{mdframed}
\end{LTXexample}

\Examplesec{Gimmick}
\begin{LTXexample}
\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}
\end{LTXexample}

\Examplesec{complex example with TikZ}

\begin{tltxmdfexample}
\tikzstyle{titregris} =
     [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}
}
\makeatother

\mdfdefinestyle{exercisestyle}{%
  outerlinewidth=1pt,innerlinewidth=0pt,
  roundcorner=2pt,linecolor=gray,
  tikzsetting={shading = exersicebackground},
  innertopmargin=1.2\baselineskip,
  skipabove={\dimexpr0.5\baselineskip+\topskip\relax},
  needspace=3\baselineskip,
  frametitlefont=\sffamily\bfseries,
  settings={\global\stepcounter{exercise}},
  singleextra={%
        \node[titregris,xshift=1cm] at (P-|O) %
           {~\mdf@frametitlefont{\theexercise}~};
      \ifdefempty{\mdf@@exercisepoints}%
      {}%
      {\node[titregris,left,xshift=-1cm] at (P)%
        {~\mdf@frametitlefont{\mdf@@exercisepoints points}~};}%
   },
  firstextra={%
        \node[titregris,xshift=1cm] at (P-|O) %
           {~\mdf@frametitlefont{\theexercise}~};
      \ifdefempty{\mdf@@exercisepoints}%
      {}%
      {\node[titregris,left,xshift=-1cm] at (P)%
        {~\mdf@frametitlefont{\mdf@@exercisepoints points}~};}%
   },
}
\begin{mdframed}[style=exercisestyle,]
\ExampleText
\end{mdframed}

\begin{mdframed}[style=exercisestyle,exercisepoints=10]
\ExampleText
\end{mdframed}
\end{tltxmdfexample}
\clearpage
\Examplesec{Theorem environments}
\begin{LTXexample}
\mdfdefinestyle{theoremstyle}{%
     linecolor=red,linewidth=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*}
\end{LTXexample}

\end{document}
 \endinput