# Scripts #261

Open
opened this Issue Mar 14, 2015 · 78 comments

Projects
None yet
2 participants

### GoogleCodeExporter commented Mar 14, 2015

 I open this issue for people to post their scripts here (for lack of a better way). I start by adding a script to inline bibliographies. When submitting papers to journals, they typically want all data contained in one single file (the .tex file) - they don't support (external) BibTeX files. The attached script opens the .bbl file associated with the currently open .tex file and copies its contents to the current cursor position. Note that this script saves the file before opening the .bbl file. This can lead to a "Save File" dialog. This is necessary as this is the only way I could think of right now to ensure that we're not working on a new (unsaved) document, which would cause problems.  Original issue reported on code.google.com by st.loeffler on 26 Dec 2009 at 2:52 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Note: To use scripts, you need at least Tw 0.3 (the current development version at the time of writing). To install scripts, put them in the Tw scripts folder. Simply click on "Show Scripts Folder" in the "Scripts" menu of Tw (alternatively, navigate to the "scripts" folder in your Tw configuration folder by hand; see TipsAndTricks on the wiki to locate it). Then, click on "Update Scripts" in the "Scripts" menu of Tw (or restart Tw).  Original comment by st.loeffler on 26 Dec 2009 at 2:56

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Thanks Stefan, I only just found this. I'll put some scripts that I had attached as comments to the wiki entry here instead.  Original comment by paul.a.norman on 20 Apr 2010 at 4:29

### GoogleCodeExporter commented Mar 14, 2015

 Sometimes when in pdf preview, you decide to re-typset and need to see the output console in the source.  Original comment by paul.a.norman on 20 Apr 2010 at 4:50 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 When using a master document, you may wish to open a selected file name, or one in an \input{filename.tex} just position the cursor between the {braces} (useful until project management tools are able to be developed)  Original comment by paul.a.norman on 20 Apr 2010 at 4:53 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Show/Open the current file's folder/directory - MW Windows specific easily adapted other OS.  Original comment by paul.a.norman on 20 Apr 2010 at 4:55 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Import File Contents off Disk into Tw Editor - MS Windows specific but easily adapted.  Original comment by paul.a.norman on 20 Apr 2010 at 10:20 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Convert Selected lines of text into an \item list, (Updated:) presents drop down box with some LaTeX environments to choose from. Ignores/deletes blank lines, and leaves the User to handle any of their own % comment lines.  Original comment by paul.a.norman on 24 Apr 2010 at 7:17 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 I needed a "scratch pad" asociated with any/each .tex document on demand - a place to keep notes and almost a "to do" for esp. when working with multiple documents under a master document. Put someting in the "Issues" list, but did this as a temporary measure or/ in case it is seen as not worth adopting in the main editor. There are three scripts so far. The first (1) scratchPad.js This .Js (MS Specific but alterable) creates a text file based on the .tex document name in the same directory, So one for: a) My-First.tex would look like: b) My-First_tex-Scratch-Pad.txt If the file exists, it is opened, if not it is created and opened. Then the windows are placed a) left and b) right. If you are in a ...tex_Scratch-Pad.txt document and call this script (1) it will find and show the main editing document it bleongs to. If the scratch-pad document does not yet exist, this script (1) above must be run first before the other scripts are going to be used. Recomend using editor book marks %: blah something blah and Tw- Menu/ Window/Show/Tags in each document. The second Script (2) scratchPadCopyTexTorTag.js will copy selected text or selected bokmark tag between the two editors, make sure that the cursor is where you want it in the opposite editor first. And the third script (3) scratchPadNewTagInBoth.js will create a new identical bookmark in both editors at once. Again make sure that the cursor is where you wnat it in both editors first. Scripts (1), (2), and (3) can be run from either editor, and will find the other one, but again please make sure that if the scratch pad has not yet been created, run script (1) scratchPad.js first (it will do no harm in any event). I have found these scripts very useful during selection/holding of researech material for specific subdocuments. Please try and improve these, and point out any problems to me. I updated them 28-04-2010, to give more descriptive and informative variable names, and to make the text editor windows place beside eachother for each script. Paul  Original comment by paul.a.norman on 28 Apr 2010 at 10:05 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Please, help: I tried two script examples with the last version of tw 03.r.567 but with debugging information Uncaught exception at C:/Documents and Settings/horák/TeXworks/scripts/inlineBib.js:13: ReferenceError: target is not defined The TW sees the scripts, allows their debugging, but...? Karel Horak  Original comment by hor...@math.cas.cz on 8 May 2010 at 1:52

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Insert Cross Reference This script makes a list of \label{s} in the active document, and offers a drop down box to chose one, and another drop down box to choose a cross-reference type ( \ref or \pageref). (Also has the base for a generic simple find \command{} function)  Original comment by paul.a.norman on 9 May 2010 at 5:28 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Format Selected Text Characters Presents a drop-down box to choose one of these standard LaTeX character formats and applies it to highlighted text in the Tw editor. \textnormal textnormal main document font \textrm rmfamily roman \textit itshape italics \emph n/a emphasis \textmd mdseries medium weight (default) \textbf bfseries boldface \textup upshape upright (default) \textsl slshape slanted \textsf sffamily sans serif \textsc scshape small caps \texttt ttfamily typewriter \underline underline underline \textsuperscript n/a this is superscript List from:-- Section 5.2 LATEX for Word Processor Users version 1.0.6 Guido Gonzato, Ph.D. November 7, 2009 page: latex4wpsu30.html#x42-480005.2.3  Original comment by paul.a.norman on 20 May 2010 at 7:56 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Set Size for Selected text or rest of document Presents a drop-down box with the Standard LaTeX font sizes from tiny -to- Huge For clarity in the editor-- If one or two words are selected {\tiny myWord} format is used If three or more words are selected \being{tiny}myFirstWord mySecondWord myThirdWord\end{tiny} format is used And if nothing is selected, the command is simply inserted with a space before and after. \tiny  Original comment by paul.a.norman on 20 May 2010 at 12:42

