Skip to main content

Questions tagged [metapost]

MetaPost uses a language based on that of Metafont to produce precise technical illustrations. Its output is either scalable PostScript or SVG or bitmaps PNG, rather than the bitmaps Metafont creates. This tag is compatible with {diagrams}.

Filter by
Sorted by
Tagged with
4 votes
0 answers
90 views

Error reproducing an example

I am trying to reproduce the example from this awesome article (link). This is my first code in Metapost and I am getting an error running the following code: prologues := 3; % set up MetaPost for EPS ...
Mac's user avatar
  • 53
2 votes
0 answers
43 views

Typesetting metapost labels horizontally into a transformed picture

I want to produce a sequence of [successive] drawings from a single program—to illustrate the successive steps in some process—where every next picture is the previous plus a little extra something. ...
g i i k's user avatar
  • 165
2 votes
2 answers
86 views

Unexpected error when using "addto"

I have defined a fairly simple macro as follows: vardef foo(expr p) = picture G; G := image( draw origin -- (300,300); ); show G; addto p also G; % remaining text When attempting ...
g i i k's user avatar
  • 165
1 vote
0 answers
62 views

What does begingroup/endgroup actually do?

I've started to notice that all my MetaPost/MetaFun figures are surrounded by begingroup ; endgroup ; Probably because I put that here when I wrote my snippet... But the fact is, I never actually ...
q6tDCWto's user avatar
5 votes
1 answer
64 views

Metapost dashed evenly option affects lines in TeX labels -- a bug?

Consider this MWE and its output (TeX Live 2023) -- is it a bug? beginfig(1) drawoptions(dashed evenly); draw btex $\sqrt{22222} \displaystyle {1 \over 22222}$ etex; endfig; end
Vadim Radionov's user avatar
2 votes
1 answer
85 views

How to properly input mp files in MetaFun?

In my ConTeXt project I have a long .mp file that I want to divide into several sub-files and make it library-like. For that purpose I load the initial file with \startMPinclusions input path/to/...
q6tDCWto's user avatar
2 votes
1 answer
63 views

Expanding macro text argument between btex etex

I have created a macro to draw something at a point and apply a label as follows: def defpoint (expr z)(text side, lab) = begingroup ... % macro text label.side(btex lab etex, z); endgroup ...
g i i k's user avatar
  • 165
3 votes
1 answer
70 views

Are boolean operations on shapes possible in MetaPost/MetaFun?

I am currently facing a, probably, simple problem. Problem which I couldn't find any satisfying solution. For this example, let's say that I have a simple square and that I what to "remove" ...
q6tDCWto's user avatar
1 vote
0 answers
67 views

Creating Mutli Colored Font

I am playing around with the igo package to create notes on the game of Go. Under the hood, it seems like the igo package computes a font for all of the symbols on the board, and simply prints a block ...
Jason Miller's user avatar
1 vote
1 answer
65 views

Limitation in calculations with Metapost

With the value i = 60 (with color blue), the curve is not drawn but with pgfplots, there is no problem. I compiled with lmtx \startMPpage[offset=1DK] numeric u; u = 6cm; ...
Fabrice's user avatar
  • 3,678
3 votes
2 answers
168 views

How does arctime in Metapost work?

Please look at the following Metapost code: path p; p = (0,0){up}..{right}(200,100)..{up}(300,400)..cycle; len := arclength p; s := arctime (2500) of p; t := arctime (len+2500) of p; draw p; show len;%...
Weißer Kater's user avatar
2 votes
1 answer
61 views

Compilation error : Isolated expression [Metapost]

I don't understand the error generated by the compilation of this code which does not work (based on an idea from Franck Pastor Area between two curves beginfig(1); interim linejoin := mitered; ...
Fabrice's user avatar
  • 3,678
3 votes
1 answer
89 views

How to use the penpos/penstroke inside a parametrized macro?

