WinEdt Macro Library  | LaTEX previous macro  | next macro



This macro allows the user to choose from different images the TEX script to be inserted.

The macro is called by an active string. It then checks in a particular folder (according to the name of the active string) all files in *.pdf format. Those images have been previously put there by the user with their corresponding scripts in .tex format. The first image pops up in a SumatraPDF window. Then the macro waits for the user to:

  • press Right arrow key to show the next image
  • press Left arrow key to show the previous image
  • press Enter to insert the corresponding script in the current file and put the caret on the first bullet

If, when an image is displayed, the user changes the current document, or presses the Esc key or manually closes the SumatraPDF window, the macro stops. The user can continue editing the current document while the macro is running but pressing Enter will result in inserting the script at the exact place the keyword was typed (to avoid unwanted actions).

Note : the pdf reader is here SumatraPDF, because it is very light (less than 1 MB) and it can be easily controlled from WinEdt. The executable sumatraPDF.exe used by the macro will have to be in WinEdt's installation directory because the macro has to work even if WinEdt is launched from an USB drive. It won't replace default pdf reader.


  • Go to the official SumatraPDF website and download the zip file at: Just extract sumatraPDF.exe into this folder: %b\Exec\Sumatra (create the folder Sumatra). You can easily adjust the path to sumatraPDF.exe if you chose to put it somewhere else.
  • Put the macro in %b\Macros\LaTeX\
  • Create a folder %b\Macros\LaTeX\Choice
  • In this folder Choice, put all images and scripts. More precisely, put them into different subfolders whose names are the same as the keywords. For example: I want all my titling styles to be accessible with the keyword "title" followed by the character "*" (the * is for the active string). In this case, I create a folder named "title" in %b\Macros\LaTeX\Choice and put all my images of titles with their scripts in that folder (%b\Macros\LaTeX\Choice\title). Attention: scripts are in .tex format and images in .pdf format (example: title1.tex; title1.pdf). The names of the files don't matter (because the macro looks into the folder and automatically lists all the files in there), but don't put spaces into the names!
  • Now, for the keywords. Continuing the last example, you would define an active string:
    • For WinEdt 5.6 or older go to Options | Settings:
      On Type:TeX
    • For WinEdt 6, open the file Active Strings.ini (in the Delimiters section) and add the following lines:



Macro contributed by Peter Laurence <>

WinEdt Macro Library  | LaTEX previous macro  | next macro