summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/mdframed/mdframed-example-default.tex
blob: d58246131d5f3703de00fcd8880ad0185a5f0fe0 (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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
%%
%% This is file `mdframed-example-default.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mdframed-examples.dtx  (with options: `mdframed-example-default')
%% ----------------------------------------------------------------
%% Working with the command fbox or fcolorbox, one has to
%% handle page breaks by hand. The present package defines the
%% environment mdframed which automatically deals with page breaks.
%% 
%% Author's name: Marco Daniel and Elke Schubert (!new)
%% License type: lppl

%%$Id: mdframed-examples.dtx 270 2011-12-09 12:19:09Z marco $
\setcounter{errorcontextlines}{999}
\documentclass[parskip=false,english,11pt]{ltxmdf}
\ltxmdfsetifoot  $Id: mdframed-examples.dtx 270 2011-12-09 12:19:09Z marco $

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

\newcommand\Loadedframemethod{default}
\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}}
\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
\Examplesec{very simple}
\begin{LTXexample}
\global\mdfdefinestyle{exampledefault}{%
     linecolor=red,linewidth=3pt,%
     leftmargin=1cm,rightmargin=1cm
}
\begin{mdframed}[style=exampledefault]
\ExampleText
\end{mdframed}
\end{LTXexample}

\Examplesec{hidden line + frame title}
\begin{LTXexample}
\global\mdfapptodefinestyle{exampledefault}{%
 topline=false,rightline=true,bottomline=false}
\begin{mdframed}[style=exampledefault,frametitle={Inhomogeneous linear}]
\ExampleText
\end{mdframed}
\end{LTXexample}
\clearpage

