The Stack Overflow podcast is back! Listen to an interview with our new CEO.

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
1
vote
1answer
141 views

Getting external variable into metapost in ConTeXt

I'm new to ConTeXt and am trying to make a small theme for my presentations to get to know it better. My slides have a title and a subtitle positioned in the header. I want to have random lines ...
0
votes
0answers
30 views

luamplib: global definitions without inheritance

Is there a way of globally metapost macros using luamplib and without enabling inheritance for mplibcode code blocks? It seems possible since it appears that this is what luamplib does when setting ...
3
votes
2answers
70 views

background color with \mpcolor

I'm using following code and I would like to make the color of the background correspond to that of the beamer style. I tried the command background:=\mpcolor{block body example.bg}; but it does not ...
6
votes
2answers
117 views

Wrap the real right around the trigonometric circle (Metapost)

I am trying to reproduce this figure but I have the impression that alpha does not correspond to the length of the path subpath (0,1.3) of p and that the value -pi/2 is not correct. \documentclass[...
2
votes
3answers
84 views

Fill sectors of a disk (Metapost)

Is it possible to write a more "clean" code to fill the sectors ? \documentclass[border=5mm]{standalone} \usepackage{luatex85} \usepackage{luamplib} \begin{document} \...
2
votes
3answers
94 views

Expand a segment (Metapost)

How to extend the segments [II'], [JJ'] and [AA'] as in the figure ? \documentclass[border=5mm]{standalone} \usepackage{luatex85} \usepackage{luamplib} \mplibtextextlabel{enable} \begin{document}...
1
vote
1answer
43 views

Module luamplib Warning

After an update of Texlive 2019, the following code displays error messages while it was running before the update. The objective is to reproduce the figure below. \documentclass[border=5mm]{...
0
votes
1answer
45 views

Metapost - How to obtain the coordinates of a given point?

Given an arbitrary point, let's say p, that may or may not be obtained by several indirect processes such as penpos or by intersections, how do I get to display the coordinates "(px,py)" of the point ...
0
votes
0answers
49 views

MetaPost graph: how can we make setrange to accept negative coordinates (when numbersystem is not scale)?

I want to plot graph with the MetaPost package graph. I have just noticed that setrange does not accept negative coordinates when -numbersystem is not scale. More precisely, it takes their absolute ...
4
votes
1answer
54 views

Does metapost contain the penstroke abbreviation command?

Hello I am trying to use Metapost to create a font, and I have been using the Metafontbook to study, there it states that the penstroke command is a type of abbreviation command for the command fill ...
3
votes
1answer
54 views

Why does this syntax outputs an error under METAFUN/METAPOST?

Given this MWE (compiled under ConTeXt) \starttext \startMPpage %variables u:=1mm ; numeric l[]; l[1]:=30 ; l[2]:=70 ; draw (0,0) -- (0,100u) ; %this does not work %fill unitsquare xscaled (l[2]-l[...
0
votes
0answers
51 views

SVG output from Metapost with opentype fonts

Is there any way to produce SVG output from Metapost and use opentype fonts for labels (like luatex allows with luamplib and pdf output)?
4
votes
1answer
87 views

Strange behaviour of the btex..etex construct

I have the following code: \starttext \startMPpage def drawtest(expr i) = %i is not used here draw btex dummy etex shifted (0,0); draw btex foo etex shifted (1.5cm,0); draw btex bar ...
0
votes
1answer
53 views

Multiple fonts in single metapost page-sized figure

I have a MetaPost figure created in ConTeXt as follows: \starttext \startMPpage draw textext("Foo") shifted (2cm,2cm) ; draw textext("Bar") shifted (5cm,5cm) ; % just to show my figure is ...
0
votes
1answer
44 views

Which Output file should I export from Metapost?

I am using Metapost software 18.0.1. I have created some plots. How should I export them that I can easily import all plots in Latex?
1
vote
1answer
35 views

metapost with tex label can't work in NOT bin folder but can work in the bin folder,what's the reason?

Win 10 1903 + TeXLive 2019 the fig.mp file are prologue := 3; verbatimtex %&latex \documentclass{article} \usepackage{CJK} \begin{document} \begin{CJK}{UTF8}{gbsn} etex beginfig(1); draw (0,0)--(...
4
votes
0answers
45 views

How to check if a macro is defined in MetaPost

Suppose one may or may not have a macro with a particular name defined in metapost, and depending on what's the case the behavior of the code needs to change in some way. Something like this: vardef ...
0
votes
1answer
86 views

Getting started drawing basic 3D objects with TikZ [closed]

Is it possible to draw this with TikZ (or perhaps a similar package related to postscript, metapost, SVG, etc.)? Sorry, I don't have much to offer this time. I usually like to provide a bunch of code ...
1
vote
1answer
169 views

MetaPost not working

The recent update seems to have broken metapost. Anyone else having problems? The following is a MWE taken from the document that used to compile. Thanks for any help. \documentclass[11pt]{article} \...
3
votes
2answers
50 views

How to fix the MetaPost “Missing argument to arrowhead” error?

I am playing the following code from page 15 in Learning METAPOST by Doing prologues := 3; outputtemplate := "%j-%c.eps"; beginfig(1); save arrowhead; vardef arrowhead(expr p) = save A,u,a,b;...
1
vote
3answers
103 views

Previewing an SVG generated by METAPOST

With v1.8, METAPOST allows one to create an SVG --- unfortunately, there aren't any TeX / code editors which have SVG previewers as far as I can tell. Found: https://code.google.com/archive/p/file-...
5
votes
2answers
324 views

Is there any other simpler way to draw the following cross section?

Given that a regular pyramid T.ABCD in which P is on TC such that TP:PC = 1:3 R is on the extension of BC such that BR:BC = 1:3 Q is arbitrarily on the plane TAD but neither outside nor on the ...
2
votes
3answers
100 views

How to globally set the font for all MetaPost drawings in ConTeXt?

When I add labels to MetaPost drawings in ConTeXt, it does not use the fonts for the rest of the document but appears to be using either a math font or the default fonts used by ConTeXt. I can set the ...
3
votes
1answer
62 views

Why can't this MetaPost drawing be placed more than once in ConTeXt?

I used the code at How to conditionally draw parts of a MetaPost drawing in ConTeXt? to display a crossword puzzle. The code works great, until I try to display another crossword puzzle, at a later ...
6
votes
2answers
134 views

ConTeXt: MetaPost graphic in overlay setups shifts between pages

Background A line is being drawn using MetaPost on an overlay, which is used as the background for a framed layer. The layer is embedded within a setups so that a dot's position on the timeline is ...
1
vote
3answers
90 views

How do I change the font of a graphic in latex?

I started working on a simple UML diagram for a final Java project. I started by reading a lot on the metauml github repository and this example in particular. As you can see by the attached image, ...
2
votes
2answers
111 views

How to conditionally draw parts of a MetaPost drawing in ConTeXt?

The basis of my problem is I am making a 14x14 crossword puzzle, I have the data for each of the 196 cells from an outside document, but need only the cells with text inside to have borders. I tried ...
2
votes
1answer
73 views

How to scale MetaPost drawings with consistent line width and label text size in ConTeXt?

I am using MetaPost to create some simple drawings in a ConTeXt document. In this example, I have a row of 14 boxes: \startMPcode draw (0,0)--(100,0)--(100,100)--(0,100)--(0,0); draw (100,0)--...
4
votes
1answer
65 views

How to stop MetaPost drawings from overlapping on different lines in ConText?

I have an itemized list. On several lines there are some boxes, drawn in MetaPost. I used \inframed[location=line] to make them vertically centered on the line. The problem is, they are overlapping ...
1
vote
0answers
56 views

Implement METAPOST in Blockly [closed]

Has anyone looked into this? Blockly is a visual code editor developed by Google: https://developers.google.com/blockly/ and at least one graphical language, OpenSCAD has been implemented: https://...
1
vote
1answer
41 views

MPINPUTS of metapost

When I ran mpost in a source directory, it worked fine. When I set MPINPUTS with $export MPINPUTS=./src, I saw an error I can't find the 'plain' preload file! I wonder if my export command somehow ...
6
votes
2answers
287 views

Drawing all planes passing through two given points in a cube

Is there a smarter way to find a collection of possible planes passing through 2 given points P on ABFE and Q on DCGH such that we can see that the point R is the intersection of PQ and the common ...
1
vote
1answer
71 views

How to draw the intersection of a circle and a path in METAPOST

How do I draw only the two sides of the circle which would be left after subtracting the heavy red line? \documentclass{article} \usepackage{luacode} \usepackage{luamplib} \usepackage{calc} \...
3
votes
1answer
60 views

How to draw braces over segment in metapost?

I want to draw brace over straight line it Metapost. In LaTeX, I can draw brace like following: \documentclass[12pt]{article} \usepackage{amsmath} \begin{document} \overbrace{text} \end{document}...
1
vote
1answer
58 views

Blank Boxes with mfpic in exam class

I'm working on a document that uses mfpicand would like to compile without having to do mpost every time. I tried to use the code given in this post, but have been unsuccessful. MWE: \...
0
votes
0answers
33 views

How to set stereotype on class parameter or method in MetaPOST

I want to be able to set event stereotype on a method, inside a class. I've read through the documentation, but found nothing on this subject. As shown below, the <<<event>>> part ...
6
votes
2answers
423 views

Color Mickey with hatching (Metapost)

I want to reproduce the image below with Metapost. I think this code is too long and the result is not exactly the expected one. beginfig(1) input hatching ; hatchoptions (withcolor red); path p, q,...
6
votes
1answer
92 views

mptopdf: Is multipage output (PDF) possible?

I have this MetaPost input file: %@ Maxime Chupin %@ 4 février 2017 %@ animCercle.mp prologues := 3; outputtemplate := "svg/%j-%c.svg"; outputformat := "svg"; % unité u:=1cm; %rayon cercle r:=5u; %...
2
votes
3answers
75 views

metapost “ missing `,' has been inserted.” compilation error

I'm quite new to this language and can't figure out the error in following code. Any help would be appreciated ! verbatimtex \documentclass{article} \usepackage[T1]{fontenc} \usepackage{mathptmx} \...
1
vote
1answer
100 views

Help with MetaPost and Metaobj with latex

Kind help with two examples to do metapost and metaobj in latex running from Texicenter. what packages to include and program two examples I read through book not able to understand. First input ...
1
vote
2answers
78 views

How to limit amount of numbers after comma in metapost?

I would like to limit floating point numbers inside a label: beginfig(1) for i=1 upto 5: label.bot(textext("$" & (decimal (-0.8*i)) & "$"), (-0.8*i, -0.2)); endfig; end; Currently ...
2
votes
1answer
70 views

The Metapost path fullcircle

Is the MetaPost path fullcircle cyclic? I attempted to find the answer in "METAPOST - A User's Manual" but had no luck. UPDATE: show cycle fullcircle; will print the answer true.
2
votes
2answers
47 views

How to specify degree of rounding in “rboxes” package?

Consider this test.mp: prologues:=3; input rboxes; beginfig(1); rboxit.box1(btex hello world etex); box1.dx=3mm; box1.dy=2mm; box1.c=(8.8cm,4.5cm); drawboxed(box1); endfig; end It yields this: How ...
3
votes
2answers
84 views

How to use previous points of a path to specify next?

Consider this test.mf: draw (10,20)--(10+100,20)--(10+100,20+50)-- (10+100+30,20+50)--(10+100+30,20+50-40); showit; end Is there a way in metafont/metapost to draw a line of given length in a ...
1
vote
1answer
82 views

Input variable as argument in metapost script?

I would like to pass input parameters into my .mp script. For example, instead of running: mpost script.mp I want to run something like: mpost script.mp 1 1 2 diamand Where "1 1 2 diamond" are 4 ...
2
votes
1answer
92 views

Strange white outline around vertices in graphs made by TikZ [closed]

In Metapost I was able to make a graph where there's no gap between the edges and vertices: But in Tikz there is a gap between the two: Making a black "border" around the vertex did not help. No ...
3
votes
1answer
109 views

How to use MP labels with PK fonts?

Run mf \\mode=localfont\; input test.mf on the following file: mode_setup; beginchar("e",10pt#,7.5pt#,2.5pt#); pickup pencircle scaled (.4pt+blacker); draw fullcircle scaled .2w shifted (w/2,(h+d)/2-...
2
votes
1answer
45 views

Why custom TEX command for labels does not work in MetaPost?

I'm trying to use text labels in MetaPost with TeX. The problem is that -tex=... option of MetaPost does not work. This example works with mpost test.mp: prologues := 3; beginfig(1); label.lrt("e", (...
6
votes
1answer
113 views

METAPOST equivalent to TikZ polar coordinates?

When drawing with TikZ, I find sometime convenient to use polar coordinates (angle:distance), as in this MWE \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture} [pole/....
3
votes
1answer
69 views

How to put two metapost graphs in the same row in LuaLatex?

I draw graphs using metapost in LuaLatex. It is more convienient than first use metapost to create graphs and then insert the graphs. But I don't know how to put two graphs in the same row. For ...