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 example, how to put the following two graphs in the same row? Thank you very much.
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode
endfigure
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument
metapost
add a comment |
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 example, how to put the following two graphs in the same row? Thank you very much.
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode
endfigure
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument
metapost
@MarcelKrüger, thank you very much for your suggestions. I edited the post.
– Jianrong Li
Nov 13 '18 at 16:45
@MarcelKrüger, I tried to write beginfig(1) and beginfig(2) in the same graph. But it is still in two rows.
– Jianrong Li
Nov 13 '18 at 16:52
add a comment |
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 example, how to put the following two graphs in the same row? Thank you very much.
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode
endfigure
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument
metapost
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 example, how to put the following two graphs in the same row? Thank you very much.
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode
endfigure
beginfigure[H]
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument
metapost
metapost
edited Nov 13 '18 at 16:44
Jianrong Li
asked Nov 13 '18 at 16:22
Jianrong LiJianrong Li
1575
1575
@MarcelKrüger, thank you very much for your suggestions. I edited the post.
– Jianrong Li
Nov 13 '18 at 16:45
@MarcelKrüger, I tried to write beginfig(1) and beginfig(2) in the same graph. But it is still in two rows.
– Jianrong Li
Nov 13 '18 at 16:52
add a comment |
@MarcelKrüger, thank you very much for your suggestions. I edited the post.
– Jianrong Li
Nov 13 '18 at 16:45
@MarcelKrüger, I tried to write beginfig(1) and beginfig(2) in the same graph. But it is still in two rows.
– Jianrong Li
Nov 13 '18 at 16:52
@MarcelKrüger, thank you very much for your suggestions. I edited the post.
– Jianrong Li
Nov 13 '18 at 16:45
@MarcelKrüger, thank you very much for your suggestions. I edited the post.
– Jianrong Li
Nov 13 '18 at 16:45
@MarcelKrüger, I tried to write beginfig(1) and beginfig(2) in the same graph. But it is still in two rows.
– Jianrong Li
Nov 13 '18 at 16:52
@MarcelKrüger, I tried to write beginfig(1) and beginfig(2) in the same graph. But it is still in two rows.
– Jianrong Li
Nov 13 '18 at 16:52
add a comment |
1 Answer
1
active
oldest
votes
In you document you use two figures. LaTeX never places multiple figures in the same row, so you have to place both mplibcode environments in the same figure environment. (You can also combine them into one mplibcode environment with multiple beginfig(...) endfig; groups, but using different mplibcode environemnts makes it easier to separate the drawings.
Then there is a remaining problem:
After beginfigure, TeX is in vertical mode.
If you add multiple hboxes (through mplibcode) while vertical mode is active, TeX stacks them vertically.
So you want to enter horizontal mode first: Add leavevmode before the first mplibcode environment:
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
leavevmode
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode% <- Omit this comment to add a space between the graphs.
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument

add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459804%2fhow-to-put-two-metapost-graphs-in-the-same-row-in-lualatex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In you document you use two figures. LaTeX never places multiple figures in the same row, so you have to place both mplibcode environments in the same figure environment. (You can also combine them into one mplibcode environment with multiple beginfig(...) endfig; groups, but using different mplibcode environemnts makes it easier to separate the drawings.
Then there is a remaining problem:
After beginfigure, TeX is in vertical mode.
If you add multiple hboxes (through mplibcode) while vertical mode is active, TeX stacks them vertically.
So you want to enter horizontal mode first: Add leavevmode before the first mplibcode environment:
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
leavevmode
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode% <- Omit this comment to add a space between the graphs.
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument

add a comment |
In you document you use two figures. LaTeX never places multiple figures in the same row, so you have to place both mplibcode environments in the same figure environment. (You can also combine them into one mplibcode environment with multiple beginfig(...) endfig; groups, but using different mplibcode environemnts makes it easier to separate the drawings.
Then there is a remaining problem:
After beginfigure, TeX is in vertical mode.
If you add multiple hboxes (through mplibcode) while vertical mode is active, TeX stacks them vertically.
So you want to enter horizontal mode first: Add leavevmode before the first mplibcode environment:
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
leavevmode
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode% <- Omit this comment to add a space between the graphs.
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument

add a comment |
In you document you use two figures. LaTeX never places multiple figures in the same row, so you have to place both mplibcode environments in the same figure environment. (You can also combine them into one mplibcode environment with multiple beginfig(...) endfig; groups, but using different mplibcode environemnts makes it easier to separate the drawings.
Then there is a remaining problem:
After beginfigure, TeX is in vertical mode.
If you add multiple hboxes (through mplibcode) while vertical mode is active, TeX stacks them vertically.
So you want to enter horizontal mode first: Add leavevmode before the first mplibcode environment:
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
leavevmode
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode% <- Omit this comment to add a space between the graphs.
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument

In you document you use two figures. LaTeX never places multiple figures in the same row, so you have to place both mplibcode environments in the same figure environment. (You can also combine them into one mplibcode environment with multiple beginfig(...) endfig; groups, but using different mplibcode environemnts makes it easier to separate the drawings.
Then there is a remaining problem:
After beginfigure, TeX is in vertical mode.
If you add multiple hboxes (through mplibcode) while vertical mode is active, TeX stacks them vertically.
So you want to enter horizontal mode first: Add leavevmode before the first mplibcode environment:
RequirePackageluatex85
documentclass[12pt]amsart
usepackagefloat
usepackageluamplib
begindocument
beginfigure[H]
leavevmode
beginmplibcode
beginfig(1)
pair A,L,R,N;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]--A[2];
draw A[2]--A[3];
draw A[3]--A[4];
draw A[4]--A[5];
draw A[5]--A[1];
draw A[1]--A[4];
endfig;
endmplibcode% <- Omit this comment to add a space between the graphs.
beginmplibcode
beginfig(1)
pair A,L,R,N,t;
path p;
A[1] := (0,2cm);
for i=2 upto 5:
A[i] := A[i-1] rotated -360/5;
endfor;
draw A[1]..A[2]..A[3]..A[4]..A[5]..A[1];
endfig;
endmplibcode
endfigure
enddocument

answered Nov 13 '18 at 17:33
Marcel KrügerMarcel Krüger
11.8k11535
11.8k11535
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459804%2fhow-to-put-two-metapost-graphs-in-the-same-row-in-lualatex%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@MarcelKrüger, thank you very much for your suggestions. I edited the post.
– Jianrong Li
Nov 13 '18 at 16:45
@MarcelKrüger, I tried to write beginfig(1) and beginfig(2) in the same graph. But it is still in two rows.
– Jianrong Li
Nov 13 '18 at 16:52