\Examplesec{colored frame title}
\begin{LTXexample}
\renewcommand\mdframedtitleenv[1]{%
                 \colorbox{green}{%
                 \parbox{\dimexpr\linewidth-6pt\relax}%6pt=linewidth
                 {\centering\bfseries #1}}%
                 \par\kern.5\baselineskip\noindent%
        }
\global\mdfapptodefinestyle{exampledefault}{%
   rightline=true,innerleftmargin=0,innerrightmargin=0}
\begin{mdframed}[style=exampledefault,frametitle={Inhomogeneous linear}]
\ExampleText
\end{mdframed}
\end{LTXexample}

\Examplesec{framed picture which is centered}
\begin{LTXexample}
\begin{mdframed}[userdefinedwidth=6cm,align=center,
                 linecolor=blue,linewidth=4pt]
\includegraphics[width=\linewidth]{donald-duck}
\end{mdframed}
\end{LTXexample}

\Examplesec{theorem with separate header and the help of TikZ (complex)}
\begin{tltxmdfexample}
\makeatletter
\newcounter{theo}[section]
\newcommand*\newmdframedtitleenv[1]{%
 \@afterindentfalse
  {\parindent \z@
    \setlength{\parfillskip}{\z@ plus 1fil}%
    \mdraggedtitle\nobreak%
    \makebox[\linewidth][l]{%
     \hspace*{-1\mdf@innerleftmargin@length}%
     \rlap{\color{white}%
       \hspace*{-1\mdf@middlelinewidth@length}%
       \rule[\mdf@middlelinewidth@length]%
            {\dimexpr\linewidth+1\mdf@innerleftmargin@length%
             +\mdf@innerrightmargin@length
             +2\mdf@middlelinewidth@length\relax}%
            {\dimexpr\ht\strutbox+.3333em\relax}%
     }%
     \rlap{\color{blue!20}%
       \rule{\dimexpr\linewidth+\mdf@innerleftmargin@length%
             +\mdf@innerrightmargin@length\relax}%
            {\mdf@middlelinewidth@length}}%
     \hspace*{-1\mdf@middlelinewidth@length}%
     \tikz[remember picture,baseline]%
       \node[,draw = none, text = black,fill = blue!20,]%
       {\mdf@frametitlefont\strut Theorem~\thetheo#1};\relax%
   }%
  \par\kern.5\baselineskip}%
 \@afterheading}
\newenvironment{theo}[1][]{%
  \let\mdframedtitleenv\newmdframedtitleenv%
   \stepcounter{theo}%
   \ifstrempty{#1}%
     {\mdfsetup{frametitle={\strut}}}%
     {\mdfsetup{frametitle={:~#1}}}%
   \begin{mdframed}[innertopmargin=0pt,linecolor=blue!20,%
                    linewidth=2pt,topline=false,]%
   }{\end{mdframed}}
\begin{theo}[Inhomogeneous Linear]
\ExampleText
\end{theo}

\begin{theo}
\ExampleText
\end{theo}
\end{tltxmdfexample}
\makeatletter
\newcounter{theo}[section]
\newcommand*\newmdframedtitleenv[1]{%
 \@afterindentfalse
  {\parindent \z@
    \setlength{\parfillskip}{\z@ plus 1fil}%
    \mdraggedtitle\nobreak%
    \makebox[\linewidth][l]{%
     \hspace*{-1\mdf@innerleftmargin@length}%
     \rlap{\color{white}%
       \hspace*{-1\mdf@middlelinewidth@length}%
       \rule[\mdf@middlelinewidth@length]%
            {\dimexpr\linewidth+1\mdf@innerleftmargin@length%
             +\mdf@innerrightmargin@length
             +2\mdf@middlelinewidth@length\relax}%
            {\dimexpr\ht\strutbox+.3333em\relax}%
     }%
     \rlap{\color{blue!20}%
       \rule{\dimexpr\linewidth+\mdf@innerleftmargin@length%
             +\mdf@innerrightmargin@length\relax}%
            {\mdf@middlelinewidth@length}}%
     \hspace*{-1\mdf@middlelinewidth@length}%
     \tikz[remember picture,baseline]%
       \node[,draw = none, text = black,fill = blue!20,]%
       {\mdf@frametitlefont\strut Theorem~\thetheo#1};\relax%
   }%
  \par\kern.5\baselineskip}%
 \@afterheading}
\newenvironment{theo}[1][]{%
  \let\mdframedtitleenv\newmdframedtitleenv%
   \stepcounter{theo}%
   \ifstrempty{#1}%
     {\mdfsetup{frametitle={\strut}}}%
     {\mdfsetup{frametitle={:~#1}}}%
   \begin{mdframed}[innertopmargin=0pt,linecolor=blue!20,%
                    linewidth=2pt,topline=false,]%
   }{\end{mdframed}}

\begin{theo}[Inhomogeneous Linear]
\ExampleText
\end{theo}

\begin{theo}
\ExampleText
\end{theo}

\clearpage
\Examplesec{hide only a part of a line}
The example below is inspired by the following post on StackExchange \href{http://tex.stackexchange.com/questions/24101/theorem-decorations-that-stay-with-theorem-environment}{Theorem decorations that stay with theorem environment}
\begin{LTXexample}
\makeatletter
\newlength{\interruptlength}
\setlength{\interruptlength}{2.5ex}
\newrobustcmd\overlaplines{%
 \appto\md@frame@leftline@single{%
  \llap{\color{white}%
   \rule[\dimexpr-\mdfboundingboxdepth%
         \ifbool{mdf@bottomline}{-\mdf@middlelinewidth@length}{}%
         +\interruptlength\relax]%
       {\mdf@middlelinewidth@length}%
       {\dimexpr\mdfboundingboxtotalheight%
        +\ifbool{mdf@bottomline}{\mdf@middlelinewidth@length}{0pt}
        +\ifbool{mdf@topline}{\mdf@middlelinewidth@length}{0pt}%
       -2\interruptlength\relax}%
  }%
 }%
 \appto\md@frame@rightline@single{%
  \rlap{\color{white}%
    \hspace*{\mdfboundingboxwidth}%
    \hspace*{\mdf@innerrightmargin@length}%
    \rule[\dimexpr-\mdfboundingboxdepth%
          \ifbool{mdf@bottomline}{-\mdf@middlelinewidth@length}{}
          +\interruptlength\relax]%
         {\mdf@middlelinewidth@length}%
         {\dimexpr\mdfboundingboxtotalheight%
          +\ifbool{mdf@bottomline}{\mdf@middlelinewidth@length}{0pt}%
          +\ifbool{mdf@topline}{\mdf@middlelinewidth@length}{0pt}
          -2\interruptlength\relax}%
  }%
 }
}
\makeatother
\overlaplines

\begin{mdframed}[linecolor=blue,linewidth=8pt]
\ExampleText
\end{mdframed}
\end{LTXexample}
\end{document}
 \endinput
%% 
%% ================================================================
%% Copyright (C) 2011 by Marco Daniel
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in the file:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%% Marco Daniel.
%% 
%% Have fun!
%% 
%% ================================================================
%%
%% End of file `mdframed-example-default.tex'.