1

I have an external program bezierplot which returns tikz paths. E. g. bezierplot 'x^2' returns (-2.24,5) parabola bend (0,0) (2.24,5); with semicolon. Now I want to call the program with shell-escape/write18 inside a LaTeX document (pdflatex) and in text mode this works as expected:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\input{|"bezierplot 'x^2' "} % this works: (-2.24,5) parabola bend (0,0) (2.24,5);
\begin{tikzpicture}
\draw \input{|"bezierplot 'x^2' "} % this does not work
\end{tikzpicture}
\end{document}

Unfortunately, it does not work inside the tikzpicture: ! Package tikz Error: Giving up on this path. Did you forget a semicolon? It seems like the semicolon is not the problem (e.g. I removed it in the program bezierplot and used \draw \input{|"bezierplot 'x^2' "}; instead). When I change the program bezierplot such that it returns \draw (-2.24,5) parabola bend (0,0) (2.24,5);I then can successfully use \input{|"bezierplot 'x^2' "}

What is the point that I have missed? How can I force tikz to concatenate \draw with \input{|"bezierplot 'x^2' "} and ; ?

  • It is very hard to really answer this question because I cannot try things out since I do not have bezierplot. However, I would try \xdef\myplot{ \input{|"bezierplot 'x^2' "} } followed by \draw \myplot ;. – marmot Mar 10 '18 at 19:27
  • @marmot Let's say bezierplot is the following bash program: echo "(-2.24,5) parabola bend (0,0) (2.24,5)" Unfortunately, your suggestion as denoted above with \xdef did not work... – Linus Romer Mar 10 '18 at 19:48
  • @marmot latex's \input isn't expandable – David Carlisle Mar 10 '18 at 19:51
  • @DavidCarlisle Yes, thanks, I just figured this out the hard way. :-( – marmot Mar 10 '18 at 19:55
1

enter image description here

I use echo here as an external program returning the path.

\documentclass{article}
\usepackage{tikz}
\makeatletter
\let\zz\@@input
\makeatother
\begin{document}

\begin{tikzpicture}
\draw \zz|"echo '(-2.24,5) parabola bend (0,0) (2.24,5)'" ;
\end{tikzpicture}
\end{document}
  • Your solution works perfectly! Is there also a way to get the semicolon out of the external program? (So you are only allowed to use echo '(-2.24,5) parabola bend (0,0) (2.24,5)'without the semicolon?) – Linus Romer Mar 10 '18 at 20:07
  • @LinusRomer sure, if echo (or your program) doesn't add a ; just end the input with " ; – David Carlisle Mar 10 '18 at 20:12
  • @LinusRomer I edited the answer (same output) – David Carlisle Mar 10 '18 at 20:13
  • Ooops, I could have sworn that this variant did not work some minutes ago, but you are right: It works! – Linus Romer Mar 10 '18 at 20:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.