### GoogleCodeExporter commented Mar 14, 2015

 Set Size for Selected text or rest of document Presents a drop-down box with the Standard LaTeX font sizes from tiny -to- Huge For clarity in the editor-- If one or two words are selected {\tiny myWord} format is used If three or more words are selected \being{tiny}myFirstWord mySecondWord myThirdWord\end{tiny} format is used And if nothing is selected, the command is simply inserted with a space before and after. \tiny  Original comment by paul.a.norman on 20 May 2010 at 12:43 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 ulem package macros in a drop down-down box Offers the various underlining and strike-through features of the ulem package. Checks for, and if apparently missing, offers to insert usepackage[normalem]{ulem} in the document preample. \uline{important} \uuline{urgent} \uwave{boat} \sout{wrong} \xout{removed} List from:-- Section 5.2.1 LATEX for Word Processor Users version 1.0.6 Guido Gonzato, Ph.D. November 7, 2009 page: latex4wpsu30.html#x42-480005.2.3  Original comment by paul.a.norman on 20 May 2010 at 12:51 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Insert a new \label{key} If text is selected first in the Tw editor, the script endeavours to use this as the key to make a new \label{key} Checks through the current document, and offers a drop-down box with either a blank area to type in, or if the user has selected some text, that as the proposed label key. The drop- down shows any already existing label keys in the document. If the user Ok-s the drop-down box, the script then checks through existing labels to avoid reproducing the same key. If the key has already been used in another \label{key} statement, the user is shown the pre-existing key, and asked to try making a new label up again. The same checks are performed recursively until either a unique key is made, or the user cancels. Successful use, inserts \label{usersKey} (Companion script to insertCrossRef.js)  Original comment by paul.a.norman on 21 May 2010 at 8:58 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 newLabelforCrossRefsEnvCheck.js As for newLabelforCrossRefs.js Inserts a new \label{key} but does a check for an active/current environemnt e.g. \begin{figure} (Thanks to Stefan for this added suggestion.) If a standard LaTeX environment is current where the cursor is, a prefix for the label name is suggested, and a brief description of the environment is given for User assistance and confirmation (may remind people that an environment has not been \end- ed!). If a package or proprietary environment is current, a prefix abbreviation is generated and suggested. These standard LaTeX2e environemnts are treated as proprietary. "flushleft",,"Flushed left lines. " "flushright",,"Flushed right lines. " "center",," Centred lines. " And this is ignored "document",,"Enclose the whole document. " If no environment is current at the cursor position, then no specific prefix is suggested. chapter, section et al, are left for the user to determine And the user is responsible as to whether any current environment or renewed environment fully supports \label{anyWay} If text is selected first in the Tw editor, the script endeavours to use this as the key to make a new \label{key} Checks through the current document, and offers a drop-down box with either a blank area to type in, or if the user has selected some text, that as the proposed label key. The drop-down shows any already existing label keys in the document. If the user Ok-s the drop-down box, the script then checks through existing labels to avoid reproducing the same key. If the key has already been used in another \label{key} statement, the user is shown the pre-existing key, and asked to try making a new label up again. The same checks are performed recursively until either a unique key is made, or the user cancels. Successful use, inserts \label{usersKey} or \label{anyPrefix:usersKey} Please advise of any problems or possible improvements. (Companion script to insertCrossRef.js  Original comment by paul.a.norman on 22 May 2010 at 7:28 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 A scirpt to place any selected text into a multicols environment, presents a drop- down box to choose the nuber of columns. User responsible to make sure that the multicol package is somewhere in their document packages' heirarchy( it may already be included by other of the user's own packages) and the user is prompted on the Tw window's status tip, to do that.  Original comment by paul.a.norman on 25 May 2010 at 12:12 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 What means ReferenceError: TW is not defined ?  Original comment by krychaj...@gmail.com on 7 Jun 2010 at 3:42

