Last call to make your voice heard! Our 2022 Developer Survey closes in less than a week. Take survey.

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
0 votes
1 answer
26 views

Text along a curve in Metapost

Does anyone have any suggestions on how I might get text along a curve in Metapost?
user avatar
3 votes
2 answers
117 views

Problem fitting a right angle

Why the right angle does not fit with a rotation angle of 90 + 15 ? \documentclass[border=5mm]{standalone} \usepackage{luatex85} \usepackage{luamplib} \begin{document} \...
user avatar
  • 3,482
8 votes
3 answers
313 views

Adding Column Rules in ConTeXt's columnsets / pagecolumns

This is my first time playing with ConText and, while I'd like to think I have some decent programming experience, TeX code is something I've never worked with before (and am sufficiently intimidated ...
user avatar
  • 81
0 votes
1 answer
37 views

Problem with latex labels using btex and etex in METAPOST

The following simple METAPOST code does not compile without error: verbatimtex %&latex \documentclass{article} \begin{document} etex beginfig(1); z0 = (0,0); z1 = (sqrt(3)*cm,0); z2 = (sqrt(3)*cm,...
user avatar
  • 103
1 vote
2 answers
39 views

Label number in loop "for" in metapost

I first create ten points p[1],..., p[10] in MetaPost. Afterward, I use the following loop: for i = 1 upto 10: dotlabel.bot(btex i etex, p[i]); endfor then it creates in the pdf file 10 letters '...
user avatar
2 votes
1 answer
78 views

ConTeXt: Equivalent to \linewidth

I'm thinking about switching from LaTeX to ConTeXt. I'm using LaTeX extensively to create teaching materials with an extended version of xsim. There are a lot of things I would need to port, one of ...
user avatar
  • 53
5 votes
1 answer
118 views

How to use metapost(.mp) file in .tex file in overleaf

This question might be very silly but I am new in latex and I can’t find a possible solution to my problem. I am making a latex document in overleaf and I have to use diagrams so I am trying to ...
user avatar
  • 53
4 votes
2 answers
138 views

Drawing dashed closed paths with Metapost

Dashed closed paths usually look lame near the beginning of the path. beginfig(1); fill fullcircle scaled 300 withcolor white; draw fullcircle scaled 250 dashed evenly scaled 3; endfig; To achieve ...
user avatar
  • 143
0 votes
0 answers
45 views

How to use MetaPost with TecTonic?

Is there a way to get MetaPost running in Tectonic? I've tried it with \usepackage[shellescape]{gmp} but it fails at some \write18 command. I think there is some error with handling file system paths. ...
user avatar
  • 747
2 votes
1 answer
65 views

Dynamically defining metafun positional variables with \structurelistuservariable in ConTeXt

Following on from this question, I am now trying to achieve the same effect (drawing with metafun in the TOC, from the section number to the edge of the page) using positional overlays instead. ...
user avatar
  • 65
4 votes
1 answer
95 views

Drawing from a framed overlay to the page edge in ConTeXt and Metafun

Using ConTeXt for typesetting and metafun to draw, I would like to create a custom colored overlay for my table of contents. I want to fill a colored rectangle for certain TOC entries that stretches ...
user avatar
  • 65
1 vote
1 answer
57 views

Text processing in MetaPost during compilation of a LaTeX file

In a LaTeX document, I use a number of packages, many different commands created for the convenience of typing, non-standard fonts. I'd like to use it all inside MetaPost. The problem is that the text ...
user avatar
4 votes
1 answer
65 views

Metapost : Can I have a path which is partially unconnected

Hello Metapost user , Can I have a path which is partially unconnected in the middle. The code I am expecting : path p ; pair A, B, C, D, E, F ,G ; A=( 0, 0) ; B=(10, 0) ; C=(10,-10) ; D=(20,-10) ...
user avatar
4 votes
1 answer
127 views

Named MetaPost instances in LuaLaTeX

Is there anything similar to ConTeXt's \defineMPinstance for LuaLaTeX? I need to be able to have several MetaPost instances with their own sets of variables, something like this: \begin[instance_one]{...
user avatar
1 vote
1 answer
69 views

Metapost: how to build a cycle path for the picture to hatchfill?

Followed is a minimum example to show my problem. I want to hatchfill the Cee section. I don't know how to build the cycle path for the hatch. I have tried buildcycle but failed. How can I add the ...
user avatar
  • 3,087
3 votes
2 answers
90 views

Text label in MetaPost: language support

I am working with the example: beginfig(1); label.urt("Текст на русском.", origin); label.llft("Text in English.", origin); endfig; The output contains: Missing character: There ...
user avatar
  • 515
5 votes
1 answer
49 views

MetaPost's undraw does not remove the whole border

I am running the example: # := 0.5cm; beginfig(1); path tr; tr := origin--(2#, 5#)--(8#, 5#)--(10#, 0#)--cycle; color cl; cl := 0.7(green + blue); pen p; p := pencircle scaled 2mm; filldraw tr ...
user avatar
  • 515
0 votes
1 answer
54 views

MetaPost: mpost and plain.mp

Am I right that 'pure' MetaPost (mpost), without plain.mp, knows only primitive commands? So that MetaPost compiler + plain.mp is like a pure TeX + PlainTeX or TeX + any other macros package? Is it ...
user avatar
  • 515
1 vote
1 answer
36 views

MetaPost vardef: how to declare a variable of type 'expr'?

I want to make a macro swap: vardef swap(expr a, b) = save tmp; expr tmp; tmp := a; a := b; b := tmp; enddef; But there is an error when compilating: ! A statement can't begin with `expr'. I ...
user avatar
  • 515
3 votes
2 answers
79 views

MetaPost: does btex ... etex support any LaTeX command?

I am running a MetaPost sample as follows: beginfig(1); label.(btex the \emph{sum} is $\sum\limits_{n=1}^{+\infty}a_n$ etex, (3cm, 3cm)); endfig; end; by mpost main.mp. In the log there is a message !...
user avatar
  • 515
5 votes
1 answer
94 views

Metafont/Metapost — Find a path tangent through the external point

Assuming that I have the path P given, and let the T be a point outside the path P. Is there an easy way to find the point X on the path P such that the tangent on point X going through the point T? ...
user avatar
  • 273
3 votes
1 answer
61 views

Metapost: variable name with number at the end

Why can't I use variable names like a1, str2, x12? Does Metapost consider them as arrays so that a1 is like a[1] and so on? Even z-notation as z1, z2 and etc. does not work. The code is beginfig(1); # ...
user avatar
  • 515
1 vote
1 answer
79 views

Using feynmp in overleaf

I'm trying to create this diagram in overleaf: I can create this on texstudio by using the package feynmp, the code is as follows: \begin{fmffile}{diagram} \begin{fmfgraph*}(100,50) \fmfcmd{ ...
user avatar
0 votes
1 answer
109 views

How can I use Lua's string.len() inside a metapost function?

I am designing pseudo-crosswords for my pupils exercices with the following macro: \startMPinclusions % could'nt achieve using the word string length as a first parameter vardef MotMystere (expr ...
user avatar
  • 2,952
2 votes
3 answers
376 views

How to plot displacement and acceleration from a piecewise velocity function?

Given a velocity function in piecewise form. The objective is to plot both the displacement s(t) and accelaration a(t). I have no idea to use Derive when the function v(t) is in postfix form. whether ...
user avatar
  • 2,383
2 votes
2 answers
114 views

Using sans as a default font in ConTeXt Metapost

When using metapost in ConTeXt, I would like to have all my labels in sans by default. Which option can configure it and which environment should I use to pass it (MPinclusions?) I am aware of this ...
user avatar
  • 2,952
5 votes
5 answers
509 views

How to conveniently plot a list of various transformed functions y=a|f(b|x+c|)|+d of a piecewisely-defined fundamental function y=f(x)?

I have a fundamental function y=f(x) given piecewisely as follows. I want to plot a list of its transformed functions (such as y=af(bx+c)+d, y=a|f(b|x+c|)|+d) as conveniently as using Mathematica. ...
user avatar
  • 2,383
0 votes
1 answer
117 views

How do I use LaTeX commands inside the body of mpost? (metauml + gmp)

I am on Overleaf, using gmp + metauml to create a UML class diagram, in which I wish to use LaTeX commands to better format the text. I tried my best to read the manuals for both packages and scour ...
user avatar
4 votes
2 answers
343 views

ConTeXt LMTX: Offset on page titles with MetaPost

I want to do some silly Metapost stuff with chapter titles, so set a command to begin with: \setuphead[chapter][command=\ChapterTitle] And on that custom command I threw the following to pass both ...
user avatar
  • 357
2 votes
1 answer
98 views

ConTeXt: Add exterior padding to framedtext

Background Looking to adjust the exterior padding of a METAPOST graphic used as the background for a framedtext. ConTeXt version 2021.05.15. SSCCE Pilfered from the mailing list: \startuseMPgraphic{...
user avatar
  • 10.9k
6 votes
1 answer
305 views

How to create an animation that deforms gradually a flat circular sector to a cone?

I want to create an animation that gradually deforms a flat circular sector to a cone. I am inspired by a question titled How to deform a 2d shape to make a 3d object?. The following source code can ...
user avatar
  • 2,383
3 votes
1 answer
73 views

Accuracy of a junction between an arrow and a segment (Metapost)

The junction between the end of the arrow and the segment is not precise:why and how to correct this ? \documentclass[border=5mm]{standalone} \usepackage{luatex85} \usepackage{luamplib} ...
user avatar
  • 3,482
0 votes
0 answers
39 views

MetaUML Adds Extra Vertical Spaces

MetaUML seems to add extra vertical space to the class members. As you can see only the fourth and fifth elements are aligned properly. The image was generated by pdflatex using the following code: \...
user avatar
1 vote
0 answers
19 views

metapost making use of hyperref to other page /2nd question

I think my previous posting is a mess with uncleaned format. So I'm posting revised one. I am using lualatex 2020 and can make use of "\label{A:aaa}" and "\ref{A:aaa}" to make ...
user avatar
2 votes
1 answer
102 views

alignment of label text in metapost

I have a simple question. label(btex AAA etex, (0,0)) ; label(btex AAAAA BBBB CCCC etex,(0,-10)); The above statements gives center-alignment. Then how can I make left or right alignment ? I tried ...
user avatar
4 votes
1 answer
72 views

how to use verbatim inside Metapost

I am trying to put verbatim text using minipage inside Metapost. It seems working outside Metapost but not working inside. Any help would be appreciated. \documentclass{article} \usepackage{luamplib} \...
user avatar
8 votes
3 answers
160 views

how to use metapost newinternal variable

I am trying to convert the statement drawarrow (0,0)--(100,100) dashed evenly withcolor green; to newinternal string varA ; varA := "dashed evenly withcolor green" ; drawarrow (0,0)--(100,...
user avatar
1 vote
2 answers
139 views

Coloring the boxes created by boxit command

I am trying to change background color and text color of the boxes made by boxit.bb1() and tried to look for drawoptions from John Hobby's manual but I could not find any related to it. I'd appreciate ...
user avatar
1 vote
0 answers
62 views

ConTeXt : using \MPtext in different textbackgrounds [duplicate]

I am trying to change my theorem environment, and I played a little with MetaPost (that I don't know well, being more of a TiKz user). I ended with this layout (which I really like) with the help of ...
user avatar
  • 995
1 vote
0 answers
175 views

Tensor symbol as vertex in feynmp

Consider the following example \documentclass{memoir} \usepackage[margin=0.05cm]{geometry} \usepackage[force]{feynmp-auto} \usepackage{amsmath} \begin{document} \setlength{\unitlength}{.09cm} \begin{...
user avatar
  • 661
5 votes
2 answers
167 views

METAPOST syntax to set all values of an array at once

I would like to set all values of a METAPOST array in a single line as I would write in other programming langages. In all of the examples I could find, or the manuals example, one defines array ...
user avatar
  • 153
0 votes
1 answer
104 views

Convert a path to string / save path to a file in MetaPost

Is there a way to convert a path to a string [save it to a file, read it] and convert it back to a path? Something like this: path p,q; p := (0,0)..(1cm,1cm)..(3/2cm, -1cm); write "q := " &...
user avatar
2 votes
1 answer
175 views

Outlines for a TeX label in MetaPost

Is there a way to get outlines for a TeX label in MetaPost, containing something reasonably complex, say: $\sum_{x=0}^{10}x^2$? I know that I can get outlines for separate glyphs using glyph, but how ...
user avatar
9 votes
1 answer
670 views

Generative book cover

I wonder if it is possible to use LaTeX tools to generate a book cover inspired by Faber Finds project. http://blog.fabric.ch/index.php?/archives/62-Faber-Finds-generative-book-covers.html The ...
user avatar
  • 273
0 votes
1 answer
82 views

How does one rotate an entire metapost figure?

I have a metapost figure that I generated using map data and I would like to rotate the whole image by a small number of degrees to make the major lines parallel to the bottom of the screen. Is there ...
user avatar
  • 123
2 votes
1 answer
138 views

Metafont glyph description processed by Metapost to return svg paths

I'm hoping to generate SVG paths for a large number of characters, and I wonder if this could be automated via Metapost. From what I've read, mpost ’&mfplain’ cmr10 will let mpost process a ...
user avatar
  • 115
7 votes
2 answers
651 views

A More Precise Dance of Planets with Metapost and TikZ

Dance of Planets: Intro I got some fantastic answers to my question regarding the celestial dance of Venus and Earth. In this question, I am going to ask a more generalized version of the question ...
user avatar
0 votes
0 answers
90 views

Pens in metapost in ConTeXt stop working after clipping is used

There's a weird bug in ConTeXt ver. 2020.03.10: after a clipping mask is used, pens stop changing their thicknesses. \starttext \startMPcode picture p; p := image(draw (0, 0)--(1cm, 1cm) withpen ...
user avatar
2 votes
1 answer
212 views

Illustrating Newton's Path of Fastest Descent

I would like to produce the following Brachistochrone picture in Latex: I have searched this site for a Brachistochrone illustration that I might modify and found: Coding brachistochrone curve in ...
user avatar
0 votes
2 answers
146 views

Two dimensional scatter plot using latex

I have a two dimensional array of integers. I want to draw a scatter plot with the data like this: for(i=0, i<length(row), i++) for(j=0, j<length(column), j++) if data[i][j] is positive put a ...
user avatar

1
2 3 4 5
9