| 1 |
|
| 2 |
% Rolf Niepraschk, 2020-05-03, [email protected] |
| 3 |
|
| 4 |
\listfiles\errorcontextlines=100 |
| 5 |
\documentclass[a4paper,draft,twoside]{article} |
| 6 |
|
| 7 |
\usepackage[dvipsnames]{xcolor} |
| 8 |
\usepackage[textwidth=12cm,marginparwidth=4cm]{geometry} |
| 9 |
\usepackage[final]{showexpl} |
| 10 |
|
| 11 |
\usepackage{iftex} |
| 12 |
|
| 13 |
\iftutex % LuaTeX, XeTeX |
| 14 |
\usepackage{fontspec} |
| 15 |
\setmonofont{DejaVuSansMono}[Scale=MatchUppercase] |
| 16 |
\else % old engines |
| 17 |
\usepackage[T1]{fontenc} |
| 18 |
\usepackage{lmodern} |
| 19 |
\usepackage[scaled]{DejaVuSansMono} |
| 20 |
\fi |
| 21 |
|
| 22 |
\lstset{% |
| 23 |
basicstyle=\ttfamily\small, |
| 24 |
commentstyle=\itshape\ttfamily\small, |
| 25 |
showspaces=false, |
| 26 |
showstringspaces=false, |
| 27 |
breaklines=true, |
| 28 |
backgroundcolor=\color{lightgray}, |
| 29 |
breakautoindent=true, |
| 30 |
captionpos=t |
| 31 |
} |
| 32 |
|
| 33 |
\iftrue |
| 34 |
\lstset{explpreset={numbers=left,numberstyle=\tiny,numbersep=.3em, |
| 35 |
xleftmargin=1em,columns=flexible,language={}}} |
| 36 |
\fi |
| 37 |
|
| 38 |
\usepackage[font=small,labelfont=bf,justification=raggedright,% |
| 39 |
singlelinecheck=false]{caption} |
| 40 |
\usepackage{amsmath} |
| 41 |
|
| 42 |
\AtBeginDocument{% |
| 43 |
\renewcommand*\lstlistlistingname{Examples} |
| 44 |
\renewcommand*\lstlistingname{Example} |
| 45 |
} |
| 46 |
|
| 47 |
\newcommand*{\MARKER}% |
| 48 |
{\noindent\strut\vrule |
| 49 |
\hrulefill~half text area~\hrulefill\vrule |
| 50 |
\hrulefill~half text area~\hrulefill\vrule |
| 51 |
\marginpar{\strut\vrule\hrulefill~margin area~\hrulefill\vrule}} |
| 52 |
|
| 53 |
\begin{filecontents*}{ex1.tex} |
| 54 |
Line 1 \par |
| 55 |
Line 2 \par |
| 56 |
Line 3 \par |
| 57 |
Line 4 \par |
| 58 |
Line 5 \par |
| 59 |
Line 6 \par |
| 60 |
Line 7 \par |
| 61 |
Line 8 \par |
| 62 |
Line 9 \par |
| 63 |
Line 10 \par |
| 64 |
Line 11 \par |
| 65 |
Line 12 \par |
| 66 |
Line 13 |
| 67 |
\end{filecontents*} |
| 68 |
|
| 69 |
\begin{document} |
| 70 |
|
| 71 |
\section*{The \LaTeX\ package \textsf{showexpl}} |
| 72 |
|
| 73 |
\bigskip |
| 74 |
|
| 75 |
\lstlistoflistings |
| 76 |
|
| 77 |
\subsection*{The \textsf{listings} parameters still works} |
| 78 |
|
| 79 |
\begin{LTXexample}[pos=t,numbers=none, |
| 80 |
codefile=\jobname-\theltxexample.tex] |
| 81 |
\Large\LaTeX{} \LaTeX{} |
| 82 |
\LaTeX{} \LaTeX{} |
| 83 |
\end{LTXexample} |
| 84 |
|
| 85 |
\MARKER |
| 86 |
|
| 87 |
\subsection*{The \texttt{pos}, \texttt{overhang}, and |
| 88 |
\texttt{caption} parameters} |
| 89 |
|
| 90 |
\begin{LTXexample}[pos=b,overhang=.5\marginparwidth+.5\marginparsep,% |
| 91 |
caption={The \texttt{overhang} parameter}] |
| 92 |
\Large\LaTeX{} \LaTeX{} |
| 93 |
\LaTeX{} \LaTeX{} |
| 94 |
\end{LTXexample} |
| 95 |
|
| 96 |
\MARKER |
| 97 |
|
| 98 |
\begin{LTXexample}[pos=l,hsep=50pt,width=55mm] |
| 99 |
\Large\LaTeX{} \LaTeX{} |
| 100 |
\LaTeX{} \LaTeX{} |
| 101 |
\end{LTXexample} |
| 102 |
|
| 103 |
\MARKER |
| 104 |
|
| 105 |
\subsection*{The \texttt{wide} parameter with inner and outer position} |
| 106 |
|
| 107 |
\begin{LTXexample}[pos=o,wide,caption={The \texttt{wide} parameter},% |
| 108 |
label=ex:Gustav] |
| 109 |
\Large\LaTeX{} \LaTeX{} |
| 110 |
\LaTeX{} \LaTeX{} |
| 111 |
\end{LTXexample} |
| 112 |
|
| 113 |
\MARKER |
| 114 |
|
| 115 |
\begin{LTXexample}[pos=i,wide] |
| 116 |
\Large\LaTeX{} \LaTeX{} |
| 117 |
\LaTeX{} \LaTeX{} |
| 118 |
\end{LTXexample} |
| 119 |
|
| 120 |
|
| 121 |
%-------------- |
| 122 |
\newpage |
| 123 |
|
| 124 |
\subsection*{More examples on an even (left) page} |
| 125 |
|
| 126 |
\begin{LTXexample}[pos=t] |
| 127 |
\Large\LaTeX{} \LaTeX{} |
| 128 |
\LaTeX{} \LaTeX{} |
| 129 |
\end{LTXexample} |
| 130 |
|
| 131 |
\MARKER |
| 132 |
|
| 133 |
\begin{LTXexample}[pos=b,overhang=.5\marginparwidth+.5\marginparsep,% |
| 134 |
captionpos=b,caption={The \texttt{overhang} parameter again},% |
| 135 |
label=ex:Fridolin] |
| 136 |
\Large\LaTeX{} \LaTeX{} |
| 137 |
\LaTeX{} \LaTeX{} |
| 138 |
\end{LTXexample} |
| 139 |
|
| 140 |
\MARKER |
| 141 |
|
| 142 |
\begin{LTXexample}[pos=l,hsep=50pt,width=55mm] |
| 143 |
\Large\LaTeX{} \LaTeX{} |
| 144 |
\LaTeX{} \LaTeX{} |
| 145 |
\end{LTXexample} |
| 146 |
|
| 147 |
\MARKER |
| 148 |
|
| 149 |
\begin{LTXexample}[pos=o,wide,captionpos=b,% |
| 150 |
caption={The \texttt{wide} parameter again}] |
| 151 |
\Large\LaTeX{} \LaTeX{} |
| 152 |
\LaTeX{} \LaTeX{} |
| 153 |
\end{LTXexample} |
| 154 |
|
| 155 |
\MARKER |
| 156 |
|
| 157 |
\begin{LTXexample}[pos=i,wide] |
| 158 |
\Large\LaTeX{} \LaTeX{} |
| 159 |
\LaTeX{} \LaTeX{} |
| 160 |
\end{LTXexample} |
| 161 |
|
| 162 |
|
| 163 |
%-------------- |
| 164 |
\newpage |
| 165 |
|
| 166 |
\subsection*{Whole \LaTeX{} documents as example code and |
| 167 |
the para\-meters \texttt{preset}, \texttt{rframe}, and \texttt{rangeaccept}} |
| 168 |
|
| 169 |
\begin{LTXexample}[pos=r,wide,width=.65,preset=\LARGE,rframe={}] |
| 170 |
\documentclass[a4paper,twoside]{article} |
| 171 |
\begin{document} |
| 172 |
\begin{equation} |
| 173 |
\sigma(t)=\frac{1}{\sqrt{2\pi}} |
| 174 |
\int^t_0 e^{-x^2/2} dx |
| 175 |
\end{equation} |
| 176 |
\end{document} |
| 177 |
\end{LTXexample} |
| 178 |
|
| 179 |
\MARKER |
| 180 |
|
| 181 |
\begin{LTXexample}[wide,width=.75,preset=\footnotesize,rframe=single,% |
| 182 |
codefile=\jobname-\theltxexample.tex] |
| 183 |
\documentclass[a4paper,twoside]{article} |
| 184 |
\usepackage{amsmath} |
| 185 |
% enhancements for mathematical formulas |
| 186 |
\begin{document} |
| 187 |
\begin{equation}\label{eq:barwq} |
| 188 |
\begin{split} |
| 189 |
H_c&=\frac{1}{2n} |
| 190 |
\sum^n_{l=0}(-1)^{l}(n-{l})^{p-2} |
| 191 |
\sum_{l _1+\dots+ l _p=l}\prod^p_{i=1} |
| 192 |
\binom{n_i}{l _i}\\ |
| 193 |
&\quad\cdot[(n-l )-(n_i-l _i)]^{n_i-l _i}\cdot |
| 194 |
\Bigl[(n-l )^2-\sum^p_{j=1}(n_i-l _i)^2\Bigr]. |
| 195 |
\end{split} |
| 196 |
\end{equation} |
| 197 |
\end{document} |
| 198 |
\end{LTXexample} |
| 199 |
|
| 200 |
\LTXinputExample[% |
| 201 |
pos=r,backgroundcolor=\color{Goldenrod!50},% |
| 202 |
%firstline=3,lastline=6,% |
| 203 |
linerange={3-6,8-10},% |
| 204 |
float=tb,rangeaccept=true,% |
| 205 |
caption={[Floating Example]% |
| 206 |
This is a floating Example (parameter \texttt{rangeaccept=true})}]{ex1} |
| 207 |
|
| 208 |
\newpage |
| 209 |
|
| 210 |
\MARKER |
| 211 |
|
| 212 |
\subsection*{Using a graphic as the result} |
| 213 |
|
| 214 |
\begin{LTXexample}[pos=i,wide] |
| 215 |
\Large\LaTeX{} \LaTeX{} |
| 216 |
\LaTeX{} \LaTeX{} |
| 217 |
\end{LTXexample} |
| 218 |
|
| 219 |
\begin{LTXexample}[pos=i,wide,rframe={},% |
| 220 |
graphic=result-picture]% graphic=\jobname-\theltxexample |
| 221 |
\Large\LaTeX{} \LaTeX{} |
| 222 |
\LaTeX{} \LaTeX{} |
| 223 |
\end{LTXexample} |
| 224 |
|
| 225 |
\begin{LTXexample}[caption={The \texttt{graphic} parameter},captionpos=b,% |
| 226 |
pos=i,wide,graphic={[width=.5\linewidth]result-picture}] |
| 227 |
\Large\LaTeX{} \LaTeX{} |
| 228 |
\LaTeX{} \LaTeX{} |
| 229 |
\end{LTXexample} |
| 230 |
|
| 231 |
\newpage |
| 232 |
|
| 233 |
\subsection*{The parameter \texttt{varwidth}} |
| 234 |
|
| 235 |
\bigskip |
| 236 |
|
| 237 |
\MARKER |
| 238 |
|
| 239 |
\begin{LTXexample}[caption={Fix width of the result |
| 240 |
(side-by-side default: \texttt{0.5\textbackslash linewidth})},% |
| 241 |
captionpos=b] |
| 242 |
\setlength{\unitlength}{1cm} |
| 243 |
\begin{picture}(2,2) \thicklines |
| 244 |
\thicklines |
| 245 |
\put(0,0){\line(1,1){2}} |
| 246 |
\put(0,2){\line(1,-1){2}} |
| 247 |
\end{picture} |
| 248 |
\end{LTXexample} |
| 249 |
|
| 250 |
\medskip |
| 251 |
|
| 252 |
\begin{LTXexample}[caption={[The \texttt{varwidth} parameter]% |
| 253 |
Width of the result reduced to the ``natural'' |
| 254 |
width (\texttt{varwidth=true})},varwidth,captionpos=b] |
| 255 |
\setlength{\unitlength}{1cm} |
| 256 |
\begin{picture}(2,2) \thicklines |
| 257 |
\put(0,0){\line(1,1){2}} |
| 258 |
\put(0,2){\line(1,-1){2}} |
| 259 |
\end{picture} |
| 260 |
\end{LTXexample} |
| 261 |
|
| 262 |
\medskip |
| 263 |
|
| 264 |
\begin{LTXexample}[caption={Fix width of the result |
| 265 |
(default: \texttt{\textbackslash linewidth})},% |
| 266 |
pos=t,captionpos=b] |
| 267 |
\setlength{\unitlength}{1cm} |
| 268 |
\begin{picture}(2,2) \thicklines |
| 269 |
\put(0,0){\line(1,1){2}} |
| 270 |
\put(0,2){\line(1,-1){2}} |
| 271 |
\end{picture} |
| 272 |
\end{LTXexample} |
| 273 |
|
| 274 |
\medskip |
| 275 |
|
| 276 |
\begin{LTXexample}[caption={[The \texttt{justification} parameter]% |
| 277 |
Result is centered (\texttt{varwidth=true})},% |
| 278 |
varwidth,captionpos=b,pos=t,justification=\centering] |
| 279 |
\setlength{\unitlength}{1cm} |
| 280 |
\begin{picture}(2,2) |
| 281 |
\thicklines |
| 282 |
\put(0,0){\line(1,1){2}} |
| 283 |
\put(0,2){\line(1,-1){2}} |
| 284 |
\end{picture} |
| 285 |
\end{LTXexample} |
| 286 |
|
| 287 |
\end{document} |