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
3 votes
1 answer
58 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
1 vote
1 answer
78 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
  • 11.4k
0 votes
1 answer
140 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
  • 11.4k
5 votes
3 answers
239 views

How to get image-based lettering

How can we get this effect in LaTex/ConTeXt?
青山漫步's user avatar
2 votes
1 answer
34 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
69 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
85 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
197 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
32 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
50 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
143 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
104 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
0 votes
1 answer
143 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,637
2 votes
1 answer
49 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
  • 16.8k
1 vote
1 answer
82 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
64 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
88 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
67 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
81 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
82 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
128 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
  • 600
15 votes
2 answers
961 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
86 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
107 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
43 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
83 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
  • 269
7 votes
1 answer
188 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
  • 269
1 vote
1 answer
169 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
61 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
92 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 vote
2 answers
67 views

Mixed cut{after,before} keep line from fullcircle

I have a very simple code to get the angle from two vectors made of three points, that uses cutafter and cutbefore. vardef arc(expr o,a,b) = path c, d, e ; c = fullcircle scaled u shifted o ; d ...
user avatar
2 votes
1 answer
121 views

How to expand a variable

I am not sure about the title of this question but here is the context. Let's say I have two colors defined as follow color red ; red = (1, 0, 0) ; color lightred ; lightred = (1, .5, .5) ; ...
user avatar
2 votes
1 answer
59 views

Scaled a path without losing its center position

path p ; p = (1u,1u) -- (1u,3u) -- (3u,3u) -- (3u,1u) -- cycle ; draw p ; draw p scaled 2 withcolor red ; The center of the red square is moved from (2,2) to (4,4) but I want it to stay at (2,2). Of ...
user avatar
2 votes
2 answers
81 views

How to draw/fill any path around labels?

Is there any way to draw and/or fill any path around labels in MetaPost/MetaFun? According to the manual (page 27) we can use fill/unfill with bbox and thelabel, however there is nothing about, let's ...
user avatar
0 votes
0 answers
46 views

Can I create function in MetaPost? [duplicate]

There are function in programming languages, for example function f(int x){ return x*x; } Can I use something similar in MetaPost?
Mr. Linsux's user avatar
0 votes
0 answers
47 views

Call metapost with command line arguments through shell-escape; then include the resulting graphics

I would like to use metapost to draw long curved lines and overset the resulting images over long subformulas instead of relatively short widetilde. Would be great if I can choose not from the set of ...
Vadim Radionov's user avatar
0 votes
1 answer
68 views

Fill an angle using Metapost

How to fill angle using intersectionpoint and intersectiontimes primitives ? \documentclass[border=5mm]{standalone} \usepackage{luamplib} \begin{document} \mplibtextextlabel{enable} \begin{...
Fabrice's user avatar
  • 3,596
3 votes
2 answers
82 views

fill a circularpath around point 0

I am trying to fill a portion near point 0 of a circularpath. path circle ; circle = circularpath(10) scaled 200 ; pair a, b ; a = point 35 of circle ; b := point 5 of circle ; fill buildcycle((...
user avatar
10 votes
2 answers
217 views

Why changing the catcode of : cause epsfbox to fail?

I have the following very simple TeX file: \input epsf \catcode`\:=\active\def:{\thinspace\string:} a: b \centerline{\epsfbox{test.1}} \bye with test.mp containing beginfig(1); draw (0,0) -- (100,...
user avatar
0 votes
1 answer
74 views

Metapost figures with ttf fonts via XeLaTeX

I use Metapost to create pdf figures to include in the book I am writing. I usually create pdf files with the command TEX=latex mpost figure.mp and then I convert the output files figure.1, figure.2 ...
Massimo's user avatar
  • 697
1 vote
1 answer
136 views

Create tick marks on a segment

The idea is to reproduce the figure such that point U has abscissa -5/7 and point P has root 13. My practice of Metapost is not sufficient to finish the figure. \documentclass[border=5mm]{...
Fabrice's user avatar
  • 3,596
3 votes
2 answers
210 views

Vector Field in Metapost

I would like to recreate this graph in Latex, but I saw it complicated so I was inclined to do it in Metapost: s:=1.5cm ; vardef u(expr x,y) = (y+x*x-0.25*x*(y-1+2*x*x)) enddef ; vardef v(expr x,y) = ...
Zaragosa's user avatar
  • 561
7 votes
2 answers
280 views

Strange mod operator behavior in metapost

I am currently facing a strange behavior of the metapost mod operator. Here is a simple piece of code: \startMPcode for x = 0 step .5 until 10: if (x mod 1) = 0.5: label.top(x, (x*cm, 0cm)) ;...
user avatar
1 vote
2 answers
78 views

Fill in Metapost Figure constructed in FOR loop

I'm trying to create a wheel cog in Metapost that I would like fill in with a color. I came up with this code: vardef sin(expr xx) = sind(xx) enddef; vardef cos(expr xx) = cosd(xx) enddef; beginfig(1) ...
maxwell79's user avatar
1 vote
2 answers
68 views

filling an area between curves using metapost

How could I fill the area between p2 and p3 ? I tried using the buildcycle macro but it didn't work. path p[]; p1 = fullcircle xscaled 1.2in yscaled 0.6in; p2 = (-1cm, 0)..(0cm, -0.2cm)..(1cm, 0) ...
Mechap's user avatar
  • 125
0 votes
1 answer
37 views

How to use minted inside metapost

When I try to use minted with metapost (using luamplib) \begin{mplibcode} beginfig(3); picture P; P = thelabel(btex \vbox{\begin{minted}{c++} int main() { return 0; } \end{minted}}...
Mechap's user avatar
  • 125
0 votes
1 answer
150 views

Tikz Adjustment of selfsimilar sets [closed]

I have found open source figures of fractals in a PDF document and I like the presentation and style of these fractals. Now I wanted to create similar fractals, maybe the Koch curve or the Cantor set ...
calculatormathematical's user avatar
2 votes
0 answers
97 views

Metapost not centering label in circle

I'm working on a document created in Plain TeX that contains many figures created with Metapost. Many are letters centered in a circle. With a recent upgrade to: MetaPost 2.00 (Web2C 2021) the text ...
maxwell79's user avatar
1 vote
1 answer
142 views

Drawing 2d and 3d vectors using lua or luamplib in LaTeX

Here is the tikz code using which vectors can be drawn. \documentclass{article} \usepackage{tikz} \usepackage{tikz-3dplot} \usepackage{amsmath} \begin{document} \tdplotsetmaincoords{60}{120} \begin{...
user61681's user avatar
  • 1,729
0 votes
1 answer
94 views

Dance of Planets in geocentric system in TikZ/PGF

Im using code from Dance of Venus (and variations) in TikZ/PGF Im using \documentclass[border=5mm]{standalone} \usepackage{luamplib} \begin{document} \begin{mplibcode} beginfig(1); draw for t=0 ...
Kamil666777's user avatar

1
2 3 4 5
10