some suggestions for export to latex file
Hi all, for quite some time since I wrote in the forum, but I've noticed with a time to write, I clarify that I am not "programmed java" and just do the tests for my version "vanilla" of geoegebra, anyway, here are some comments:
Firts: GegebraToPstricks.java
When working with colors on the screen and you export the code is quite readable, but if you work in black and white, some exportadaas lines are not necessary, for example, to the "arc" geometric.
This code works for export in "black and white" without adding extra lines
// set arc in real world coords
GColorD geocolor = ((geogebra.awt.GColorD) geo.getObjectColor());
startBeamer(code);
if (!geocolor.equals(GColor.BLACK)) {
code.append("\\pscustom");
code.append(LineOptionCode(geo, true));
code.append("{\n");
}
code.append("\\parametricplot{");
code.append(angSt);
code.append("}{");
code.append(angExt);
code.append("}{");
code.append(format(r));
code.append("*cos(t)+");
code.append(format(m[0]));
code.append("|");
code.append(format(r));
code.append("*sin(t)+");
code.append(format(m[1]));
code.append("}\n");
if (!geocolor.equals(GColor.BLACK)) {
code.append("\\lineto(");
code.append(format(m[0]));
code.append(",");
code.append(format(m[1]));
code.append(")\\closepath}\n");
}
endBeamer(code);
The "\n" is make the code more readable.
By adding "dimen = middle" closed objects are to better respects the lines and segments
- codeBeginPic.append("cm,algebraic=true,dimen=middle,dotstyle=o,dotsize=");
The following code:
- if (name.indexOf("\u00b0") != -1) {
name = name.replaceAll("\u00b0", "\\\\textrm{\\\\degre}");
if (codePreamble.indexOf("\\degre") == -1)
codePreamble.append("\\newcommand{\\degre}\\ensuremath{^\\circ}}\n");
}
can be modified by this:
- if (name.indexOf("\u00b0") != -1) {
name=name.replaceAll("\u00b0", "\\^{\\\\circ}");
}
Using "textrm" and "newcommand" are not necessary
And finally, you can add the following code
- case DOTTED:
style = ",fillstyle=dots*,hatchangle=";
for the styles "dotted".
And as a final suggestion, although GeoGebra has a phenomenal precision for computations, when exporting to latex (or other formats) do not need much raised accuracy, for example the number "2.456000000000003" is correct in geogebra, but is more comfortable when exporting truncate this to "2.456", but, I will continue studying how to do this by hand.
Pablo
Thanks, we'll check that.
Try Kernel.checkDecimalFraction(x) to solve this problem :)
Thank you so much, the line:
code.append(format(Kernel.checkDecimalFraction(angSt)));
works perfectly, take the opportunity to ask the following code, is my version for "grid" of geogebra (psgrid not support dashed lines):
// Draw the grid
private void drawGrid() {
geogebra.common.awt.GColor GridCol = euclidianView.getGridColor();
double[] GridDist = euclidianView.getGridDistances();
double myx = xmin;
long truncx = (long)myx;
double myy = ymin;
long truncy = (long)myy;
double RX = Math.abs(xmax - xmin)/GridDist[0]+1;
long repx = (long)RX;
double RY = Math.abs(ymax - ymin)/GridDist[1]+1;
long repy = (long)RY;
// environment pspicture
codeBeginPic.append("\\begin{pspicture*}(");
codeBeginPic.append(format(xmin));
codeBeginPic.append(",");
codeBeginPic.append(format(ymin));
codeBeginPic.append(")(");
codeBeginPic.append(format(xmax));
codeBeginPic.append(",");
codeBeginPic.append(format(ymax));
codeBeginPic.append(")\n");
initUnitAndVariable();
// My Grid eje y\multips(0,ymin)(0,griddisy){numero de repeticiones}{\psline(xmin,0)(xmax,0)}
codeBeginPic.append("\\multips(0,");
codeBeginPic.append(truncy);
codeBeginPic.append(")(0,");
codeBeginPic.append(sci2dec(GridDist[1] * yunit));
codeBeginPic.append("){");
codeBeginPic.append(repy);
codeBeginPic.append("}{\\psline[linestyle=dashed,linecap=1,dash=1.5pt 1.5pt,linewidth=0.4pt,linecolor=");
ColorCode(GridCol, codeBeginPic);
codeBeginPic.append("]{c-c}(");
codeBeginPic.append(format(xmin));
codeBeginPic.append(",0)(");
codeBeginPic.append(format(xmax));
codeBeginPic.append(",0)}\n");
// My Grid eje x\multips(xmin,0)(griddisx,0){num}{\psline(0,ymin)(0,ymax)}
codeBeginPic.append("\\multips(");
codeBeginPic.append(truncx);
codeBeginPic.append(",0)(");
codeBeginPic.append(sci2dec(GridDist[0] * xunit));
codeBeginPic.append(",0){");
codeBeginPic.append(repx);
codeBeginPic.append("}{\\psline[linestyle=dashed,linecap=1,dash=1.5pt 1.5pt,linewidth=0.4pt,linecolor=");
ColorCode(GridCol, codeBeginPic);
codeBeginPic.append("]{c-c}(0,");
codeBeginPic.append(format(ymin));
codeBeginPic.append(")(0,");
codeBeginPic.append(format(ymax));
codeBeginPic.append(")}\n");
}
need to use the "integer part", there is another way (more correct) to do this.
salu2
ha, I forgot, and for consistency in the code must be modified (between the lines 139-152) to the following:
} else {
//initUnitAndVariable();
// Environment pspicture
codeBeginPic.append("\\begin{pspicture*}(");
codeBeginPic.append(format(xmin));
codeBeginPic.append(",");
codeBeginPic.append(format(ymin));
codeBeginPic.append(")(");
codeBeginPic.append(format(xmax));
codeBeginPic.append(",");
codeBeginPic.append(format(ymax));
codeBeginPic.append(")\n");
initUnitAndVariable();
}
this is vitally important, being "grid" active (or inactive) will add "\ psset" after "pspicture". This is very comfortable for the users of pdflatex by "auto-pst-.pdf" or "pst2pdf"
Please can you post a example ggb file showing where this is useful?
Comments have been locked on this page!