### GoogleCodeExporter commented Mar 14, 2015

 It sounds like you use an old version of TeXworks that doesn't support the TW object. Please update to the latest version. If that is not the case, please specify in more detail in which situation this problem occurs (what version of TeXworks are you using, on what operating system, with which script file).  Original comment by st.loeffler on 7 Jun 2010 at 6:08

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 This is a Tw help dialogue (ver 0.52) July 7th 2010 that replaces the NASA help info. It utilises the LaTeX2e Help work done by Karl Berry and others. The zip completely replaces ver 0.5 released here a few days ago. If you installed that, delete its whole directory first. Due to Jonathan Kew and Steffan Loefer's, and others efforts, it is fully integrated with the Tw editor, and requires no outside browser. Down load fom here. Unzip into your scripts folder, perhaps into a directory called help'. Allow decompression to use folder names'. Refresh your Scripts from the Scripts Menu. Make sure your TeXWorks document is saved first. You can then use (Win) Alt+F1,Alt+2 together to open this help-(Help for LaTeX2e). In the Tw Editor, select some text first, a full command, or partial text that you want to search for help on. (Double clicking a LaTeX command name will select it for you.) Further help information is available in the dialogue. Paul  Original comment by paul.a.norman on 6 Jul 2010 at 1:41 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 In reference to the comments Karel Horak and krychaj.pl about the ReferenceError: TW is not defined: I have encountered the same problem. Some details: I'm running TW 0.3 rev 514 and am having trouble with Paul Norman's InsertCrossref.js. I have other scripts, which I suppose were already there, such as Title Case, make bold, make emphasized. These work with no problems. However, this script (which is a feature I desperately wanted in TW for a while) fails. This is on a XP machine, fully updated.  Original comment by ucale...@gmail.com on 28 Jul 2010 at 2:30

### GoogleCodeExporter commented Mar 14, 2015

 @ucaledek (and probably krychaj.pl): This explains it. There has been an API change in r538. From then on, all scripts use the single TW object. Before, functions where scattered around several objects and the global namespace. Please update your Tw version - builds are available either here in the "Downloads" section or on http://web.student.tuwien.ac.at/~e0325258/projects/c/texworks/ (these are not official test builds, though). BTW: The scripts you mention are all bundled with Tw. Therefore, they use the API that was available at the time your Tw version was built. User scripts, on the other hand, may use a different version.  Original comment by st.loeffler on 28 Jul 2010 at 3:33

### GoogleCodeExporter commented Mar 14, 2015

 Is there any list of commands from TW that are available for scripting? For example are the texworks variables like "% !TEX root = path/to/root_file.tex" accessible? I'm writing a script that should read the bibtex file but that works right now only in one file. Hence, the question.  Original comment by david.kr...@gmail.com on 27 Sep 2010 at 6:08

### GoogleCodeExporter commented Mar 14, 2015

 Such a "Scripting Manual" does not exist yet, but it's in the planning phase. In the meantime, you can get an idea of what is available to scripting by browsing the .h files in the src/ directory for "Q_PROPERTY" (properties), as well as "Q_INVOKABLE" and "public slots" (methods). I'm afraid there is little to no documentation for them, however. As for the "%!TEX" constructs, they are currently not exposed to scripting. As a workaround, you could parse them yourself (e.g., using regular expressions), as the file's content is available via TW.target.text.  Original comment by st.loeffler on 27 Sep 2010 at 7:59

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 I've been focussed on QtScript as many people new to scripting may have struck it as JavaScript in browser or other work. Slowly getting the Scripting Api written up here http://twscript.paulanorman.info Docs slowly growing here http://twscript.paulanorman.info/docs/index.html and online here http://twscript.paulanorman.info/docs/html/TexWorksQtScripting.htm Paul  Original comment by paul.a.norman on 27 Dec 2010 at 11:06

