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
36 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
42 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
37 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
25 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
400 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
65 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
59 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
78 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
62 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
55 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
41 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
70 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
45 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
85 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
86 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
39 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", (...
5
votes
1answer
76 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
49 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
65 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
97 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
42 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
132 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
261 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
70 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
72 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
53 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
99 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
73 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
103 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
103 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
55 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
373 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
47 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
97 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
203 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
265 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?
1
vote
1answer
108 views

Getting the path of a pen stroke in metapost

Suppose I have some fairly trivial metapost code: outputformat := "svg"; outputtemplate := "%j-%c.svg"; beginfig(1); pickup pencircle scaled .2in yscaled .2 rotated 30; u := 36; z0 = (0,0)...
0
votes
1answer
79 views

Canvas size and margins in Metapost

I've been looking for a way to specify explicitly the size of my canvas and the margins in Metapost. It is possible? If yes, how? Thanks!
1
vote
1answer
88 views

In Metapost, access the points of a path copy

In Metapost, I want to copy a path and be able to address the points directly. I tried this, but it seems like pp1 doesn not exists. Any idea how to do it? beginfig(1); pair p[]; p1=(0,100); ...
0
votes
0answers
88 views

Create Component does not work! MetaUml: Using MetaPost in LuaLaTeX

I am trying to create a component diagram using MetaUml embedded in TeX using LuaLaTeX. Every example form the manual I tried, worked well except from components. \documentclass{article} \usepackage{...
4
votes
1answer
102 views

ConTeXt: Multiple colour stops for linear_shade

Background Looking to parameterize a horizontal rule (for headers and footers) that has three colour stops (A to B to C) and a variable thickness. For example: Single Stop Code The following code ...
4
votes
1answer
222 views

How to draw a tree-like diagram with partially shaded nodes? [closed]

I would like to draw this figure but I don't know how I can do this. Can someone help me and give me advice? I appreciate any help! Here are at least the input symbols: \documentclass{article} \...
3
votes
1answer
61 views

Interaction between rotated and externalfigure

In the following snippet, I'm rendering a rotated square and two images. If rotated 0 is used, then everything works, but if rotated 1 is used, then the second image gets shifted to the left ...
3
votes
0answers
93 views

Boundary of a path as a new path?

Is it possible to use the boundary of a shape defined as some path as a new path? In the following example \documentclass{article} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=3] \...
3
votes
1answer
278 views

Help with drawing in MetaPost

My drawing with MetaPost looks like: I need to solve the following in the graph: Making the ends of the hyperbolas parallel with the two dashed lines Labelling the two focus points F like F_1 and ...
2
votes
1answer
97 views

Metapost: pass 2D array in vardef

Can we pass 2D array in vardef? Followed is a small code. It failed to compile. outputtemplate := "%j-%c.eps"; prologues := 3; input boxes beginfig(1) vardef table (expr upper_left_centre, row, col,...
1
vote
0answers
65 views

Metapost: define <label suffix⟩> in vardef

In label.top("foo", origin), top is label suffix. Can I pass label suffix by function call? Given suffix qqaa: vardef (suffix qqaa)foo (expr ...) label.qqaa("whatever", origin); enddef; I don't ...
3
votes
2answers
153 views

How to make a custom closed curve independent from other closed curves in a single pscustom?

It is related to my previous question but with a little bit different requirement. Rather than editing the previous one that potentially makes "inconvenience" to the accepted answer, let me ask it ...
1
vote
0answers
109 views

Lualatex: landscape for some page (every page from metapost code)

I want to landscape some pages and keep other pages portrait. Each page is a picture from metapost. I compile in lualatex. Google tells me to use the package lscape or pdflscape for the purpose of ...
0
votes
1answer
146 views

Metapost for loop of a list

Suppose I have a array of path path pat[]; I try to define a function like this: def drawpaths(expr plists)= for p in plists: pickup defaultpen; draw pat[p]; endfor enddef so that I can ...