4 Going further: Editing toolsWhen you have had some practise with TEXworks, you’ll find the need for more effective tools. Many tools exist in TEXworks. We are going to see them now. 4.1 Creating a document from a templateMost documents you will create will use the same instructions in the preamble, the same layout settings, similar heading and so on. You can use predefined templates or create your own with all of these settings already in place. Use File / New from template… or If you want to create a personal template, you just have to create a suitable document with everything you always want to do (and perhaps marking places to fill in) and save it as a 4.2 Creating a project using several source filesWhen the source becomes long, it is sometimes difficult to navigate in it. It is then useful to split the source in different smaller files: one file will be the main document, with the preamble, the But there might be a problem if, in a sub-document, you start typesetting/compilation: as there is no preamble nor To tell TEXworks that it should typeset the main document one adds at the very beginning of the sub-document the instruction:
for example:
If the main file is in the same folder, its name is enough, as in the above example. Notice that the slash Further, with MiKTeX, the call to a sub-document, 4.3 Spell-checkYou can turn on automatic spell-checking of your source from Edit / Spelling / <language>: for example en-GB for UK English. During typing, if there is an error, the word is underlined by a red wavy line. A right-click on the word opens a contextual menu in which there are some replacement suggestions. Click on the desired word to make the replacement. Before using the spell-checker, you need to install dictionaries in the right folder of TEXworks: One can use the available dictionaries for OpenOffice and other free software;14, if you have Thunderbird with spell-check, you can copy the 4.4 Search and replace4.4.1 Standard functionsThe options of the menu Search: Find…, Find again, Replace… and Replace again ( There are the usual options: Find backwards, Wrap around or Replace within selection. The following options are also usual: Case sensitive and Whole words. By default the search is forward, towards the end of the document. The option Replace in all open files is also a frequent choice, but not as much as the others; this allows, for example, replacement in all the files of a project – pay attention as this is very powerful. The last option, Regular expression, is detailed in the next sub-section. ![]() In the Search menu there are other options:
4.4.2 Regular expressionsThe regular expressions provide a very powerful tool, but they require some effort to be well understood. To understand them fully would require a manual, so we’ll give some simple ideas of use: see also section 6.2. Suppose we have the following text: Voici du texte pour tester les expressions régulières dans du texte accentué. Voici du texte pour tester les expressions régulières dans du texte accentué. Voici du texte pour tester les expressions régulières. Voici du texte pour tester les expressions régulières. truc truc tél.: 010-99-99-99 tél.: 00.32.10.99.99.99 tél.: 00/32-10/99.99.99 We want to 1) insert an empty line between the paragraphs after “accentué” (to create paragraphs in LATEX) but not after the three telephone numbers; 2) replace each tab character between the two words “truc” of the fourth paragraph, by three spaces; and finally 3) make the telephone numbers consistent by replacing the various punctuation characters by spaces. In the dialog box we have to select the option: Regular expression. For 1) in the dialogue box Replace ( For 2) use For 3) find If one has strings of the same character but of different length (for example 2, 3, 4, 5 characters) and one wants to bring all strings to a string with less characters (for example 2), one can ask to replace the string If one wants to insert at the beginning of some paragraphs separated or not by an empty line the same string, for example If it was making sense, we could replace all the letters between “a” and “m” by “$” using 4.5 Other tools for editing and error tracking4.5.1 Standard toolsIt is always possible to undo an action using Edit / Undo or TEXworks also provides the standard editing tools such as the clipboard; therefore one can select, cut/copy and paste a piece of text. You can select with the mouse by dragging over the desired text, or by double-clicking to select a word. Using the keyboard, holding down You can easily change the case of a selection — put everything upper case or lower case — using Edit / Changer case / and next, depending on the desired effect, ALL UPPERCASE or all lowercase. It is also convenient to show the line numbers, as all errors messages refer to these numbers; you can toggle the line numbers, on the left of the editing panel, on/of by Format / Line Numbers. 4.5.2 CommentingWhen preparing a document with (LA)TEX it is often useful to prevent compilation of a portion of text to be able to locate an error; you can do this piece by piece until you find a part which creates an error. To do this, commenting the source block by block is needed. We have seen that the symbol % marks the beginning of a comment. To comment a big piece of text, it is sufficient to select it and ask to mark it as comment Format / Comment or “ 4.5.3 Matching delimitersA frequent error is to forget a closing symbol: parenthesis, bracket, square bracket, etc. TEXworks helps with a tool to show the pairs of symbols: when the cursor moves over one of these symbols, its partner is briefly highlighted in orange. You can also select an entire block using Edit / Balance Delimiters or by the short-cut 4.5.4 Smart quotesAnother similar error, but this time semantic and having no influence on typesetting, is in the use of quotes when one wants to give focus to some text. There are two types of quotes, in English, the ‘single’ quotes and the “double” quotes. They are obtained by the In a Finally, it is possible to define personal quotes systems in the file containing the definitions ( 4.6 Auto-completionAnother tool which rapidly becomes indispensable is auto-completion. Indeed, when you use (LA)TEX, you have to continuously enter codes to, for example, create environments; you also have to remember to close every group you open. Auto-completion allows you to type a keyword, hit As an example to insert “LATEX”, we have to type Another example is \begin{minipage}{} • \end{minipage}• with the cursor between the empty pair of brackets where you need to enter the size of the minipage. See the section 6.3 for a list of the keywords for auto-completion. Notice the “•” in the minipage environment. They are place holders which can be reached by If a partial keyword is given, repeatedly hitting If you want to create your own keywords, you can add a bfigo:=\begin{figure}[#INS#]#RET##RET#\end{figure}• \bibliography{#INS#}• In the first case, In the second case we give ourselves a short-cut, which will let us type the first part of Of course it is always possible to use “•”! The .txt file containing the auto-completion information needs to be UTF-8 encoded: it can be created with TEXworks. |