Debian Codegraph @

texmf-dist/doc/latex/mdframed/mdframed-example-texsx.tex

raw
1
2
3 \setcounter{errorcontextlines}{999}
4 \documentclass[parskip=false,english,11pt,lipsum=true]{ltxmdf}
5
6 \usepackage{tikz}
7 \usetikzlibrary{calc,arrows,shadings,shadows}
8 \newcommand\Loadedframemethod{tikz}
9 \usepackage[framemethod=\Loadedframemethod]{mdframed}
10
11 \surroundwithmdframed[middlelinecolor=ltxmdfblue,middlelinewidth=1pt,%
12 roundcorner=10pt,innertopmargin=0pt,%
13 leftmargin=1cm,rightmargin=1cm,%
14 innerleftmargin=-15pt,innerrightmargin=-15pt,%
15 ignorelastdescenders,%
16 settings={\lstset{resetmargins}},%
17 skipbelow=\topskip,skipabove=\topskip,%
18 innerbottommargin=0pt,backgroundcolor=gray!10]%
19 {tltxmdfexample}
20
21 \newmdenv[middlelinecolor=ltxmdfblue,middlelinewidth=1pt,%
22 roundcorner=10pt,innertopmargin=0pt,%
23 leftmargin=1cm,rightmargin=1cm,%
24 innerleftmargin=-15pt,innerrightmargin=-15pt,%
25 ignorelastdescenders,%
26 settings={\lstset{resetmargins}},%
27 skipbelow=\topskip,skipabove=\topskip,%
28 innerbottommargin=0pt,backgroundcolor=gray!10]%
29 {tltxmdfhighlight}
30 \def\highlightinputenv{tltxmdfhighlight}
31
32 \title{The \Pack{mdframed} package}
33 \subtitle{Examples for \Opt{framemethod=\Loadedframemethod}}
34 \author{\href{mailto:[email protected]}{Marco Daniel}}
35 \date{\mdfmaindate}
36 \version{\mdversion}
37 \introduction{In this document I collect various examples for
38 \Opt{framemethod=\Loadedframemethod}.
39 Some presented examples are more or less exorbitant.}
40
41 \mdfsetup{skipabove=\topskip,skipbelow=\topskip}
42 \newrobustcmd\ExampleText{%
43 An \textit{inhomogeneous linear} differential equation has the form
44 \begin{align}
45 L[v ] = f,
46 \end{align}
47 where $L$ is a linear differential operator, $v$ is
48 the dependent variable, and $f$ is a given non-zero
49 function of the independent variables alone.
50 }
51
52 \newcounter{examplecount}
53 \setcounter{examplecount}{0}
54 \renewcommand\thesubsection{}
55 \newcommand\Examplesec[1]{%
56 \stepcounter{examplecount}%
57 \subsection{Example~\arabic{examplecount}~--~#1\relax}%
58 }
59
60 \begin{document}
61 \maketitle
62 \section{Loading}
63 In the preamble only the package \Pack{mdframed} width the option
64 \Opt{framemethod=\Loadedframemethod} is loaded. All other modifications will be
65 done by \Cmd{mdfdefinestyle} or \Cmd{mdfsetup}.
66
67 {\large\color{red!50!black}
68 \NOTE Every \Cmd{global} inside the examples is necessary to work with my own
69 created environment \Env{tltxmdfexample*}.}
70
71 \section{Examples}
72 All examples have the following settings:
73
74 \begin{tltxmdfexample}
75 \mdfsetup{skipabove=\topskip,skipbelow=\topskip}
76 \newrobustcmd\ExampleText{%
77 An \textit{inhomogeneous linear} differential equation has the form
78 \begin{align}
79 L[v ] = f,
80 \end{align}
81 where $L$ is a linear differential operator, $v$ is the dependent
82 variable, and $f$ is a given non-zero function of the independent
83 variables alone.
84 }
85 \end{tltxmdfexample}
86 \clearpage
87 \Examplesec{Package listings}
88 The example below is inspired by the following post on StackExchange
89 \href{http://tex.stackexchange.com/questions/27673/background-overflows-^^A
90 when-using-rounded-corners-for-listings-package-listings}%
91 {Background overflows when using rounded corners for listings
92 (package: `listings`)}
93
94 Here the solution which can be decorate as usual.
95
96 \begin{tltxmdfexample}[moretexcs={BeforeBeginEnvironment,AfterEndEnvironment},
97 morekeywords={lstlisting}]
98 \BeforeBeginEnvironment{lstlisting}{%
99 \begin{mdframed}[<modification>]%
100 \vspace{-0.7em}}
101 \AfterEndEnvironment{lstlisting}{%
102 \vspace{-0.5em}%
103 \end{mdframed}}
104 \end{tltxmdfexample}
105
106 With the new command \Cmd{surroundwithmdframed} you can use
107 \begin{tltxmdfexample}[moretexcs={BeforeBeginEnvironment,AfterEndEnvironment},
108 morekeywords={listings}]
109 \surroundwithmdframed{listings}
110 \end{tltxmdfexample}
111
112 \clearpage
113 \Examplesec{Package multicol}
114 How I wrote in \enquote{Known Problems} you can't combine \Pack{multicol} with
115 \Pack{mdframed}. In a simple way without any breaks you can use:
116
117 \begin{tltxmdfexample*}[morekeywords={multicols}]
118 \begin{multicols}{2}
119 \lipsum[1]
120 \begin{mdframed}
121 \ExampleText
122 \end{mdframed}
123 \lipsum[2]
124 \end{multicols}
125 \end{tltxmdfexample*}
126
127 \clearpage
128 \twocolumn[\Examplesec{Working in twocolumn mode}]
129 \begin{tltxmdfexample*}[moretexcs={Examplesec}]
130 \lipsum[1]\lipsum[2]
131 \begin{mdframed}[%
132 leftmargin=10pt,%
133 rightmargin=10pt,%
134 linecolor=red,
135 backgroundcolor=yellow]
136 \ExampleText
137 \end{mdframed}
138 \lipsum[2]
139 \end{tltxmdfexample*}
140
141 \clearpage
142 \onecolumn
143 \Examplesec{Working inside enumerate}
144 \begin{tltxmdfexample*}[morekeywords={enumerate}]
145 Text Text Text Text Text Text Text Text
146 \begin{enumerate}
147 \item in the following \ldots
148 \begin{mdframed}[linecolor=blue,middlelinewidth=2]
149 \ExampleText
150 \end{mdframed}
151 \item \lipsum[2]
152 \end{enumerate}
153 Text Text Text Text Text Text
154 \end{tltxmdfexample*}
155
156 \Examplesec{Position a specific symbol at a line}
157 \begin{tltxmdfexample*}
158 \tikzset{
159 warningsymbol/.style={
160 rectangle,draw=red,
161 fill=white,scale=1,
162 overlay}}
163 \mdfdefinestyle{warning}{%
164 hidealllines=true,leftline=true,
165 skipabove=12,skipbelow=12pt,
166 innertopmargin=0.4em,%
167 innerbottommargin=0.4em,%
168 innerrightmargin=0.7em,%
169 rightmargin=0.7em,%
170 innerleftmargin=1.7em,%
171 leftmargin=0.7em,%
172 middlelinewidth=.2em,%
173 linecolor=red,%
174 fontcolor=red,%
175 firstextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
176 node[warningsymbol] {\$};},%
177 secondextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
178 node[warningsymbol] {\$};},%
179 middleextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
180 node[warningsymbol] {\$};},%
181 singleextra={\path let \p1=(P), \p2=(O) in ($(\x2,0)+0.5*(0,\y1)$)
182 node[warningsymbol] {\$};},%
183 }
184 \begin{mdframed}[style=warning]
185 \ExampleText
186 \end{mdframed}
187 \end{tltxmdfexample*}
188
189 \Examplesec{digression-environement inspired by Tobias Weh}
190 \begin{tltxmdfexample*}[morekeywords={%
191 font,anchor,let,in,arrow,round,cap,controls,coordinate,%
192 excursus,head,arrows,calc,line,width,and,to,digressionarrows,%
193 base,west},%
194 moretexcs={usetikzlibrary}]
195 \usetikzlibrary{calc,arrows}
196 \tikzset{
197 excursus arrow/.style={%
198 line width=2pt,
199 draw=gray!40,
200 rounded corners=2ex,
201 },
202 excursus head/.style={
203 fill=white,
204 font=\bfseries\sffamily,
205 text=gray!80,
206 anchor=base west,
207 },
208 }
209 \mdfdefinestyle{digressionarrows}{%
210 singleextra={%
211 \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
212 \path let \p1=(Q), \p2=(O) in (\x1,{(\y1-\y2)/2}) coordinate (M);
213 \path [excursus arrow, round cap-to]
214 ($(O)+(5em,0ex)$) -| (M) |- %
215 ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
216 ++(23em,2ex);
217 \node [excursus head] at ($(Q)+(2.5em,-0.75pt)$) {Digression};},
218 firstextra={%
219 \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
220 \path [excursus arrow,-to]
221 (O) |- %
222 ($(Q)+(12em,0ex)$) .. controls +(0:16em) and +(185:6em) .. %
223 ++(23em,2ex);
224 \node [excursus head] at ($(Q)+(2.5em,-2pt)$) {Digression};},
225 secondextra={%
226 \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
227 \path [excursus arrow,round cap-]
228 ($(O)+(5em,0ex)$) -| (Q);},
229 middleextra={%
230 \path let \p1=(P), \p2=(O) in (\x2,\y1) coordinate (Q);
231 \path [excursus arrow]
232 (O) -- (Q);},
233 middlelinewidth=2.5em,middlelinecolor=white,
234 hidealllines=true,topline=true,
235 innertopmargin=0.5ex,
236 innerbottommargin=2.5ex,
237 innerrightmargin=2pt,
238 innerleftmargin=2ex,
239 skipabove=0.87\baselineskip,
240 skipbelow=0.62\baselineskip,
241 }
242
243 \begin{mdframed}[style=digressionarrows]
244 \ExampleText
245 \end{mdframed}
246 \end{tltxmdfexample*}
247
248 \Examplesec{Theorem style shading background}
249 \begin{tltxmdfexample*}[morekeywords={top,bottom,Theorem,shadow,alternativtheorem}]
250 \mdtheorem[%
251 apptotikzsetting={%
252 \tikzset{mdfbackground/.append style ={%
253 top color=yellow!40!white,
254 bottom color=yellow!80!black},
255 mdfframetitlebackground/.append style={
256 top color=purple!40!white,
257 bottom color=purple!80!black
258 }
259 }%
260 },
261 ,roundcorner=10pt,middlelinewidth=2pt,
262 shadow=true,frametitlerule=true,frametitlerulewidth=4pt,
263 innertopmargin=10pt,%
264 ]{alternativtheorem}{Theorem}
265 \begin{alternativtheorem}[Inhomogeneous linear]
266 \ExampleText
267 \end{alternativtheorem}
268 \end{tltxmdfexample*}
269 \end{document}
270 \endinput