-1

How should we insert a page break via the code itself in maple program ?

Not insert page break? of menu

As I want to insert the page break as the code runs and with other outputs. In maple code.

sriram
  • 5
  • 6
  • Your phrase, "as the code runs and with other outputs" is quite unclear. Page breaks normally make an effect when viewing in slideshow mode or printing/exporting. Specify precisely what effects you expect to see when executing to produce mixed output & pagebreaks, and what (if any) immediate effects of the pagebreaks you expect. Also specify what hopes you gave for page-breaking without extra white-space, since there is not mechanism to compute size of pretty-printed 2D Output. If possible full code to be executed should be provided by you. – acer Dec 23 '19 at 02:02
  • Difficult for me to share code as it is part of my research sample example i give Just print("next"): next print should be in next page say while i EXPORT to PDF say print("next page") another way could be if i use fprintf(fp,"PAGE 1") NEXT ONE IN NEXT PAGE of that word file say fprintf(fp,"PAGE2") via the code itself – sriram Dec 23 '19 at 04:32

1 Answers1

0

Let's suppose that you have the following PutGraph procedure defined and available.

(You could define it in the Startup Code region of your Document/Worksheet. Or you could define it in your Maple initialization file. Or you could define it and store it in a .mla Library archive within your libname path. Or you could simply define it at the start of any Document/Worksheet in which you want to utilize it. I leave that choice to you.)

Then you can utilize this Putgraph procedure instead of DrawGraph, with the extra effect that it inserts a pagebreak right before the inlined plot of the Graph.

It also accepts a 2D or 3D plot as its argument. And if its argument is a Graph then you can also pass additional arguments that would normally be accepted by DrawGraph.

The restriction is that you can only effectively use one such call to this implementation of PutGraph per Execution Group or Document Block. If you want it done otherwise then you will have to show me explicitly how you need to call it once for multiple insertions. If you want specific behaviour then you will have to describe it adequately.

Here's the procedure, as 1D Maple notation code:

PutGraph:=proc(GG::{Graph,specfunc({PLOT,PLOT3D})})
  local T,xml;
  uses DocumentTools,DocumentTools:-Layout,GraphTheory;
  if GG::Graph then
    T:=DrawGraph(GG,_rest);
  else T:=GG; end if;
  xml:=Worksheet(Group(Input(Textfield(InlinePlot(T)))));
  InsertContent(subsindets(xml,'specfunc(anything,_XML_Input)',
                           u->':-_XML_Input'(':-_XML_Pagebreak'(),
                                             op(u))));
  return NULL;
end proc:

Here's some example of calling it. (I'll mention again: it needs to be called at most once per Execution Group or Document Block. If you put it more than once in the same Execution Group/Block then only the last instance will work as intended.)

G1 := GraphTheory:-RandomGraphs:-RandomGraph(6,degree=3):

Now, in its own Execution Group/Document Block,

PutGraph(G1);

You can have something else appear before the next page break, or several things like text, other input/output, etc.

somethingelse;

And now, in its own Execution Group/Block,

PutGraph(G1,showlabels);

And so on,

somethingelse;

PutGraph(G1,showweights);

somethingelse;

P := GraphTheory:-DrawGraph(G1):

PutGraph(P);

somethingelse;
acer
  • 6,671
  • 15
  • 15