summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/mdframed/mdframed-example-texsx.tex
blob: 6f34f23d9a6d7cb07fa7b69b272948828b2cd964 (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


\setcounter{errorcontextlines}{999}
\documentclass[parskip=false,english,11pt,lipsum=true]{ltxmdf}

\usepackage{tikz}
\usetikzlibrary{calc,arrows,shadings,shadows}
\newcommand\Loadedframemethod{tikz}
\usepackage[framemethod=\Loadedframemethod]{mdframed}

\surroundwithmdframed[middlelinecolor=ltxmdfblue,middlelinewidth=1pt,%
                      roundcorner=10pt,innertopmargin=0pt,%
                      leftmargin=1cm,rightmargin=1cm,%
                      innerleftmargin=-15pt,innerrightmargin=-15pt,%
                      ignorelastdescenders,%
                      settings={\lstset{resetmargins}},%
                      skipbelow=\topskip,skipabove=\topskip,%
                      innerbottommargin=0pt,backgroundcolor=gray!10]%
                     {tltxmdfexample}

\newmdenv[middlelinecolor=ltxmdfblue,middlelinewidth=1pt,%
                      roundcorner=10pt,innertopmargin=0pt,%
                      leftmargin=1cm,rightmargin=1cm,%
                      innerleftmargin=-15pt,innerrightmargin=-15pt,%
                      ignorelastdescenders,%
                      settings={\lstset{resetmargins}},%
                      skipbelow=\topskip,skipabove=\topskip,%
                      innerbottommargin=0pt,backgroundcolor=gray!10]%
                     {tltxmdfhighlight}
\def\highlightinputenv{tltxmdfhighlight}

\title{The \Pack{mdframed} package}
\subtitle{Examples for \Opt{framemethod=\Loadedframemethod}}
\author{\href{mailto:marco.daniel@mada-nada.de}{Marco Daniel}}
\date{\mdfmaindate}
\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 my own
created environment \Env{tltxmdfexample*}.}

\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{Package listings}
The example below is inspired by the following post on StackExchange
\href{http://tex.stackexchange.com/questions/27673/background-overflows-^^A
      when-using-rounded-corners-for-listings-package-listings}%
     {Background overflows when using rounded corners for listings
      (package: `listings`)}

Here the solution which can be decorate as usual.

\begin{tltxmdfexample}[moretexcs={BeforeBeginEnvironment,AfterEndEnvironment},
                       morekeywords={lstlisting}]
\BeforeBeginEnvironment{lstlisting}{%
    \begin{mdframed}[<modification>]%
    \vspace{-0.7em}}
\AfterEndEnvironment{lstlisting}{%
    \vspace{-0.5em}%
    \end{mdframed}}
\end{tltxmdfexample}

With the new command \Cmd{surroundwithmdframed} you can use
\begin{tltxmdfexample}[moretexcs={BeforeBeginEnvironment,AfterEndEnvironment},
                       morekeywords={listings}]
\surroundwithmdframed{listings}
\end{tltxmdfexample}

\clearpage
\Examplesec{Package multicol}
How I wrote in \enquote{Known Problems} you can't combine \Pack{multicol}  with
\Pack{mdframed}. In a simple way without any breaks you can use:

\begin{tltxmdfexample*}[morekeywords={multicols}]
 \begin{multicols}{2}
  \lipsum[1]
  \begin{mdframed}
   \ExampleText
  \end{mdframed}
  \lipsum[2]
 \end{multicols}
\end{tltxmdfexample*}

\clearpage
\twocolumn[\Examplesec{Working in twocolumn mode}]
\begin{tltxmdfexample*}[moretexcs={Examplesec}]
\lipsum[1]\lipsum[2]
\begin{mdframed}[%
   leftmargin=10pt,%
   rightmargin=10pt,%
   linecolor=red,
   backgroundcolor=yellow]
\ExampleText
\end{mdframed}
\lipsum[2]
\end{tltxmdfexample*}

