Debian Codegraph @

texmf-dist/doc/latex/mpostinl/mpinlsmp.tex

raw
1 %%
2 %% This is file `mpinlsmp.tex',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% mpostinl.dtx (with options: `sample')
8 %%
9 %% Copyright (C) 2010-2025 Niklas Beisert
10 %%
11 %% This work may be distributed and/or modified under the
12 %% conditions of the LaTeX Project Public License, either version 1.3
13 %% of this license or (at your option) any later version.
14 %% The latest version of this license is in
15 %% https://www.latex-project.org/lppl.txt
16 %% and version 1.3c or later is part of all distributions of LaTeX
17 %% version 2008 or later.
18 %%
19 \NeedsTeXFormat{LaTeX2e}[1996/12/01]
20 \ProvidesFile{mpinlsmp.tex}[2025/12/27 v1.5.3 sample for mpostinl]
21 \documentclass[12pt,a4paper]{article}
22
23 \parindent0pt
24 \parskip6pt
25
26 \usepackage[fonts=true]{mpostinl}
27
28 \usepackage[utf8]{inputenc}
29
30 %% optional: add filename to position labels in metapost code
31 \IfFileExists{currfile.sty}{\usepackage{currfile}}{}
32 %% optional: tools to align graphics
33 \makeatletter\define@key{Gin}{align}[]{}\makeatother
34 \IfFileExists{graphbox.sty}{\usepackage{graphbox}}{}
35
36 %% some sample package options:
37 %% \mpostsetup{write=false}
38 %% \mpostsetup{compile=false}
39 \mpostsetup{checksum}
40 \mpostsetup{now}
41 %% \mpostsetup{nowall}
42 \mpostsetup{lineno}
43 %% \mpostsetup{latex=false}
44 %% \mpostsetup{classopt={12pt}}
45
46 %% declare packages to be used for processing labels:
47 \begin{mposttex}[global]
48 \usepackage[utf8]{inputenc}
49 \end{mposttex}
50
51 %% specify global definitions:
52 \begin{mpostdef}[global]
53 newinternal unit;
54 unit:=1cm;
55 \end{mpostdef}
56
57 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58 \begin{document}
59
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
61 \section{Basic Functionality}
62
63 a plain circle:\\
64 \begin{mpostfig}
65 draw fullcircle scaled unit;
66 label(btex 1 etex, (0,0));
67 \end{mpostfig}
68
69 scaled (and aligned to centre if available):\\
70 X
71 \begin{mpostfig}[opt={scale=1.5,align}]
72 draw fullcircle scaled unit;
73 label(btex 2 etex, (0,0));
74 \end{mpostfig}
75 X
76
77 declare figure with label (no display).
78 \begin{mpostfig}[label={fig}]
79 draw fullcircle scaled unit;
80 label(btex 3 etex, (0,0));
81 \end{mpostfig}
82
83 display:\\
84 \mpostuse{fig}
85
86 display with options:\\
87 \mpostuse[scale=1.5,align]{fig}
88
89 display in a box:\\
90 \fbox{\mpostuse{fig}}
91
92 centred display:
93 \begin{center}
94 \mpostuse[scale=1.5]{fig}
95 \end{center}
96
97 display in equation (align if possible):
98 \begin{equation}
99 \mpostuse[scale=1.5,align]{fig}
100 \end{equation}
101
102 filename: \mpostgetname{fig}
103 \texttt{\mpostfigurename}
104
105 figure with filename:\\
106 \begin{mpostfig}[file={\jobname-name.mps},label={name},show]
107 draw fullcircle scaled unit;
108 label(btex 4 etex, (0,0));
109 \end{mpostfig}
110 \\
111 filename: \mpostgetname{name}
112 \texttt{\mpostfigurename}
113
114 display by \verb+\includegraphics+ (if file exists):\\
115 \IfFileExists{\jobname-name.mps}{\includegraphics{\jobname-name.mps}}{}
116
117 label does not exist:\\
118 \mpostuse{not_exist}
119
120 utf-8 test:\\
121 \begin{mpostfig}
122 interim unit:=1.5cm;
123 draw fullcircle scaled unit;
124 label(btex àáâãäåæ etex, (0,0));
125 \end{mpostfig}
126
127 empty figure:\\
128 \begin{mpostfig}
129 \end{mpostfig}
130
131 empty figure:\\
132 \begin{mpostfig}
133
134 \end{mpostfig}
135
136 \begin{mposttex}[dual]
137 \def\mymacro{hello!}
138 \end{mposttex}
139 dual definition `\mymacro':\\
140 \begin{mpostfig}
141 draw unitsquare shifted (-0.5,-0.5) xscaled 3 scaled unit;
142 label(btex \mymacro etex, (0,0));
143 \end{mpostfig}
144
145 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146 \section{Immediate Processing}
147
148 immediate processing per figure:\\
149 \begin{mpostfig}[now]
150 interim unit:=1.5cm;
151 draw fullcircle scaled unit;
152 label(btex 5 etex, (0,0));
153 \end{mpostfig}
154
155 turn on immediate processing for all figures and keep sources.
156 \mpostsetup{nowall,nowkeep}
157
158 generate file \texttt{\jobname-now.mps}:
159 \begin{mpostfig}[file={\jobname-now.mps}]
160 draw fullcircle scaled unit;
161 label(btex 6 etex, (0,0));
162 \end{mpostfig}
163 \\
164 display by \verb+\includegraphics+:\\
165 \includegraphics{\jobname-now.mps}
166 \\
167 source \texttt{\jobname-now.mp}
168 \IfFileExists{\jobname-now.mp}{exists}{does not exist}.
169
170 turn off immediate processing and discard sources.
171 \mpostsetup{nowall=false,nowkeep=false}
172
173 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 \section{Filename Composition}
175
176 by label:\\
177 \mpostsetup{labelnames=true}
178 \begin{mpostfig}[label={circle},show]
179 draw fullcircle scaled unit;
180 label(btex 7 etex, (0,0));
181 \end{mpostfig}
182 \mpostsetup{labelnames=false}
183 \\
184 filename: \mpostgetname{circle}
185 \texttt{\mpostfigurename}
186
187 change extension:
188 \mpostsetup{extension=eps}
189 \begin{mpostfig}[label={ext}]
190 draw fullcircle scaled unit;
191 label(btex 8 etex, (0,0));
192 \end{mpostfig}
193 \mpostsetup{extension=mps}
194 \\
195 filename: \mpostgetname{ext}
196 \texttt{\mpostfigurename}
197
198 change template:\\
199 \mpostsetup{template=\mpostfilename-figure-#1.mps}
200 \begin{mpostfig}[label={template},show]
201 draw fullcircle scaled unit;
202 label(btex 9 etex, (0,0));
203 \end{mpostfig}
204 \mpostsetup{template=\mpostfilename-#1.mps}
205 \\
206 filename: \mpostgetname{template}
207 \texttt{\mpostfigurename}
208
209 \mpostsetup{numberwithin=subsection}
210
211 \subsection{Section 1}
212
213 \begin{mpostfig}[show,label={sec1}]
214 draw fullcircle scaled unit;
215 label(btex 10 etex, (0,0));
216 \end{mpostfig}
217 \\
218 filename: \mpostgetname{sec1}
219 \texttt{\mpostfigurename}
220
221 \subsection{Section 2}
222
223 \begin{mpostfig}[show,label={sec2}]
224 draw fullcircle scaled unit;
225 label(btex 11 etex, (0,0));
226 \end{mpostfig}
227 \\
228 filename: \mpostgetname{sec2}
229 \texttt{\mpostfigurename}
230
231 \begin{mpostfig}[show,label={sec3}]
232 draw fullcircle scaled unit;
233 label(btex 12 etex, (0,0));
234 \end{mpostfig}
235 \\
236 filename: \mpostgetname{sec3}
237 \texttt{\mpostfigurename}
238
239 \subsection{Section 3}
240
241 \begin{mpostfig}[show,label={sec4}]
242 draw fullcircle scaled unit;
243 label(btex 13 etex, (0,0));
244 \end{mpostfig}
245 \\
246 filename: \mpostgetname{sec4}
247 \texttt{\mpostfigurename}
248
249 \makeatletter
250 \def\thempi@count{\arabic{mpi@count}}
251 \makeatother
252
253 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 \section{Multiple Files}
255
256 \mpostdone
257
258 \mpostsetup{globaldef=true}
259
260 \begin{mpostdef}
261 unit:=0.8cm;
262 \end{mpostdef}
263
264 \mpostsetup{globaldef=false}
265
266 \mpostfile[include]{\jobname-inc}
267
268 \begin{mpostdef}
269 def drawcircle =
270 draw fullcircle scaled unit
271 enddef;
272 \end{mpostdef}
273
274 \mpostdone
275
276 \subsection*{Section 1}
277 \mpostfile{\jobname-sec1}
278
279 \begin{mpostfig}[show,label={sec5}]
280 drawcircle;
281 label(btex 14 etex, (0,0));
282 \end{mpostfig}
283 \\
284 filename: \mpostgetname{sec5}
285 \texttt{\mpostfigurename}
286
287 \mpostdone
288
289 \subsection*{Section 2}
290 \mpostfile{\jobname-sec2}
291
292 \begin{mpostfig}[show,label={sec6}]
293 drawcircle;
294 label(btex 15 etex, (0,0));
295 \end{mpostfig}
296 \\
297 filename: \mpostgetname{sec6}
298 \texttt{\mpostfigurename}
299
300 \begin{mpostdef}
301 unit:=1.5cm;
302 \end{mpostdef}
303
304 \begin{mpostfig}[show,label={sec7}]
305 drawcircle;
306 label(btex 16 etex, (0,0));
307 \end{mpostfig}
308 \\
309 filename: \mpostgetname{sec7}
310 \texttt{\mpostfigurename}
311
312 \mpostdone
313
314 \subsection*{Section 3}
315 \mpostfile{\jobname-sec3}
316
317 \begin{mpostfig}[show,label={sec8}]
318 drawcircle;
319 label(btex 17 etex, (0,0));
320 \end{mpostfig}
321 \\
322 filename: \mpostgetname{sec8}
323 \texttt{\mpostfigurename}
324
325 \mpostdone
326
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328 \end{document}
329 \endinput
330 %%
331 %% End of file `mpinlsmp.tex'.