# Re: Embedding asymptote in LyX

Ok, I have succeded to export to TeX, and I am now trying asymptote as
the instructions advised.

It is NOT a LyX question, I guess, but still it might be useful to ask
it here, since I believe that there are LyX users who use Asymptote...
and because it might be still LyX related, because of the following
fact:
doing what the instructions advised, on a test.tex file which contains
only what's written in this document, works well. Here is the code:

\documentclass[10pt]{article}
\usepackage[pdftex]{graphicx}
\usepackage{asymptote}
\begin{document}
\begin{figure}
\centering
\begin{asy}
size (3cm);
draw (unitcircle);
\end{asy}
\caption{Embedded Asymptote figures are easy!}
\label{fig:embedded}
\end{figure}
\end{document}

Again - this code works WELL.

So now I am trying to do the same with an exported-to-tex LyX document.
For that purpose, I have created a very simple LyX document, and
exported it to TeX; it worked as well.

I have tried to make it a bit more complicated - I tried to do the SAME
simple document, but in Hebrew (as I usually do). I have left the code
inside the asymptote example in English.

And that's it. Now it is not working any more...

A simple analyzation of the situation:
a. when the document was in English, the first "pdflatex asytest2" had
created a file named "asytest2.asy" with this line in it:
defaultfilename='asytest2_1';
this is probably good, because the command "asy asytest2" generates a
file "asytest2_1.pdf" with the unit circle, and the second "pdflatex
asytest2" generates "asytest2.pdf" with the unit circle embedded.
but:
b. when the document is still mainly in English, but I have a *single
word* in Hebrew (actually, in a Hebrew "direction", but it is still with
English characters; it looks like that: [in the tex file] sometext
\inputencoding{cp1255}\R{some more text}) then the first "pdflatex
asytest2" generates the file "asytest2.asy" as before, but in it, the
relevant line is now:
defaultfilename='asytest2_\protect \beginL 1\endL ';
and that is probably not good, since the command "asy asytest2"
generates a file named "asytest2_\protect eginL 1\endL .pdf" (which
can't be good) and of course, the second "pdflatex asytest2" does *not*
embed the nice unitcircle from that pdf.

manually removing the line "\inputencoding{cp1255}\R{text}" does not
make any difference, so I assumed it is something with the main
configuration of the tex file. So, I have compared to files, one with
thi encoding difference, and one without, that are otherwise the same,
and these are the results:
The ONLY difference (besides the line with
\inputencoding{cp1255}\R{text} - which its removal changes nothing), is
\documentclass[10pt,english]{article} becomes
\documentclass[10pt,hebrew,english]{article}
and \usepackage[latin9]{inputenc} becomes
\usepackage[cp1255,latin9]{inputenc}

I have tried to remove only one of them, so see what happens... I have
tried only to remove hebrew from the first line, but then the second
line caused an error; so I have kept the "hebrew" in the first line, and
removed "cp1255" from the second line. well, that didn't change anything
either.
Removing both changes, that is, removing both "hebrew" and "cp1255" from
the heading, return the situation - of course - to the one we had in the
beginning - a pure English document; then, of course, it worked well
again.

That's my little research...
Any ideas?

Peleg.

On Wed, 2008-05-14 at 08:40 +0100, Peleg Michaeli wrote:
> Oh, I see...
>
> They also wrote this line under that figure: "For ASYMPTOTE versions ≥
> 1.14, you can simply call PDFLATEX directly" - but I have misunderstood
> it, probably; I thought it meant that in this specific case (version ≥
> 1.14), I *don't* need to do that.
>
> Well, then...
>
> I am looking for a workaround now.
>
> Is it possible to export a LyX document to a TeX document without losing
> data? Then, I'll be able to do what they suggest in the documentation.
>
> Thanks,
> Peleg.
>
> On Tue, 2008-05-13 at 19:38 +0200, Manveru wrote:
> > Hough!
> >
> > I am not a specialist of ASYMPTOTE, but I've just looked into the
> > documentation. They directly tell about makefile for latex with asymptote:
> >
> > document.pdf: document.tex
> >     pdflatex -shell-escape document
> >     asy document
> >     pdflatex -shell-escape document
> >
> > It means that ASYMPTOTE need an additional step during document generation
> > which launch "asy" command between two "pdflatex" invocations. This is what
> > LyX is *not able* to do. Generation process is compiled in, automatic... and
> > as some people suggests, not user configurable.
> >
> > Maybe it is worth to put feature request in bugzilla, to get this to work
> > when \usepackage{asymptote} is used in preamble definition.
> >
> > Regards,
> > M.
> >
> > 2008/5/13 Peleg Michaeli <[EMAIL PROTECTED]>:
> >
> > > Hello!
> > >
> > > I am trying to embed Asymptote in LyX documents.
> > >
> > > I am following this tutorial:
> > > http://www.dse.nl/~dario/projects/asylatex/asylatex.pdf<http://www.dse.nl/%7Edario/projects/asylatex/asylatex.pdf>
> > >
> > > I am doing everything as suggested:
> > > * I have included \usepackage{asymptote} and
> > > \usepackage[pdftex]{graphicx} in the LaTeX preamble
> > > * I have done Crtl-L in the middle of the document and added this LaTeX
> > > code:
> > >
> > > \begin{figure}
> > > \centering
> > > \begin{asy}
> > > size (3cm);
> > > draw (unitcircle);
> > > \end{asy}
> > > \caption{Embedded Asymptote figures are easy!}
> > > \label{fig:embedded}
> > > \end{figure}
> > >
> > > When I generate the document (using pdflatex), I get nothing special: a
> > > "figure" with "PDF" written there, but no image (no "unitcircle")...
> > > when I do the same, but with DVI, I get "EPS" written instead of the
> > > unitcircle. Either way, I don't see any picture...
> > >
> > > I have a new version of Asymptote: 1.18 - so it should work
> > > automatically with pdflatex.
> > >
> > > Any ideas?
> > > Maybe I should ask a different list?
> > >