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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
|
%%
%% This is file `mpinlsmp.tex',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% mpostinl.dtx (with options: `sample')
%%
%% Copyright (C) 2010-2018 Niklas Beisert
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
\NeedsTeXFormat{LaTeX2e}[1996/12/01]
\ProvidesFile{mpinlsmp.tex}[2018/01/17 v1.21 sample for mpostinl]
\documentclass[12pt,a4paper]{article}
\parindent0pt
\parskip6pt
\usepackage[fonts=true]{mpostinl}
\usepackage[utf8]{inputenc}
%% optional: add filename to position labels in metapost code
\IfFileExists{currfile.sty}{\usepackage{currfile}}{}
%% optional: tools to align graphics
\makeatletter\define@key{Gin}{align}[]{}\makeatother
\IfFileExists{graphbox.sty}{\usepackage{graphbox}}{}
%% some sample package options:
%% \mpostsetup{write=false}
%% \mpostsetup{compile=false}
\mpostsetup{now}
%% \mpostsetup{nowall}
\mpostsetup{lineno}
%% \mpostsetup{latex=false}
%% \mpostsetup{classopt={12pt}}
%% declare packages to be used for processing labels:
\begin{mpostdef}[tex,global]
\usepackage[utf8]{inputenc}
\end{mpostdef}
%% specify global definitions:
\begin{mpostdef}[global]
newinternal unit;
unit:=1cm;
\end{mpostdef}
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Basic Functionality}
a plain circle:\\
\begin{mpostfig}
draw fullcircle scaled unit;
label(btex 1 etex, (0,0));
\end{mpostfig}
scaled (and aligned to centre if available):\\
X
\begin{mpostfig}[opt={scale=1.5,align}]
draw fullcircle scaled unit;
label(btex 2 etex, (0,0));
\end{mpostfig}
X
declare figure with label (no display).
\begin{mpostfig}[label={fig}]
draw fullcircle scaled unit;
label(btex 3 etex, (0,0));
\end{mpostfig}
display:\\
\mpostuse{fig}
display with options:\\
\mpostuse[scale=1.5,align]{fig}
display in a box:\\
\fbox{\mpostuse{fig}}
centred display:
\begin{center}
\mpostuse[scale=1.5]{fig}
\end{center}
display in equation (align if possible):
\begin{equation}
\mpostuse[scale=1.5,align]{fig}
\end{equation}
filename: \mpostgetname{fig}
\texttt{\mpostfigurename}
figure with filename:\\
\begin{mpostfig}[file={\jobname-name.mps},label={name},show]
draw fullcircle scaled unit;
label(btex 4 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{name}
\texttt{\mpostfigurename}
display by \verb+\includegraphics+ (if file exists):\\
\IfFileExists{\jobname-name.mps}{\includegraphics{\jobname-name.mps}}{}
label does not exist:\\
\mpostuse{notexist}
utf-8 test:\\
\begin{mpostfig}
interim unit:=1.5cm;
draw fullcircle scaled unit;
label(btex àáâãäåæ etex, (0,0));
\end{mpostfig}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Immediate Processing}
immediate processing per figure:\\
\begin{mpostfig}[now]
interim unit:=1.5cm;
draw fullcircle scaled unit;
label(btex 5 etex, (0,0));
\end{mpostfig}
turn on immediate processing for all figures and keep sources.
\mpostsetup{nowall,nowkeep}
generate file \texttt{\jobname-now.mps}:
\begin{mpostfig}[file={\jobname-now.mps}]
draw fullcircle scaled unit;
label(btex 6 etex, (0,0));
\end{mpostfig}
\\
display by \verb+\includegraphics+:\\
\includegraphics{\jobname-now.mps}
\\
source \texttt{\jobname-now.mp}
\IfFileExists{\jobname-now.mp}{exists}{does not exist}.
turn off immediate processing and discard sources.
\mpostsetup{nowall=false,nowkeep=false}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Filename Composition}
by label:\\
\mpostsetup{labelnames=true}
\begin{mpostfig}[label={circle},show]
draw fullcircle scaled unit;
label(btex 7 etex, (0,0));
\end{mpostfig}
\mpostsetup{labelnames=false}
\\
filename: \mpostgetname{circle}
\texttt{\mpostfigurename}
change extension:
\mpostsetup{extension=eps}
\begin{mpostfig}[label={ext}]
draw fullcircle scaled unit;
label(btex 8 etex, (0,0));
\end{mpostfig}
\mpostsetup{extension=mps}
\\
filename: \mpostgetname{ext}
\texttt{\mpostfigurename}
change template:\\
\mpostsetup{template=\mpostfilename-figure-#1.mps}
\begin{mpostfig}[label={template},show]
draw fullcircle scaled unit;
label(btex 9 etex, (0,0));
\end{mpostfig}
\mpostsetup{template=\mpostfilename-#1.mps}
\\
filename: \mpostgetname{template}
\texttt{\mpostfigurename}
\mpostsetup{numberwithin=subsection}
\subsection{Section 1}
\begin{mpostfig}[show,label={sec1}]
draw fullcircle scaled unit;
label(btex 10 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec1}
\texttt{\mpostfigurename}
\subsection{Section 2}
\begin{mpostfig}[show,label={sec2}]
draw fullcircle scaled unit;
label(btex 11 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec2}
\texttt{\mpostfigurename}
\begin{mpostfig}[show,label={sec3}]
draw fullcircle scaled unit;
label(btex 12 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec3}
\texttt{\mpostfigurename}
\subsection{Section 3}
\begin{mpostfig}[show,label={sec4}]
draw fullcircle scaled unit;
label(btex 13 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec4}
\texttt{\mpostfigurename}
\makeatletter
\def\thempi@count{\arabic{mpi@count}}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Multiple Files}
\mpostdone
\mpostsetup{globaldef=true}
\begin{mpostdef}
unit:=0.8cm;
\end{mpostdef}
\mpostsetup{globaldef=false}
\mpostfile[include]{\jobname-inc}
\begin{mpostdef}
def drawcircle =
draw fullcircle scaled unit
enddef;
\end{mpostdef}
\mpostdone
\subsection*{Section 1}
\mpostfile{\jobname-sec1}
\begin{mpostfig}[show,label={sec5}]
drawcircle;
label(btex 14 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec5}
\texttt{\mpostfigurename}
\mpostdone
\subsection*{Section 2}
\mpostfile{\jobname-sec2}
\begin{mpostfig}[show,label={sec6}]
drawcircle;
label(btex 15 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec6}
\texttt{\mpostfigurename}
\begin{mpostdef}
unit:=1.5cm;
\end{mpostdef}
\begin{mpostfig}[show,label={sec7}]
drawcircle;
label(btex 16 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec7}
\texttt{\mpostfigurename}
\mpostdone
\subsection*{Section 3}
\mpostfile{\jobname-sec3}
\begin{mpostfig}[show,label={sec8}]
drawcircle;
label(btex 17 etex, (0,0));
\end{mpostfig}
\\
filename: \mpostgetname{sec8}
\texttt{\mpostfigurename}
\mpostdone
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\end{document}
\endinput
%%
%% End of file `mpinlsmp.tex'.
|