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:


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:

MACRO="Exe('%b\Exec\TeX\dvi2ps.edt');" % need to get the command for the pythontex execution
REQ_FILTER="%P\%N.dvi" % need to change for pythontex to run

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

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


add the following lines

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

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);`


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:

          `WinExe('','cmd.exe /C ""C:\Program Files\MiKTeX 2.9\scripts\pythontex\pythontex" "%N%T""','%P','',100,0,'','','',0);`+
  • 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.