On Mon, May 29, 2017 at 05:53:08PM -0400, Scott Kostyshak wrote: > It is a not-so-rare situation that the user needs to add -shell-escape as an > option to the LaTeX converter that is being used, in order to compile a > document. > > We can't ship documents that compile out-of-the-box without the user > doing the dance of figuring out how to add the option. The average user > does not feel comfortable modifying converter options, and further they > need to (or at least should) remember to remove the option after they > are done compiling a document. > > It would be nice to make the process of temporarily using -shell-escape > more user-friendly. > > One solution is to add a set of converters, one for each LaTeX flavor, > and then to specify the "needauth" flag for those converters. It would > be unfortunate to have > > LaTeX (pdflatex) (shell-escape) -> PDF (pdflatex-se) > > as a completely different converter from > > LaTeX (pdflatex-shell-escape) -> PDF (pdflatex) > > An alternative is to recognize that really this should be a document > setting. We could have a document option "shell-escape" (or a more > user-friendly name) in Document > Settings > Formats, which does the > following if checked: If an export is chosen that uses a LaTeX > converter, -shell-escape is added to the options. > Of course, for this approach we need to be careful. A malicious user > could just set the document setting and then do bad stuff. So LyX > would need to confirm once that the user trusts the document (using > the needauth framework?). > > Any thoughts?
We could ship some already defined formats and converters with the needauth option. Then, the format with the -shell-escape can be assigned as default for a document. When the user tries to preview it, it should be automatically warned, I think. For example, this is what I currently use (minus the needauth): \format "pdf2se" "pdf" "PDF (pdflatex se)" "" "qpdfview" "" "document,vector" "" \format "pdf4se" "pdf" "PDF (XeTeX se)" "" "qpdfview" "" "document,vector" "" \converter "pdflatex" "pdf2se" "pdflatex --shell-escape $$i" "latex=pdflatex" \converter "xetex" "pdf4se" "xelatex --shell-escape $$i" "latex=xelatex" There are many examples that require the -shell-escape option. Some that come to mind are tikz and the gnuplottex package. See the attached. -- Enrico
#LyX 2.2 created this file. For more info see http://www.lyx.org/ \lyxformat 508 \begin_document \begin_header \save_transient_properties true \origin unavailable \textclass article \begin_preamble \usepackage[miktex,siunitx]{gnuplottex} \usepackage{siunitx} % Using pdflatex, the produced eps file is automatically converted % to pdf using epstopdf by default. Unfortunately, the cairolatex % terminal of gnuplot inserts a couple comment lines just before % the line "%!PS-Adobe-3.0 EPSF-3.0" that characterizes an eps file. % This confuses the epstopdf program that comes with MikTeX, which % issues a "Invalid binary DOS header" error and produces an empty % pdf file. The solution is using ps2pdf. \usepackage{epstopdf} \epstopdfDeclareGraphicsRule{.eps}{pdf}{.pdf}{% ps2pdf -dEPSCrop #1 \OutputFile } \end_preamble \use_default_options true \maintain_unincluded_children false \language english \language_package default \inputencoding auto \fontencoding global \font_roman "default" "default" \font_sans "default" "default" \font_typewriter "default" "default" \font_math "auto" "auto" \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 100 \font_tt_scale 100 100 \graphics default \default_output_format pdf2 \output_sync 0 \bibtex_command default \index_command default \paperfontsize 12 \spacing single \use_hyperref false \papersize default \use_geometry true \use_package amsmath 1 \use_package amssymb 1 \use_package cancel 1 \use_package esint 1 \use_package mathdots 1 \use_package mathtools 1 \use_package mhchem 1 \use_package stackrel 1 \use_package stmaryrd 1 \use_package undertilde 1 \cite_engine basic \cite_engine_type default \biblio_style plain \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \justification true \use_refstyle 1 \index Index \shortcut idx \color #008000 \end_index \leftmargin 2cm \topmargin 2cm \rightmargin 2cm \bottommargin 2cm \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \tracking_changes false \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict false \end_header \begin_body \begin_layout Standard \begin_inset Note Note status open \begin_layout Plain Layout Remember to add the -shell-escape option to the LaTeX(pdflatex)->PDF(pdflatex) converter. \end_layout \begin_layout Plain Layout Note that the preview is only shown after the document is typeset, because the preview machinery simply ignores any extra option (thus including the -shell-escape one). \end_layout \end_inset \end_layout \begin_layout Standard \begin_inset Preview \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash begin{gnuplot}[terminal=cairolatex,terminaloptions=lw 3] \end_layout \begin_layout Plain Layout set title "The sinc function" \end_layout \begin_layout Plain Layout set xlabel "Abscissa" \end_layout \begin_layout Plain Layout set ylabel "Ordinate" \end_layout \begin_layout Plain Layout set samples 200 \end_layout \begin_layout Plain Layout set zeroaxis \end_layout \begin_layout Plain Layout set border 31 lw 1 \end_layout \begin_layout Plain Layout plot sin(pi*x)/(pi*x) lw 2 title "sinc(x)" \end_layout \begin_layout Plain Layout \backslash end{gnuplot} \end_layout \end_inset \end_layout \end_inset \end_layout \end_body \end_document
#LyX 2.2 created this file. For more info see http://www.lyx.org/ \lyxformat 508 \begin_document \begin_header \save_transient_properties true \origin unavailable \textclass article \begin_preamble % Author: Till Tantau % Source: The PGF/TikZ manual \usepackage{tikz} % GNUPLOT required \usepackage{verbatim} \begin{comment} :Title: GNUPLOT basics :Tags: Plots, GNUPLOT, External file PGF/TikZ provides a convenient mechanism for plotting functions using `GNUPLOT`_. To run this example for the first time you have to do the following: - GNUPLOT must be installed on your system. Try typing ``gnuplot`` on the command line to see if it's installed. Windows users may have to rename ``wgnuplot`` to ``gnuplot``. - You must allow TeX to run external programs. The command line option to enable this is usually ``--shell-escape`` or ``--enable-write18`` PGF will call GNUPLOT for you and store the data in a file. Next time you compile the example, data will be loaded from the generated file. See section 11.12.3 in the manual for more information. .. _GNUPLOT: http://www.gnuplot.info/ | Author: Till Tantau | Source: The PGF/TikZ manual \end{comment} \end_preamble \use_default_options false \maintain_unincluded_children false \language english \language_package none \inputencoding iso8859-1 \fontencoding default \font_roman "default" "default" \font_sans "default" "default" \font_typewriter "default" "default" \font_math "auto" "auto" \font_default_family default \use_non_tex_fonts false \font_sc false \font_osf false \font_sf_scale 100 100 \font_tt_scale 100 100 \graphics default \default_output_format pdf2 \output_sync 0 \bibtex_command default \index_command default \paperfontsize default \spacing single \use_hyperref false \papersize default \use_geometry false \use_package amsmath 1 \use_package amssymb 0 \use_package cancel 0 \use_package esint 1 \use_package mathdots 0 \use_package mathtools 0 \use_package mhchem 0 \use_package stackrel 0 \use_package stmaryrd 0 \use_package undertilde 0 \cite_engine basic \cite_engine_type default \biblio_style plain \use_bibtopic false \use_indices false \paperorientation portrait \suppress_date false \justification true \use_refstyle 0 \index Index \shortcut idx \color #008000 \end_index \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \paragraph_indentation default \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle empty \tracking_changes false \output_changes false \html_math_output 0 \html_css_as_file 0 \html_be_strict false \end_header \begin_body \begin_layout Standard \align center \begin_inset Note Note status open \begin_layout Plain Layout For correctly typesetting this document add the \end_layout \begin_layout Plain Layout \family typewriter --shell-escape \family default option to the \begin_inset Quotes eld \end_inset \SpecialChar LaTeX (pdflatex)\SpecialChar menuseparator PDF (pdflatex) \begin_inset Quotes erd \end_inset converter. \end_layout \begin_layout Plain Layout To obtain a correct preview add \end_layout \begin_layout Plain Layout \family typewriter --latex="pdflatex --shell-escape" \family default to the \begin_inset Quotes eld \end_inset \SpecialChar LyX Preview\SpecialChar menuseparator PNG \begin_inset Quotes erd \end_inset converter. \end_layout \end_inset \begin_inset Preview \begin_layout Standard \begin_inset ERT status open \begin_layout Plain Layout \backslash begin{tikzpicture}[domain=0:4] \end_layout \begin_layout Plain Layout \backslash draw[very thin,color=gray] (-0.1,-1.1) grid (3.9,3.9); \end_layout \begin_layout Plain Layout \backslash draw[->] (-0.2,0) -- (4.2,0) node[right] {$x$}; \end_layout \begin_layout Plain Layout \backslash draw[->] (0,-1.2) -- (0,4.2) node[above] {$f(x)$}; \end_layout \begin_layout Plain Layout \backslash draw[color=red] plot[id=x] function{x} \end_layout \begin_layout Plain Layout node[right] {$f(x) =x$}; \end_layout \begin_layout Plain Layout \backslash draw[color=blue] plot[id=sin] function{sin(x)} \end_layout \begin_layout Plain Layout node[right] {$f(x) = \backslash sin x$}; \end_layout \begin_layout Plain Layout \backslash draw[color=orange] plot[id=exp] function{0.05*exp(x)} \end_layout \begin_layout Plain Layout node[right] {$f(x) = \backslash frac{1}{20} \backslash mathrm e^x$}; \end_layout \begin_layout Plain Layout \backslash end{tikzpicture} \end_layout \end_inset \end_layout \end_inset \end_layout \end_body \end_document