### GoogleCodeExporter commented Mar 14, 2015

 Hi, Here is a second look at a Script for helping people start new scripts for TeXworks. This one ver 0.31 has a minor fix to the version numbers to reflect how Script version numbers work (you make them up they bear no relationship to the Tw version or revision number). It now forms the header for QtScript, Python and Lua scripts, and can incorporate any new scripting engines that may be added later. Helps set up the header correctly - I hope :) Can be modified for other Script languages easily. Put into a sub-directory under your scripts folder. In Scripts menu "Reload Scripts List" If Preferences / Scripts / Write is turned on, it will remember the Author's Name for future use. If you don't want to do that just edit "Your Name" out of authorName.txt in which ever folder you put the script in from the zip. Make a new document in Tw (click into the new document if necessary), and use Alt+N Alt+S (if you have not already allocated it for something else) or use Scripts Menu look for "Make Script". Comments, feed back, appreciated please, Paul  Original comment by paul.a.norman on 4 Jan 2011 at 10:13 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 INSTALL: Unzip to any directory under you TeXworks script directory - see http://code.google.com/p/texworks/wiki/TipsAndTricks?can=5#Locating_and_customiz ing_TeXworks_resources for further information. Change the Alt key combination if you want/need to avodid conflicts with any existing scripts. Use Tw Menu item, Scripts/Scripting TeXworks/Reload USAGE: In you editing document Hold down the Alt Key and before releasing it, tap the A and then the C keys, than release the Alt key. Drop down boxe(s) appear, for speed use the arrow keys, and the Enter Key to select. BACKGROUND: Hi, After a request for information on the list for inserting accented letters, thought to make a little customisable trial script for situations where the occasional accented letter is required in differing languages. This can be achieved in LaTeX using \stuff but as it seems that under a UTF-8 document using pdflatex these direct characters come out directly in the pdf, I have left it as it is for now. ALso it is easier to work with if the character already looks somewhat like its pdf version. Should work in differing OS-es hopefully - appreciate any feedback on that point particularly please - I may need to change to a numeric utf-8 style generation of the characeters. I've set the short cut to Alt+C Alt+A (Character - Accented) - you can change that at the top of the script. When inserted in your document, these (especially capitals) may look strange in certain editor fonts, but should produce ok under pdflatex, if your production font has the characters and if % !TEX TS-program = pdflatex % !TEX encoding = UTF-8 Unicode is at the top of your TeXworks document. Paul paul.a.norman@gmail.com TwScript.paulanorman.com  Original comment by paul.a.norman on 1 Feb 2011 at 1:52 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 SCRIPT: helpLatex2e.js VERSION: 0.55 Intended for TeXworks development versions after November 2010 - (current Tw ver 0.3 release728+) Earlier versions may work with http://texworks.googlecode.com/issues/attachment?aid=-1422232581323878961&name=H elp_latex2e_ver_0-52.zip&token=e67ae4aa0aaa91eab3ea65bc0030fa49 RELEASE DATE: Tuesday 1st, February, 2011 BRIEF: Karl Berry's much improved/updated NASA html Help information in a paste-able TeXworks dialogue. Shows LaTeX2e help information form within the TeXworks editor. INSTALL: (The zip completely replaces any version released here previously. If you installed one, delete its whole directory first.) Unzip to any (new) directory under you TeXworks script directory - see http://code.google.com/p/texworks/wiki/TipsAndTricks?can=5#Locating_and_customiz ing_TeXworks_resources for further information. Allow decompression to use folder names'. Change the Alt key combination if you want/need to avoid conflicts with any existing scripts. Then use Tw Menu item, Scripts/Scripting TeXworks/Reload Scripts List USAGE: (N.B. If you "paste" from the help dialogue, any text already selected in the editor, will be replaced.) First, if you want to - in the Tw Editor, select some text, a full command, or partial text that you want to search for help on. (Double clicking a LaTeX command name will select it for you.) While in your editing document Hold down the Alt Key and before releasing it, tap the F1 and then the 2 keys, than release the Alt key. Further help information is available in the dialogue that opens. Reasonably intuitive. Type partial LaTeX commands or concepts into the text box at the left. IN the main help document window highlight any text you want inserted into your TeXworks editing document, and either use the button "Paste Selection into Tw" and find more selectable text and paste in teh same way (use Cancel when finished), or select some text and OK (will paste and close dialogue). UPDATES: http://code.google.com/p/texworks/issues/detail?id=261 And also check occasionally for any new material at TwScript.PaulANorman.com BACKGROUND: Hi, This is a Tw help dialogue originally released July 7th 2010 that replaces the NASA help info. It utilises the LaTeX2e Help work done by Karl Berry and others. Paul paul.a.norman@gmail.com TwScript.paulanorman.com  Original comment by paul.a.norman on 1 Feb 2011 at 9:23 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Code Snippet findFromScript() - out of discussion http://tug.org/pipermail/texworks/2011q1/003718.html function findFromScript() { if (this.findFromScript.arguments.length > 0 && this.findFromScript.arguments[0] != "") { useThis = this.findFromScript.arguments[0]; } else { useThis = "Find Text" } with (TW.target) { var selStart = selectionStart ; insertText(useThis); selectRange(selStart,useThis.length); copyToFind(); insertText(""); doFindDialog(); } }  Original comment by paul.a.norman on 3 Feb 2011 at 9:37

### GoogleCodeExporter commented Mar 14, 2015

 findFromScript is looking good, but you should also take into account the case when there is an actual selection in the document. I.e., save the selectionEnd, and call selectRange(selStart, 0) before inserting text. Otherwise you'd effectively delete the portion of the text is selected before the function call.  Original comment by st.loeffler on 3 Feb 2011 at 9:44

