4

is there a shortcut within WinEdt to use the pythontex command?

For the pythontex command, I know that you have to use the command prompt and then go to the path where the pythontex file is stored. In my example it is at: C:\Program Files\MiKTeX 2.9\scripts\pythontex

Then you have to type in the path to the file that you need to compile for pythontex. I will then have to type: pythontex C:\Users\superman\Desktop\test\example

Can WinEdt be customized to carry out these steps in a more efficient manner, for example by creating a button??

OK, I followed some steps and copied all the text from the active toolbar.ini file (in my case all the verbage in Toolbar2d.ini) and copied it to Private.ini under the \ My custom Tex toolbar: [TOOLBAR*]

I added:

  BUTTON="|"   
  BUTTON="PyTeX"
  BUTTON="|"

to the bottom of the file.

I would like to know what commands to input in the MainMenu.ini file. I did a copy/past and have this so far appened to the end of the MainMenu.ini file:

ITEM="PyTeX"
CAPTION="&PyTeX"
IMAGE="Python"
MACRO="Exe('%b\Exec\TeX\dvi2ps.edt');" % need to get the command for the pythontex execution
SHORTCUT="24644::Shift+Ctrl+Y"
REQ_FILTER="%P\%N.dvi" % need to change for pythontex to run
ITEM="-"

Can you help me edit these commands to run the pythontex?

  • Yes you can create such buttons. See the documentation of the option interface. – Ulrike Fischer Jun 16 '15 at 7:33
  • @UlrikeFischer, I am able to get the button to show up on the toolbar but it is greyed out? Can you assist me in getting the correct command for the pythontex to run (i.e. the correct command) and have the button not show up as greyed out? – Joe Jun 17 '15 at 15:39
  • I would at first try to use Run and not Exe, e.g. MACRO="Run('pythontex %n%t')" (check the parameters of Run in the macro manual). – Ulrike Fischer Jun 17 '15 at 15:51
4

Update (2016-04-10)

A new add-on PythonTeX is available for WinEdt, so, if you want, revert the changes you've made in MainMenu.ini and install this package.

Be sure to have PythonTeX installed correctly, i.e. run the script python­tex_in­stall.bat bundled with PythonTeX.


Original answer

I don't have neither Python nor PythonTeX installed, so I couldn't try it, but the following should work.

In your local copy of MainMenu.ini, just before the line

  ITEM="ConTeXt"

add the following lines

  ITEM="PyTeX"
    CAPTION="PyTeX"
    IMAGE="Python"
    SAVE_INPUT=1
    MACRO=`WinExe('','"C:\Program Files\MiKTeX 2.9\scripts\pythontex\pythontex.exe" "%N%T"','%P','',100,0,'','','',0);`
    SHORTCUT="24665::Shift+Ctrl+Y"
    REQ_FILTER=:"%!M=TeX"|"%!M=TeX:STY"|"%!M=TeX:AUX"
  ITEM="-"

Adjust the command line inside MACRO to your settings.

Then press Shift+Ctrl+F9 to reload the file.

If pythontex in your command line is not an executable, but a python script, as I suspect, replace the MACRO line with the following:

    MACRO=`WinExe('','cmd.exe /C ""C:\Program Files\MiKTeX 2.9\scripts\pythontex\pythontex" "%N%T""','%P','',100,0,'','','',0);`

EDIT

If you're redirecting your auxiliary files to another folder, you will have the need to move the .pytxcode file to your main directory.

In this case, substitute the MACRO line with the following:

    MACRO=`IfStr("%O","%P","<>",!|IfFileExists('%O\%N.pytxcode',!'CopyFile("%O\%N.pytxcode","%P\%N.pytxcode",1);DeleteFile("%O\%N.pytxcode");');|);`+
          `WinExe('','cmd.exe /C ""C:\Program Files\MiKTeX 2.9\scripts\pythontex\pythontex" "%N%T""','%P','',100,0,'','','',0);`+
          `IfStr("%O","%P","<>",!|IfFileExists('%P\%N.pytxcode',!'CopyFile("%P\%N.pytxcode","%O\%N.pytxcode",1);DeleteFile("%P\%N.pytxcode");');|);`
  • Thanks for your response. I think that I am much closer after your input. I put your commands in however the CMD window pops up and just ask to press any key. It does not seem to run pythontex. If I have to run python tex manually on my tex file named Cplusplus.tex, this is my full dos command "C:\Program Files\MiKTeX 2.9\scripts\pythontex\pythontex F:\Desktop\techpapers\Cplusplus", where the tex file is located at F:\Desktop\techpapers\Cplusplus. I did modify your MACRO to...'"C:\Program Files\MiKTeX 2.9\scripts\pythontex\pythontex" "%N%T"','%P'... – Joe Jun 17 '15 at 16:31
  • 1
    @Joe Surely it didn't work because pythontex in your command line is pythontex.py and not pythontex.exe. See if the edited code works. – karlkoeller Jun 17 '15 at 17:50
  • much closer...you are correct with your comment that it is a pyton script that needs to be run. When I try your updated command, the CMD says 'C:\Program' is not recognized as an internal or external command, operable program or batch file. – Joe Jun 17 '15 at 19:01
  • 1
    @joe substitute the last 111 with 0 – karlkoeller Jun 17 '15 at 19:23
  • 1
    @Joe See the edit. – karlkoeller Jun 19 '15 at 5:00

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.