Stack Exchange Network

Stack Exchange network consists of 174 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}.

2
votes
1answer
41 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
34 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
59 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
35 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
83 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
71 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
36 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
63 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
41 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
48 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
79 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
37 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} \...
2
votes
1answer
82 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'...
2
votes
2answers
217 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
67 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
70 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
50 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
90 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
67 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
92 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
53 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
333 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
45 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
95 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
153 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
224 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
102 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
64 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
75 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
85 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
96 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
210 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
55 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
81 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
254 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
87 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
56 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
149 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
100 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
123 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 ...
1
vote
1answer
132 views

Metapost: vardef - draw a picture and return pairs

In a vardef, I draw a picture and I want to return the pairs of the picture. Followed is small code. It can draw the picture - "I" shape but I don't know how to return the pairs - p[]. If I uncomment ...
1
vote
0answers
84 views

Draw a PhotoGate apparatus

Is there a way to improve a schematic representation of PhotoGate apparatus? These instruments are widely used in Physics, so it would be interesting to get a good representation of it. I would like ...
5
votes
1answer
94 views

Metapost graphics not aligned in ConTeXt TABLE

I am using TABLE to design map legend. Symbols should be middle-aligned. As said in the title, the metapost graphics used as symbols are not aligned in my TABLE environment (column 1 and 3), whereas ...
10
votes
3answers
497 views

Format decimal(i) numbers

What is wrong with this code? \startMPcode numeric u; path yy; u:= 3cm; for i=0 step 2/10 until 2: draw (left--right) shifted (0,i*u); label.lft(textext(decimal(i)), (-2,i*u)); endfor; yy = (down-...
0
votes
1answer
117 views

Metapost: scale a picture

If I define a picture, how can I scale the picture by a scale factor? For example, if the scale factor is 5, then the target will be as 5 times as the size of the defined picture. The scale factor ...
2
votes
1answer
85 views

Metapost: get the radius of circle box

Followed is a small code. I want to get the radius of circle box. If I put the last sentence before the drawboxed command, the compilation failed due to unknown pair. It looks like only after drawing ...
1
vote
1answer
100 views

Lualatex: using verbatimtex in metapost

I want to use verbatimtex in metapost and compile it in lualatex. Followed is a small code. But it failed. I have googled and added verbatimtex block here and there but no lucky. Please help. Thank ...
1
vote
1answer
105 views

Metapost: text along a line

Followed is a small code to show text along a line. The "bar" is what I want. My question is how I can get the "bar" case no matter from "A to B" or "B to A'. Generally, I want to draw a line and ...
6
votes
4answers
956 views

How to draw the following diagram with tikz?

I want to draw the following diagram Where $BE$ is a tangent at $B$. Here is my MWE \documentclass[margin=10pt]{standalone} \usepackage{tikz} \begin{document} \begin{tikzpicture}[scale=4.0, axes/....