3

Following the accepted answer to this question: Can I use an image located on the web in a LaTeX document?

I am trying to insert the following code to a trivial LyX document:

\write18{wget "http://cdn.sstatic.net/tex/img/logo.png" -O "/home/erelsgl/logo.png"}

I export the document to PS, but the file is not downloaded, and I get no error message (the trivial LyX document is indeed shown in PS).

How can I make LyX run the command?

I saw that there is a "shell-escape" argument that should be passed to the tex file processor, but how do I access it from LyX?

  • 3
    Is is really worth downloading the image using LaTeX instead of just downloading it by hand? Does all operating systems even have wget? – daleif Nov 11 '13 at 15:53

1 Answers1

7

You did add the \write18 in an ERT, or the preamble?

I think you add the --shell-escape flag in Tools --> Preferences --> File Handling --> Converters. If you use pdfLaTeX to compile your document, find the entry in the list called LaTeX (pdfLaTeX) -> PDF (pdflatex). Add --shell-escape in the Converter field, between pdflatex and $$i:

preferences window

Torbjørn T.
  • 206,688
  • Sorry for the side question, but can a new converter be created so that it could specifically use -shell-escape? With this method two LaTeX->PDF converters can be used with ease dealing with graphics or external programs such as gnuplot. – TheVal Nov 11 '13 at 16:51
  • @AndreaL. Take a look at Help --> Customization, section 3.3 Converters. – Torbjørn T. Nov 11 '13 at 17:09
  • Thanks for the tip, but specifically, it says "...quindi i format devono avere nomi differenti. Date un’occhiata e poi createne dei vostri!", or "...therefore format files must have different names. Take a look and then create some of yours". The section is unexpanded, and so it gives only the fact that the button Add exists, not its action (as you can see is disabled in your picture). – TheVal Nov 11 '13 at 19:00
  • @AndreaL. Sorry, I didn't really read that carefully, but in the English version it says 'To define a new converter, select the From format and To format from the drop-down lists, enter the command needed for the conversion, and then press the Add button.' Trying it out, the Add button is activated after selecting something different from either of those menus. Not sure exactly how it works though, you can't create a new converter from LaTeX (pdflatex) To PDF (pdflatex), but as you define the command for the converter yourself, (ctd.) – Torbjørn T. Nov 11 '13 at 19:43
  • (ctd.) that is perhaps not so important, you'll just get the 'wrong' name for your new converter. (Haven't tested this though.) – Torbjørn T. Nov 11 '13 at 19:43
  • And this is the second Thanks, =). Returning to the creation of a new converter, I was used to do it with TeXworks, because it only needed two command-line options and the job was done; so I'm surprised that LyX has not implemented this feature yet... – TheVal Nov 11 '13 at 22:04
  • @AndreaL. maybe no one has requested it – scottkosty Nov 11 '13 at 22:34
  • This works, thanks! (I also put the --shell-escape in LaTeX(Plain)-to-DVI). – Erel Segal-Halevi Nov 12 '13 at 14:11
  • Do remember that --shell-exscape is quite dangerous. Use with extreme care. – daleif Nov 12 '13 at 15:15
  • @scottkosty Just added., but I'm still "fascinated" by this lack of my supposed-to-be-favourite IDE. (I now begin to understand the dis-approval of egreg for it...). – TheVal Nov 12 '13 at 17:43
  • @AndreaL. It looks like I misunderstood your question. Now I understand and as mentioned in the ticket, it is possible to add new converters in LyX. However, that it was not clear to you how to do it might be a bug in the UI. Please let us know (new ticket :)) if you have an idea for how to improve it – scottkosty Nov 12 '13 at 22:18
  • 1
    @AndreaL. Why is LyX a "supposed-to-be-favourite IDE"? It's liked by some and not by others. It all comes down to preferences. If you want to constantly be writing the LaTeX code, then of course you will not like it because it tries to write the LaTeX code for you. I think there are many good reasons to use LyX. I also think there are many good reasons not to use LyX. – scottkosty Nov 12 '13 at 22:20
  • 1
    @scottkosty I guess the point (in this specific case) is to have two different versions of one converter, e.g. LaTeX -> PDF with pdflatex, where one has --shell-escape enabled, and one does not. – Torbjørn T. Nov 12 '13 at 22:51
  • @TorbjørnT. Ah, right. Thanks for the explanation. I believe this is possible but one must define a new file format (e.g. PDF (shell escape)) and then the converter will be unique: LaTeX -> PDF (shell escape) – scottkosty Nov 13 '13 at 01:31
  • @scottkosty I was thinking the same, because from the To Format menu there can be chosen only un-matched file formats, and I do not know if it's possible to create the PDF(shell escape) format... – TheVal Nov 13 '13 at 14:32
  • @AndreaL. To create the PDF(shell escape) go to Tools > Preferences > File Handling > File Formats and click on "new" – scottkosty Nov 13 '13 at 17:44
  • @scottkosty Oh. My. Well... I guess that this so wanted "format files" window has always been under my nose the entire time (I may start to think that I'm actually blind) =). – TheVal Nov 13 '13 at 18:07
  • @AndreaL. well, the preferences window is kind of cluttered. There are many that I have never experimented with. – scottkosty Nov 13 '13 at 18:11
  • @scottkosty Yes, recently I began to notice some new parameters even after writing my thesis with it (not to mention the hours passed for understanding the document layout...). – TheVal Nov 13 '13 at 18:18