getRelativePath (Experimental)

Parent Previous Next

(Experimental) twPan.getRelativePath(mainPath, wantedPath) : string

Very much need this, and could not find a JavaScript function on the web for it, and it does not appear to be in PhpJs either, so it is experimental.

It was needed for working out relative file paths for graphics from main Tex document especially for use in Portable Tw situations.

MiKTeX and LaTeX endeavour to find a graphic on a relative path.

mainPath could be the main document's path, and wantedPath is the full path to the graphic, above, at or below the main document's position.

Relative path returned, or full path if in different tree.

Could be used as in ...

// TeXworksScript

// Title:  Insert Graphic(s) to Col Width

// Description: Allows multiple selection of file names and inserts with title description and copyright note, using column width

// Author:  Paul Norman

// Version: 0.3

// Script-Type: standalone

// Context: TeXDocument

// Shortcut: Alt+G, Alt+I

 eval("helper_twPan")); // Un-Comment if Needed

//  eval("helper_PhpJs")); // Un-Comment if Needed

//%: insertGraphics


var chosenImages ="Image Files (*.jpg *.jpeg *.png *.pdf)");


if (chosenImages.length > 0)


                           for (image in chosenImages)


         var graphicPath =   twPan.getRelativePath(,   chosenImages[image]);


         var graphicCaption = twPan.prompt("Graphic Caption");

             graphicCaption = graphicCaption.toTitleCase();


         var copyRightInfo = twPan.prompt("Copyright Info");


         var includeGraphicsOptions ="Graphic Options", ["[width=\\ScaleIfNeeded]","","[]","[width= ]"])




                                + includeGraphicsOptions


                                + graphicPath


                                + graphicCaption


                                + copyRightInfo




                                   } // End.  for (image in chosenImages)

                           } // End. if (chosenImages.length > 0)

Created with the Personal Edition of HelpNDoc: Free PDF documentation generator