\clearpage
\onecolumn
\Examplesec{Working inside enumerate}
\begin{tltxmdfexample*}[morekeywords={enumerate}]
Text Text Text Text Text Text Text Text
\begin{enumerate}
\item in the following \ldots
      \begin{mdframed}[linecolor=blue,middlelinewidth=2]
         \ExampleText
      \end{mdframed}
\item \lipsum[2]
\end{enumerate}
Text Text Text Text Text Text
\end{tltxmdfexample*}

\Examplesec{Position a specific symbol at a line}
\begin{tltxmdfexample*}
\tikzset{
  warningsymbol/.style={
      rectangle,draw=red,
      fill=white,scale=1,
      overlay}}
\mdfdefinestyle{warning}{%
 hidealllines=true,leftline=true,
 skipabove=12,skipbelow=12pt,
 innertopmargin=0.4em,%
 innerbottommargin=0.4em,%
 innerrightmargin=0.7em,%
 rightmargin=0.7em,%
 innerleftmargin=1.7em,%
 leftmargin=0.7em,%
 middlelinewidth=.2em,%
 linecolor=red,%
 fontcolor=red,%
 firstextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
                           node[warningsymbol] {\$};},%
 secondextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
                           node[warningsymbol] {\$};},%
 middleextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
                           node[warningsymbol] {\$};},%
 singleextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
                           node[warningsymbol] {\$};},%
}
\begin{mdframed}[style=warning]
\ExampleText
\end{mdframed}
\end{tltxmdfexample*}

\Examplesec{digression-environement inspired by Tobias Weh}
\begin{tltxmdfexample*}[morekeywords={%
                    font,anchor,let,in,arrow,round,cap,controls,coordinate,%
                    excursus,head,arrows,calc,line,width,and,to,digressionarrows,%
                    base,west},%
                   moretexcs={usetikzlibrary}]
\usetikzlibrary{calc,arrows}
\tikzset{
   excursus arrow/.style={%
      line width=2pt,
      draw=gray!40,
      rounded corners=2ex,
   },
   excursus head/.style={
      fill=white,
      font=\bfseries\sffamily,
      text=gray!80,
      anchor=base west,
   },
}
\mdfdefinestyle{digressionarrows}{%
 singleextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
      \path [excursus arrow, round cap-to]
         ($(O)+(5em,0ex)$) -| (M) |- %
         ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
 firstextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,-to]
         (O) |- %
         ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
         ++(23em,2ex);
      \node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};},
 secondextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow,round cap-]
         ($(O)+(5em,0ex)$) -| (Q);},
 middleextra={%
      \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
      \path [excursus arrow]
         (O) -- (Q);},
   middlelinewidth=2.5em,middlelinecolor=white,
   hidealllines=true,topline=true,
   innertopmargin=0.5ex,
   innerbottommargin=2.5ex,
   innerrightmargin=2pt,
   innerleftmargin=2ex,
   skipabove=0.87\baselineskip,
   skipbelow=0.62\baselineskip,
}

\begin{mdframed}[style=digressionarrows]
         \ExampleText
\end{mdframed}
\end{tltxmdfexample*}

\Examplesec{Theorem style shading background}
\begin{tltxmdfexample*}[morekeywords={top,bottom,Theorem,shadow,alternativtheorem}]
\mdtheorem[%
 apptotikzsetting={%
   \tikzset{mdfbackground/.append style ={%
               top color=yellow!40!white,
               bottom color=yellow!80!black},
               mdfframetitlebackground/.append style={
                     top color=purple!40!white,
                     bottom color=purple!80!black
               }
           }%
  },
  ,roundcorner=10pt,middlelinewidth=2pt,
  shadow=true,frametitlerule=true,frametitlerulewidth=4pt,
  innertopmargin=10pt,%
  ]{alternativtheorem}{Theorem}
\begin{alternativtheorem}[Inhomogeneous linear]
\ExampleText
\end{alternativtheorem}
\end{tltxmdfexample*}
\end{document}
 \endinput