### GoogleCodeExporter commented Mar 14, 2015

 Code Snippet findFromScript() - out of discussion http://tug.org/pipermail/texworks/2011q1/003718.html - and http://code.google.com/p/texworks/issues/detail?id=261#c48 function findFromScript() { with (TW.target) { var saveSelStart = selectionStart ; var saveSelectionLength = selectionLength ; if (this.findFromScript.arguments.length > 0 && this.findFromScript.arguments[0] != "") { useThis = this.findFromScript.arguments[0]; } else { useThis = "Find Text" } selectRange(saveSelStart,0); // avoid overwriting existing text if selected insertText(useThis); selectRange(saveSelStart,useThis.length); copyToFind(); insertText(""); selectRange(saveSelStart,saveSelectionLength); doFindDialog(); } }  Original comment by paul.a.norman on 3 Feb 2011 at 10:10

### GoogleCodeExporter commented Mar 14, 2015

 Searching within Large Paragraph(s) located by syncTeX from Tw Previewer. Out of discussion: - http://tug.org/mailman/htdig/texworks/2011q1/003737.html Standard Tw Find does not give multiple results for a Find performed within in a Selected area. INSTALLATION: Unzip anywhere under your Scripts folder (new folder or existing one or none). USAGE: Triple Click the target paragraph / select paragraph(s) first, then run this script. Shortcut Alt+L & ALt+S If multiple results are found, a drop down selection box is presented to the User to choose from, otherwise if one result it found - the chosen result is jumped to and highlighted. Script has much room for improvement ... And could be partially automated if we had access to a global varible that could be updated at this point in PDFdocument.cpp Line 1464 (ver 0.3 rev 729) TeXDocument::openDocument(QFileInfo(curDir, filename).canonicalFilePath(), true, true, synctex_node_line(node)); http://code.google.com/p/texworks/issues/detail?id=472 paul.a.norman@gmail.com  Original comment by paul.a.norman on 10 Feb 2011 at 4:43 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Clips Storage Useful for reusable text, or blocks of LaTeX portions that need to be stored for later insertion in documents. Especially useful where defining a new LaTeX command in a .sty is not appropriate, as some change may be needed on each usage. Selected text is stored in a directory structure within your Script directory tree. Such saved Text can be identified in a drop-down box and inserted into a document, or the saved text can be retrieved for editing itself. Saved portions are stored as plain uncompressed text that can be edited/updated by other applications. Developed under Windows, may need tweaking on line 68 for use on MacOsx or Linux, haven't been able to test there. Script written in QtScript and gives simple examples of the revised readFile, writeFile, System and openFileFromScript TwScript api calls and usage. Setup ----- Unzip this script into its OWN ( <-essential) directory under /scripts Make a new folder if necessary. (See http://code.google.com/p/texworks/wiki/TipsAndTricks?can=5#Locating_and_customizing_TeXworks_resources for further information if needed.) You'll need to turn on file access (both Read and Write) and System commands in Tw Menu: Edit/Preferences/Scripts note the warnings there. USAGE ----- If any text is selected in editor, will try to store it to disk. - else with no text selected in editor, it will try to retrieve text clip from disk and insert into editor / or edit previously saved text clip. Shortcut: Alt+S, Alt+C Feedback much appreciated, Paul paul.a.norman@gmail.com  Original comment by paul.a.norman on 10 Feb 2011 at 5:35 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

  This is a temporary EXPERIMENTAL workaround in scripting for saving accepted words from spell checking marks. Use at Your own risk! MAKE a BACKUP of your current dictionary first!!! Installation: put in any directory under your script folder. Turn on both Read and Write permissions in Edit/Preferences/ Scripts First usage will ask you to select your dictionary (ending in .dic). Usage: Selected text (User selects/double clicks - first) is added to the user's current dictionary, if no text is selected in editor, the current dictionary is opened for editing - look at the end of it. Additions do not take effect until TeXworks is started again - meanwhile for current session, tell spell checker to ignore word after adding it. Shortcut: Alt+H & Alt+S  Original comment by paul.a.norman on 13 Feb 2011 at 10:21 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 This script runs TexDoc using a package name highlighted in the Tw editor. This will either show package help or other choices if available. If you are using and have MiKTeXes automatic package loading turned on, and are using a new package - compile your Tw document at least once before using this script if you want help for that package. Shortcut: Alt+T & Alt+D NEED: You'll have to turn on Edit.Preferences/Scripts System commands for this to work Install: anywhere in your script folder tree, then Tw Menu Scripts / Scripting TeXworks/ Reload Script List USAGE: double click on a package name (select name) in Tw editor and use this short cut (above) You may need to associate Yap (or other) with .dvi files. On MikTex Yap.exe is in the \miktex\bin folder I origianlly did this as a Lua script in 2009-09-19 /* package = "texdoc " .. TW.target.selection os.execute(package) -- TW.result = package; */ But you would need to turn on other script plugins for that to work - perhaps considered by some as even more dangerous than QtScript with System turned on :);) paul.a.norman@gmail.com  Original comment by paul.a.norman on 13 Feb 2011 at 11:09 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Hi, I've started putting scripts on an extension of some web space I use, to make maintaining them easier as discussed http://tug.org/mailman/htdig/texworks/2010q3/002955.html Here are the current Help scripts I have done. 1. A script (Alt+F1 & Alt+1) for getting help on, packages (local and web), Faq (local and web) and genreal LaTeX commands (web). http://twscript.paulanorman.com/downloads/?GeneralHelp 2. And another (Alt+F1 & Alt+2) for getting LaTeX2e help built in to the Tw Editor. http://twscript.paulanorman.com/downloads/?Latex2eHelp Appreciate any feedback especially on 1. above and working it on Mac. Paul paul.a.norman@gmail.com  Original comment by paul.a.norman on 14 Feb 2011 at 6:16

