Menu

LaTeX figure environment. asy graph. Caption is lost in the final pdf.

Help
gustaf
2017-01-04
2017-01-05
  • gustaf

    gustaf - 2017-01-04

    The Asymptote graph consists of but a straight line and an x- and a y-axis. It is enclosed in the figure environment which includes a caption as well. The LaTeX file is called demo.tex; a link is included below.

    There are two problems:

    1. The caption is lost in the pdf written.
    2. There is a "float too large" detected by LaTeX

    I have tried to use \protect without success. As to the second problem I am completely without ideas.

    All files involved (including the log-file) are found in the catalogue pointed to by this link:
    https://1drv.ms/f/s!AvIP6x1zKSLzhWO_fqAYRZdUdSIX

    The handling of the files was by means of a (Windows) batch file:

    call wp        q.bat
    call wp        demo.tex
    call clean
    call we        demo.tex
    call tse       demo.tex   -n%1
    call wp        demo.tex
    call we        q.bat
    call pdflatex  demo
    call acrobat   demo
    call asy       demo-*.asy
    call pdflatex  demo
    call acrobat   demo
    

    The we and wp manages the write-permissions. The tse is my editor. The first call to acrobat in fact shows the caption correctly. The second acrobat call (after the asy demo-.asy) shows the line and the two axes but without the caption.

    Does anyone have a suggestion about what error(s) I commit?

    Ch

     
  • Marek Szwabowicz

    Hi gustaf

    There is high probability you have no mistake in your code. There is some problem with dvips around since the last upgrade of MikTeX, which pushes the graphics downwards - see my post from 2 days ago. To be sure that your case is the same, pls post your code here.

    Marek

     
  • gustaf

    gustaf - 2017-01-04

    Marek,

    You should find the file demo.tex following the link that is in the post. Anyway, here it is:

    \documentclass[12pt,a4paper]{article}
    \usepackage{asymptote}
    %
    \begin{document}
    \begin{figure}[htbp]
    \begin{center}
    \begin{asy}
      import graph;
      size(10cm ,10cm,IgnoreAspect);
      real xn   =         0.0000000000;
      real xx   =         1.0000000000;
      real yn   =         0.0000000000;
      real yx   =         1.0000000000;
      real Dx   =         0.2000000000;
      real Dxs  =         0.0500000000;
      real Dy   =         0.2000000000;
      real Dys  =         0.0500000000;
      string  xLabel  = "x [ ]";
      string  yLabel  = "y [ ]";
      pen[] p = {solid,dashed,longdashed};   // a vector of pens
      p.cyclic = true;
      real[][] a = new real [2][2];
      a[0][  0]=           0 ;     a[1][  0]=0;
      a[0][  1]=           1 ;     a[1][  1]=1;
      real[] x=a[0];
      real[] y=a[1];
      write("x" , x);   // verify onto stdout
      write("y" , y);
      pen q=p[0];
      xaxis(Label(xLabel           ,EndPoint          ),YEquals(yn),  LeftTicks(Step=Dx, step=Dxs), xmin=xn, xmax=xx);
      yaxis(Label(rotate(0)*yLabel ,EndPoint,RightSide),Left       , RightTicks(Step=Dy, step=Dys), ymin=yn, ymax=yx);
      pen q=p[0];
      draw(graph(x,y),q);
    \end{asy}
    \end{center}
    \protect{\caption[Short text]{Long text}}
    \end{figure}
    %
    \end{document}
    

    Christer

     
  • Marek Szwabowicz

    On my system only upper part of your picture is visible.

    Pls try this code from the Asymptote manual (first paragraph of the section 3.4):

    size(3cm);
    draw(unitsquare);
    label("$A$",(0,0),SW);
    label("$B$",(1,0),SE);
    label("$C$",(1,1),NE);
    label("$D$",(0,1),NW);
    

    Don't embed it into a latex code, but compile it straight as is. Then comment out all label commands and try again.

     

    Last edit: Marek Szwabowicz 2017-01-04
  • gustaf

    gustaf - 2017-01-05

    With Bowman's latest version of plain.asy installed (see above) the figure environment now includes the caption as well.

    Thank you for the help.

    Christer

     

Log in to post a comment.