I am trying to create parameterized macro to draw a shape with penpos and penstroke macros in MetaPost (Metafont?) with plain.mp base but I am getting a error. Running the code below, def curve_st(...
sigsegv's user avatar
  • 625
2 votes
2 answers
63 views

Intersection of line of a triangle with another line passing through opposite vertex and circumcenter

I have following code: pair a; pair b; pair c; pickup pencircle scaled 0.2pt; a = (0, 4cm); b = (-2cm, 0); c = (1cm, 0); draw a -- b -- c -- cycle; pair p; pair q; pair r;...
Shiv's user avatar
  • 173
2 votes
0 answers
46 views

Metapost outputtemplate influences %& format comment parsing in verbatimtex

Consider the following code: outputtemplate := "%j-%2c.mps"; verbatimtex %&latex \documentclass{article} \begin{document} etex beginfig(1) label.lft(btex \textbf{J} etex,origin); ...
TeXnician's user avatar
  • 33.7k
2 votes
1 answer
90 views

using Lua from within MetaPost

Is it possible to run a Lua function from within luamplib environment? This example with runscript does not work, but shows what I like to do: \documentclass{article} \usepackage{iftex,luamplib} \...
user187802's user avatar
  • 17.4k
4 votes
2 answers
197 views

Is there a way to get glyph/text outlines in MetaPost in LuaLaTeX?

I need to get outline paths for certain text in MetaPost in LuaLaTeX to use them for some further manipulations, similar to what you can do in ConTeXt: \starttext \startMPcode picture p; ...
Sergey Slyusarev's user avatar
0 votes
2 answers
32 views

How to expand macro name when passing it to luamplib code to be used as a file name?

I need to pass some string of text from my LuaLaTeX document to be used as a file name. Here's a kind of MWE: \documentclass{article} \usepackage{luamplib} \def\testfilename{test1} \def\writesomewords#...
Sergey Slyusarev's user avatar
4 votes
2 answers
154 views

How do I make the squiggly line in metapost?

I can do the normal line, but don't know how I'm supposed to do the squiggly one. Code is this: beginfig(1); numeric u; u=1cm; path ytelg; ytelg := (0,-0.25u)--(0,3u); path xtelg; xtelg :=...
hellusENG's user avatar
1 vote
2 answers
241 views

How to draw those shapes in Metapost

I can't figure out how to draw those two shapes in Metapost, are easy but I really don't get it. This the code I was trying to fix with a online visualizer: beginfig(0); draw (0,0)--(5,0)..(7.5,2.5).....
freezr's user avatar
  • 103
3 votes
1 answer
103 views

MetaPost - Tangent line between two paths

I'm trying to make a function that given 2 paths would draw all the lines that are common tangents of them. More specifically I was trying to draw the common tangent of 2 ellipses so that it would ...
Thiago Brawerman's user avatar
2 votes
1 answer
114 views

ConTeXt: Pass text value into text background graphic

Background Looking to draw dynamically-derived text as a "legend" for a paragraph that spans multiple pages. Version: 2023.07.18 22:07 Problem The text doesn't appear where desired. Code ...
Dave Jarvis's user avatar
0 votes
1 answer
222 views

ConTeXt: Round corner for fieldset with title

Background I'm looking to stylize an HTML fieldset-like environment to would allow consecutive "concurrent" sections to appear in the document. Using version 2023.07.18 22:07. Output Example ...
Dave Jarvis's user avatar
5 votes
3 answers
287 views

How to get image-based lettering

How can we get this effect in LaTex/ConTeXt?
青山漫步's user avatar
2 votes
1 answer
53 views

How to treat files generated by mfplain?

Metapost can treat Metafont sources with mfplain. Example: mpost -mem=mfplain cmr10.mf Then each glyph is output in separate file like this: cmr10.0 cmr10.1 cmr10.2 ... I cannot find any tutorial ...
Weißer Kater's user avatar
1 vote
1 answer
95 views

Best ways to draw geometric shapes given "partial" information

I am trying to draw geometric shapes given only "partial" information. Let me show you some examples with triangles: Construct a triangle ABC such that ∡CAB=75°, d(A,B)=40 and d(C,A)=60. ...
user avatar
1 vote
1 answer
194 views

How to define a function in metapost that draw graph based on a string?

In algebraic topology, we need to draw polygon with label that indicate the identification of edges. For example, shows the glue of $a_1$ and $a_1$ along the arrow. My question is how to define a ...
user19832's user avatar
  • 1,585
5 votes
1 answer
229 views

Bisectors the good old compass way

I am trying to reproduce the construction of bisectors with compass. Here is what I managed to get so far vardef bisector(expr A, O, B, r) = save arc, E, F, I; path arc[] ; pair E, F, I[]; % ...
user avatar
1 vote
1 answer
59 views

MetaPost textual does not operate with luamplib

The code picture tex_pct; tex_pct:=btex Too baffled etex scaled 3; for tkn within tex_pct: if textual tkn: show "textual"; fi endfor end. compiled with mptopdf shows 4 "...
Maxime Chupin's user avatar
0 votes
0 answers
79 views

how can I achieve a similar effect in ConTeXt

I am completely new to ConTeXt and have just started to experiment with writing metapost directly within ConTeXt. In Latex , I can use the tcolorbox macro package to achieve the effect of output on ...
青山漫步's user avatar
4 votes
1 answer
172 views

How to achieve the effect of tcolorbox macro package in ConTeXt?

I am completely new to ConTeXt and have just started to experiment with writing metapost directly within ConTeXt. In Latex , we use the tcolorbox macro package to achieve the effect of code on the ...
青山漫步's user avatar
4 votes
3 answers
134 views

Browse all path of an text picture with MetaPost

I want to perform a loop (type within) on all the paths of a text. I tried to build a picture with btex ... etex but it seems that this kind of picture has only one element (length gives 1). I want ...
Maxime Chupin's user avatar
1 vote
1 answer
209 views

Drawing polygons with MetaPost

To draw different kinds of polygons, I use the following code modified from the answer to this post. The original code was designed to draw pentagons. As noticed, when applying this modified code ...
Hany's user avatar
  • 4,927
2 votes
1 answer
62 views

Line from lower left to upper right corner of page with metapost

I have this example where I want to draw a line in the background from corner to opposite corner of the page using metapost, The problem is that the line does not reach both ends, and I cannot figure ...
Salim Bou's user avatar
  • 17.1k
1 vote
1 answer
137 views

Colored math expression metapost

Is there a way in metapost to print a single label (in math notation) like this one label(btex \Large{$3$} etex,(2,-1)); using some specific color like red or blue? Thank you in advance.
Mathland's user avatar
  • 167
1 vote
1 answer
77 views

luamplib creates unexpected files

I compile the following file test.tex \documentclass{article} \usepackage{fontspec} \usepackage{luamplib} \begin{document} \begin{mplibcode} input metauml; beginfig(1); Note.xxx("Hello"...
user2609605's user avatar
3 votes
1 answer
113 views

Extract digits from a number in a metapost plot

Given a possibly big integer (up to $10^12$ or more) is there a way to print the digits of that number in fixed position using metapost? For example given the number 123456789 or 2365411111 is it ...
Mathland's user avatar
  • 167
1 vote
1 answer
71 views

How to color bottom in rectuangular 3d box

I got code from this website. I want to fill bottom in 3D magenta color. How to do that? \documentclass{standalone} \usepackage{tikz} \usetikzlibrary{arrows.meta} \begin{document} \begin{tikzpicture}...
Guest's user avatar
  • 125
1 vote
1 answer
102 views

Is it possible to convert color to array?

I am trying to figure out if it is possible to convert colors to arrays with {red|green|blue}part and this macro vardef arrayFromColors(suffix $)(text c) = save i_ ; i_ = 0 ; numeric $[][] ; for ...
user avatar
0 votes
1 answer
150 views

How to change the font of a MetaPost?

I have the following code in order to create a UML diagram with MetaUML: \begin{mpost}[mpsettings=input metauml;] Class.Task("Task") ( "-id: long", "-name:...
imaginny's user avatar
0 votes
1 answer
159 views

Drawing Phase Diagrams Using MetaPost

I wanted to take the solution provided by @Thruston at phases (stages) of economic cycle. However, when I copied and pasted the first block of code provided as a solution in English, I could not get ...
itc's user avatar
  • 655
15 votes
2 answers
1k views

Is Metapost still relevant in the age of Lua etc.?

Disclaimer: I am not sure if I am "allowed" to ask such a question, but I was also not sure if it belongs to Meta instead. Often when somebody asks a tikz-focussed question, some users ...
Dr. Manuel Kuehner's user avatar
3 votes
1 answer
108 views

Determine whether a path in Metapost/Metafont is a line

Given an already defined path p in Metapost/Metafont: How can I determine whether a segment like subpath (0,1) of p is a line? I am aware that I can simply check if the control points lie on the line (...
Linus Romer's user avatar
2 votes
0 answers
153 views

Making vector fonts from metafont sources in LuaTeX?

According to the presentation "TUG 2020 — Marcel Krüger — MetaPost-based, dynamic extensible delimiters for LuaTeX" it is possible to generate "fully hinted, vector glyphs" from (...
Weißer Kater's user avatar
0 votes
3 answers
56 views

My charts in Metapost are at different scales. How I can improve it?

I have a little problem with my Metapost graphics. My charts are at different scales. I will attach an example of how it looks on the page. On the second graph, you can clearly see its name and the os ...
Michael Znum's user avatar
3 votes
1 answer
93 views

Why does pensquare end lines at an angle?

For example: path p[]; p1 := (0,0)--(5cm,0)--(5cm,5cm); p2 := p1 shifted (7cm,0); p3 := p2 shifted (7cm,0); p4 := p3 shifted (7cm,0); p5 := p4 shifted (7cm,0); linecap := squared; pickup pencircle ...
guidoism's user avatar
  • 289
7 votes
1 answer
212 views

How do I create a pen that only draws on the right side of the path?

Let's say I have a path that represents the inside dimensions of a room. I would like to draw a thin line representing that inside space. But I would also like to draw the thickness of the walls. The ...
guidoism's user avatar
  • 289
1 vote
1 answer
312 views

Unable to read mpx file

This is file of LaTeX: verbatimtex \documentclass[a4paper, 12pt]{article} \usepackage{amsfonts, amssymb, longtable, verbatim} \usepackage[utf8]{inputenc} \usepackage{cmap} \usepackage[T2A]{fontenc} \...
Mr. Linsux's user avatar
3 votes
1 answer
114 views

Is there a way to output SVG from MetaPost with all the fonts outlines?

Suppose, there's an arbitrary .mp file which produces an image with some TeX text labels, e.g.: outputtemplate := "test.svg"; outputformat := "svg"; beginfig (1); draw ...
Sergey Slyusarev's user avatar
1 vote
2 answers
135 views

Metapost in LaTeX (gmp package) - not working

I try to use metapost code inside LaTeX, and I only receive MP Icon insted of dediecated picture: example of code which I want to produce: \documentclass[]{article} \usepackage[T1]{fontenc} \...
Adam Marek Kasprzak's user avatar

1
2 3 4 5
11