### GoogleCodeExporter commented Mar 14, 2015

 Get Translation - Experimental More details, and Available on http://twscript.paulanorman.com/downloads/?GetTrans Currently Windows Only. Useful for initial translation in TeXworks of small portions needed on the fly. Usage: Highlight a block of text, a few small paragraphs or one big one. Run Script, choose languages (these will be remembered for current Tw editing session). Maximum of 1500 characters at a time will be processed - will be clearly marked in results. Result is slightly preprocessed for LaTeX requirements. (Google's total daily combined limit for all TeXworks users of this Script is presently 100,000 characters - on days that this is exceeded, script wont work). Gives a Scripting example of using TW.script.xxxGlobal(s) with JSON, and TW.system(). Utilises the Google Translation Api. More details, and Available on http://twscript.paulanorman.com/downloads/?GetTrans  Original comment by paul.a.norman on 17 Feb 2011 at 6:03

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Off Keyboard Symbols - Characters BRIEF: Will take a string of unicode(s) hexidecimal numbers and insert as unicode character(s) Download / Updates: http://twscript.paulanorman.info/downloads/?MakeUnicode INSTALL: Unzip to any directory under you TeXworks script directory - see http://code.google.com/p/texworks/wiki/TipsAndTricks?can=5#Locating_and_customiz ing_TeXworks_resources for further information. Allow decompression to use folder names'. Change the Alt key combination if you want/need to avoid conflicts with any existing scripts. Then use Tw Menu item, Scripts/Scripting TeXworks/Reload Scripts List USAGE: Any Os. Write one or a list of hexadecimal for unicode characters separated by one space (as below) use a double space to get a word space e.g. 006c 006f 0054 0065 Select (highlight) the codes, and use short cut Alt+M&Alt+U, or position cursor with nothing selected and run shortcut For example.. 0048 0065 006c 006c 006f 0054 0065 0058 0077 006f 0072 006b 0073 Would yield: Hello TeXworks Paul  Original comment by paul.a.norman on 10 Mar 2011 at 6:22

### GoogleCodeExporter commented Mar 14, 2015

 Hi, A Windows Only Solution - short file names. There are times in LaTeX, operating under Windows, when it is useful to be able to just insert the short "no spaces" version of a file name or path. Dialogue box locates a file, and the windows short version of its name, is inserted in TeXworks document (no spaces in path). Enable System access see: http://twscript.paulanorman.com/docs/html/files/TexWorksApplicationProgramingI.h tml Script Download: http://twscript.paulanorman.com/downloads/?ShortName Note: (contains a CSRIPT call to activeX objects - see contained systemShortName.js)  Original comment by paul.a.norman on 17 Apr 2011 at 5:43

### GoogleCodeExporter commented Mar 14, 2015

 xcolor_svgnames_X11names.js Version 0.4 - Sunday 17th, April, 2011 Displays some standard colours and offers some colour macro commands for insertion into Tw Document. This is a prototype which will be developed when time permits. Needs File read and write see: http://twscript.paulanorman.com/docs/html/files/TexWorksApplicationProgramingI.h tml Script Download: http://twscript.paulanorman.com/downloads/?InsertColour  Original comment by paul.a.norman on 17 Apr 2011 at 10:51

### GoogleCodeExporter commented Mar 14, 2015

 Context based autocompleter for completing words used in the open document, arguments to label and ref and as a new feature filename autocompletion for include, input and includegraphics commands. Guide to use. 1. start typing the long word that should be autocompleted 2. press " + m" and the autocompleter will complete the word or at least make a suggestion for a completion. 3. if not satisfied with the suggestion press " + m" until the correct word is found.  Original comment by henrikmidtiby@gmail.com on 16 May 2011 at 3:48 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Ok, here is a small script for completing an environment like \begin{something} I think it is multi nesting safe - place cursor on a new line, where you want \end{something} and just activate with Alt E keys. It works from top down to where your cursor is, so it won't know if the environment is already ended past the cursor. After some discussion on the list, I realised that I had always wanted this for myself when ever someone had mentioned it, and finally felt to have a real go at it! Please let me know what breaks it. Paul  Original comment by paul.a.norman on 17 May 2011 at 6:58 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 [deleted comment] 

### GoogleCodeExporter commented Mar 14, 2015

 Ok, found a few things that would break script mentioned in comment 61. Here is a link to a new download. Also script now enhanced to indicate which open Environments have not yet been closed in a document. Activates with Alt E twice, Paul http://twscript.paulanorman.com/downloads/?endEnvironment  Original comment by paul.a.norman on 18 May 2011 at 2:27

