Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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}.

1
vote
1answer
50 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
31 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
79 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-...
4
votes
2answers
262 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
71 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
45 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
97 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
71 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
83 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
47 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
59 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
42 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
30 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 ...
7
votes
2answers
266 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
60 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
48 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
39 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
405 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
78 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
66 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
85 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
67 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
60 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
43 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
75 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
54 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
90 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
95 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
42 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
87 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
55 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 ...
2
votes
1answer
67 views

How to make the vertices not connect to arrows?

I draw the following graph in Metapost. How to make the vertices of the subgraph with red edges not connect to arrows. The graph I obtained is I want the vertices looks like the following picture (...
2
votes
2answers
125 views

How to draw arrows on curves in Metapost

I need to draw the following graphs using Metapost. How to draw the arrows on curves? Thank you very much.
2
votes
2answers
46 views

Problem with package gmp: \sqrt in label

It is quite weird that the gmp package cannot corporate with \sqrt in label. The MME on overleaf: \documentclass{article} \usepackage[shellescape,latex]{gmp}%nowrite \usempxclass{amsart} \...
3
votes
1answer
200 views

How to run metapost?

I have tried to run metapost with the command: mpost myfigure.mp I got an error which I've seen a lot of people ask about: Sorry, I can't find the 'mpost' preload file; will try 'plain'. I can'...
3
votes
2answers
286 views

How to even start learning MetaPost using Windows?

I got interested in learning MetaPost but for some reason i can't find any reliable source on where i am supposed to start. All the manuals and guides i found start literally out of nowhere and what's ...
5
votes
1answer
75 views

graphicx regression in TL 2018? \convertMPtoPDF undefined in preamble

Consider the following MNWE: \documentclass{article} \usepackage{graphicx} % \input{supp-pdf.mkii} \newbox\mypic \sbox\mypic{\includegraphics[height=6.5ex]{moral-compass-lliw10}} \begin{document} ...
2
votes
1answer
75 views

How to normalize the coordinate without changing the object size?

The following MWE produces \documentclass[pstricks,border=12pt,12pt]{standalone} \usepackage{pst-circ} \psset { unit=1cm, dipolestyle=zigzag, } \begin{document} \begin{pspicture}[showgrid=...
1
vote
2answers
59 views

metapost vardef returning multiple values

I need to write a metapost vardef returning several numerical values. Metapost seems to allow returning only one value. How to make a metapost vardef returning multiple numerical values?
4
votes
2answers
104 views

Metapost (Graph) LuaLaTeX: intersectionpoint - graph with line not what intended - why?

Good morning! Trying around as MP-Newbie since days to get a correct intersection between my graph p and a horizontal line in red. The point in my example is at the red trianlge in the left bottom. ...
1
vote
1answer
78 views

What is the easiest way to find MetaPost definitions?

What I currently do is that I just use grep to search all files in the MetaPost tree for a keyword, e.g. grep -r withdots `kpsexpand -v '$TEXMFDIST'`/metapost and then scan the output by eye to find ...
1
vote
1answer
112 views

luamplib Multiple beginfigures

I'd like to include a METAPOST file that contains multiple beginfig blocks in my LuaLaTeX document. I'm including the file using input filename ; within a mplibcode environment, but this just places ...
0
votes
1answer
108 views

How can I compile Metapost code using PdfLaTeX?

I'm working on the website ShareLaTeX and I want to adapt the code giving by thruston in this link with the compiler PdfLaTeX instead of LuaLaTeX. I already tried to change the compiler in ShareLaTeX ...
0
votes
0answers
57 views

Tablor package with metapost files generation

I want to use the tablor package but I get an issue with the compilation of the metapost file. Here's my tableau_variation.tex file : \documentclass{article} \usepackage{graphicx} \usepackage[...
17
votes
3answers
392 views

wood pattern with metapost

I need to draw few diagrams like this with MetaPost. So I want to create a wood-pattern-filling-function and use it few times. Is there a good way to do it? I think to generate a random function, ...
1
vote
1answer
51 views

Metapost error ! An expression can't begin with `]'

I am trying to reproduce the examples in Metapost showed here but I am having this error: ! An expression can't begin with `]'. 0 ] l.12 vector e[] ...
1
vote
1answer
99 views

Does LaTeX use METAPOST to generate pictures?

This is a sort of continuation to this question. I would like to know how does LaTeX generate pictures with its 'picture' environment. Since TeX deals with typesetting and not with graphics, I ...
5
votes
1answer
248 views

How to check if a given point is inside some closed path in MetaPost

If there is some arbitrary closed path (without self intersections) in MetaPost, is there a simple way to check if a given point falls inside or outside of it? For example: path p; pair q, r; p := (-...
1
vote
2answers
299 views

Vary font size in Metapost

I would like to vary font sizes in Metapost ... like draw btex \small Text etex shifted(0cm, 1cm) and so on ... but cannot work out how to do this. Is there a way?