Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am using Windows 7, Cygwin (CYGWIN_NT-6.6-WOW64), and MiKTeX 2.9. I am trying to compile a document of a friend of mine who has written a specific document class file (.cls), a class that is able to run Python code from the document LaTeX source (.tex) and include its output in the document (maybe along with the Python code). I want (in a sense, I need) to write my own documents using that class.

My friend works on Linux, and I try to compile his document from a Cygwin terminal by using pdflatex --enable-write18 thedocumentfile.tex (indeed, my command line is PATH=.:$PATH pdflatex --enable-write18 thedocumentfile.tex). If I search for latex packages in my Cygwin Setup, I only find texlive-collection ones, not installed, so I guess pdflatex is calling a latex-to-PDF compiler version in a MiKTeX 2.9 package called miktex-pdftex-base-2.9. I think this is what I want, just one LaTeX distribution (MiKTeX) installed in my machine.

But compilation fails because command lines passed as arguments to \write18 are written to be interpreted by a bash, but my compilation attempts send them to a Windows command interpreter.

I don't know if it is possible to instruct my compiler not to pass command lines to the Windows interpreter, but to the bash shell of Cygwin. I hope it will. Does anybody know how?

share|improve this question
3  
you can get the cygwin compiled texlive 2012 from tug rather than from cygwin and run on cygwin (that's what I use) that uses bash by default I couldn't see in texlive a customisation for the shell it uses, don't know about miktex. –  David Carlisle Oct 10 '12 at 20:48
    
Thank you very much, @David, I will try your suggestion in case no one knows how to force MiKTeX to do what I need. I would prefer not to change my LaTeX distribution (nor mix two of them) if avoidable. –  federico.prat Oct 10 '12 at 21:35
    
If what you are really going for is using Python from LaTeX, you might consider PythonTeX. It works well with Windows, and can be faster than some of the Python-LaTeX solutions based on \write18 (it saves output, so only modified code is executed). –  G. Poore Oct 10 '12 at 23:42
1  
Using c:\cygwin\bin\bash.exe -l -c "<bash commands>" will run <bash commands> via Cygwin, but at least on my system it's really slow. –  G. Poore Oct 11 '12 at 1:26
    
@G. Poore: Thanks for your comments. Regarding PythonTex, it is not the kind of solution I am looking for, because the class file I want to use provides more than just Python facilities. Regarding how to call Cygwin bash from the Windows interpreter, it is the ugly solution I have adopted, so thank you very much, this allows me to make compilation work (after modifying the \write18 arguments in the class file). However, I'm still interested in configuring MiKTeX in order to make it use bash so I can use the original class file (or other bash-supported class files in the future). –  federico.prat Oct 11 '12 at 19:45
add comment

1 Answer

To sidestep the question with a moralistic injunction: it's fundamentally unportable to have complex shell scripts embedded in Tex documents. Much better is to use \write18 to call a program (with arguments, if needs be) as a system call, which will be interpreted the same by either bash or as a Windows command shell call.

You might be able to encourage your friend to refactor his class file into a few shell scripts plus the class file which invokes those scripts by plain system calls.

What is a system call

They are the "atoms" of shell scripts, that in Unix/C are invoked using the system() C function, which is included in most scripting languages such as Python. It may have switches or arguments, but it won't have anything like control structures, pipelines, or IO redirection operators.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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