### GoogleCodeExporter commented Mar 14, 2015

 Smartwrap ========= The built-in support for hard wrapping in TeXworks (version 0.4) is, at best, very limited. Smartwrap is a TeXworks script to support more intelligent handling of hard wrapping in LaTeX files. Features: - Formats paragraphs by adding or removing hard wrapping. - Applies to the paragraph containing the cursor, or to paragraphs in a selected region. - Respects indentation levels. - Tries hard to identify text which should not be reformatted such as equations, verbatim environments or lines containing comments.  Original comment by shibt...@gmail.com on 24 May 2011 at 3:41 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Open Pdf in Acrobat Reader -- Was: http://code.google.com/p/texworks/issues/detail?id=261#c35 Here is a simplistic scripting implementation of a suggestion by Bruno to look at using pdfopen. Could use pdfclose if that is needed as well. ** Before Use - See license and disclaimer in Script File Useful when acrobat reader needs to be used to check something like \pdfmarks Regrettably at present this is Windows only - Bruno and I tried! Utilises a hightech in-built human observational facility for determing the poppler preview page number :) (your eyes) Each call of this script will open a new instance of acrobat reader (a work around for a DDE issue if the document is requested for a new page number) Under Windows at least the the acrobat reader pdf appears to still need to be closed prior to TeXworks Typesetting taking place. Text highlighted in the Tw editor would be used as a specified "named destination" (if you have any) see hyperref package, otherwise a page number is requested (optional - the box can be canceled). Feedback appreciated please, Paul  Original comment by paul.a.norman on 11 Jun 2011 at 12:45 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Auto Prompt for very basic document version backup scheme http://paulanorman.info/twscript/downloads/index.html?VersioningBasic Two hook scripts that run on File Open, and Typeset (success or failure) with a prompt offering to make a backup (with date and time in file name) in a location of your choosing. Standard locations are listed, and there is an option to choose a new backup location. Each distinct new save location is stored, and presented as an option during further uses of the script(s). After a custom location is first used, the last used folder will appear in the top of the drop down on successive script runs. Additionally there is a manually run script, for creating a version backup at any time. Paul  Original comment by paul.a.norman on 10 Jul 2011 at 12:05

### GoogleCodeExporter commented Mar 14, 2015

 I have migrated my scripts to https://github.com/stloeffler/TeXworks-scripts as well as updated them and commented them (a little). These are: - "Inline bibliography" (does what the name suggests; required for some scientific journal submissions) - "Open containing directory" (opens the directory containing the active file; similar to Paul's script above, but should work on all platforms) Additional scripts will be added there. I've also deleted my previous comments containing the old revisions.  Original comment by st.loeffler on 27 Jul 2011 at 12:08

### GoogleCodeExporter commented Mar 14, 2015

 Hi, Here is a third look at a Script for helping people start new scripts for TeXworks. This one ver 0.311 has a minor fix to the end of a Lua script header. It now forms the header for QtScript, Python and Lua scripts, and can incorporate any new scripting engines that may be added later. Helps set up the header correctly - I hope :) Can be modified for other Script languages easily. Put into a sub-directory under your scripts folder. In Scripts menu "Reload Scripts List" If Preferences / Scripts / Write is turned on, it will remember the Author's Name for future use. If you don't want to do that just edit "Your Name" out of authorName.txt in which ever folder you put the script in from the zip. Make a new document in Tw (click into the new document if necessary), and use Alt+N Alt+S (if you have not already allocated it for something else) or use Scripts Menu look for "Make Script". Comments, feed back, appreciated please, Paul  Original comment by paul.a.norman on 5 Nov 2011 at 3:45 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 SCRIPT Collection: text Styles, Sizes, (Ulem) Special Underlining and Strike through Combines as a collection and updates three previous scripts in this list. http://code.google.com/p/texworks/issues/detail?id=261#c18 http://code.google.com/p/texworks/issues/detail?id=261#c19 http://code.google.com/p/texworks/issues/detail?id=261#c21 SHORTCUTS: Text Sizes - Alt T Alt S Font Styles - Alt C Alt S (character Style) ulem Special Underlining - Alt S Alt U VERSION: 0.1 RELEASE DATE: Tuesday 8th, November, 2011 BRIEF: Drop Down boxes to provide LateX text size, {\large upto three words} \begin{large}Some more and more\end{large} \large text style, \textit{} {\itshape } \itshape and ulem package special underlining, wavy, double line-wrap-single-underline also strikeout and X-through. Go to http://twscript.paulanorman.com/downloads/?textStylesSizesUlemUnderlining Paul  Original comment by paul.a.norman on 8 Nov 2011 at 10:46

### GoogleCodeExporter commented Mar 14, 2015

 Previous Comments 13 and 14 on this issue 261, covering openAllinputs-tex.js have been replaced by a replacement script, link below, by Henrik Skov Midtiby https://github.com/henrikmidtiby/autocompleteForTexworks/blob/master/scripts/ope nAllinputs-tex.js Paul  Original comment by paul.a.norman on 11 Nov 2011 at 10:33

### GoogleCodeExporter commented Mar 14, 2015

 Can someone please tell me how to add a keyboard shortcut to the openContainingDirectory script? I tried adding "// Shortcut: Ctrl+e" but that doesn't work.  Original comment by dpak.che...@gmail.com on 23 Dec 2011 at 3:40

### GoogleCodeExporter commented Mar 14, 2015

 Hi, // Shortcut: Ctrl+e Might already be assigned in one of your TeXworks scripts, plus you need to have run Menu>Scripts / Scripting TeXworks/ Reload Script List to get newly added scripts and shortcuts working, or just restart TeXworks after saving the script in the Scripts folder sub tree. I tried Stefan's script with // Shortcut: Alt+O, Alt+C, Alt+D (When using, hold the Alt down and tap OCD release Alt) I use three letter short cuts now (but you don't have to) to leave room for expansion, and they are very easy to remember if based on the Script name -- here Open Containing Directory. Remember if you change a shortcut, save the .js file, and do the reload thing mentioned above to see the changes work. Paul  Original comment by paul.a.norman on 23 Dec 2011 at 11:53

### GoogleCodeExporter commented Mar 14, 2015

 Hi, I've got a bit of a temporary unofficial list of some available scripts, and locations to get them from, on the first page at http://twscript.paulanorman.info Paul  Original comment by paul.a.norman on 11 Jan 2012 at 5:36

### GoogleCodeExporter commented Mar 14, 2015

 Here is a proof of concept for version checking on the web. checkTexWorksVersion.js needs to go under your TeXworks Scripts folder. Activate with ALT C T V That will run on twscript.paulanorman.info You can put TeXworksCheckVersion.txt and TeXworksCheckVersion.html on any local/wide web server and they will work in any JavaScript enabled browser. Edit the numbers in TeXworksCheckVersion.txt, and the address http:// in checkTexWorksVersion.js I think that we need some sort of easier exposure to script of release and version strings please. Paul  Original comment by paul.a.norman on 16 Jan 2012 at 12:17 Attachments:

### GoogleCodeExporter commented Mar 14, 2015

 Hi, Here are some useful scripts I implemented: /* GLS */ /* It converts an acronym or glossary entry to \gls{...} as it sets toLowerCase and if the text ends in 's' it assumes the plural form \glspl{...}. If no selected text, it creates the \gls{} and puts the cursor inside.*/ var selTxt = cursor.selectedText(); var txt = selTxt.toLowerCase(); if(selTxt.charAt(selTxt.length-1)=='s') { editor.write("\\glspl{"+txt.substring(0,txt.length-1)+"}"); } else { editor.write("\\gls{"+txt+"}"); } if(selTxt.length==0) cursor.shift(-1); cursor.clearSelection(); /*Auto Itemize*/ /*It adds itemize to the text block whilst assuming each new line the item separator*/ var selTxt = cursor.selectedText(); if(selTxt.length>0) { editor.write("\\begin{itemize}\r"); editor.write("\t\\item "); var resText = selTxt.replace(/(\r\n|\n|\r)/gm,"\r\t\\item "); editor.write(resText); editor.write("\r"); editor.write("\\end{itemize}"); } else { editor.write("\\begin{itemize}\r\t\\item \r\t\\item \r\t\\item \r\\end{itemize}"); } cursor.clearSelection(); I don't know if this is the right place to say this but I would appreciate if someone put a close button in the message/log file panel so that every time my tex has errors I have not have to go to the view options and disable it. Miguel  Original comment by miike...@gmail.com on 23 May 2012 at 4:57

### GoogleCodeExporter commented Mar 14, 2015

 Hi, Here is an update for the basic LateX2e help dialogue that removes the requirement of having to have the TeXworks debugger on, as reported by Juan Leal. Thread: http://tug.org/pipermail/texworks/2013q1/005712.html New Download: http://twscript.paulanorman.info/downloads/?Latex2eHelp Kind regards, Paul  Original comment by paul.a.norman on 18 Feb 2013 at 1:01

### GoogleCodeExporter commented Mar 14, 2015

 Dear Paul, I followed all the instructions but the backup file is void all the times. I am running under Ubuntu and I use Texworks. I have never scripted myself before! Thanks Anna (writing her PhD Thesis)  Original comment by anuskita...@gmail.com on 24 Sep 2013 at 5:18

### GoogleCodeExporter commented Mar 14, 2015

 Sorry Paul, now it works fantastically well :) I said everything yes in the script's preferences (I had the option you said activated already) and now it works. Thanks so much for sharing. When I finish I will try to get into scripting, in order to save collectively a collection of files, like the thesis chapters. Best wishes, Anna  Original comment by anuskita...@gmail.com on 24 Sep 2013 at 5:50