## 5 Going further: Other tools ### 5.1 SyncTeX-ing between source and preview When you are reading a document in preview and see something to change, it is convenient to go immediately to the same place in the source. To do that, hold down `[Ctrl]` (Mac OS X `[Cmd]`) and click at the appropriate place in the preview window: the cursor will jump and highlight the same location in the source window. The same is true in the other direction: `[Ctrl]+[click]` in the source will highlight the same line in the preview window. It is also possible to use a [Right-click] to open a context window and select “jumpt to PDF”' or “jump to source”'. Here a remark for users under Windows: this only works if all the names for folders/files/…do not have accented characters. If, for example, your document is in `C:\Documents and Settings\Propriétaire\My Documents\thesis` it will not work because of the `é` of `Propriétaire`! ### 5.2 Special comment strings Special comments, at the very beginning of the files, can be used to manage two other aspects of the compilation. By default, TEXworks uses the “utf8” encoding for saving files, but some files could be saved in another format. To ask another encoding for a specific file one can put at the beginning of this file: `% !TeX encoding = latin1` : another encoding often used. If we want to compile a file with another programme than the default TEX or LATEX, we put at the beginning of the file: `% !TeX program = the_programme` for example: `% !TeX program = xelatex` Pay attention about this last instruction: you have to use here the name of the programme which should be used for the whole project, as it is the programme name which is first encountered when starting typesetting (the one from the sub-document in which you are), TEXworks will use that programme, even if another name appears in the main document! When opening a document with a specified programme name, this will become the programme to use (its name will appear in the drop down menu in the Tools bar); but if you then manually change the programme, it is the one shown in the drop down menu which will be used. ### 5.3 Formatting the source for legibility To facilitate legibility of the source, one can use indentation as programmers do:
    \begin{itemize}
        \item First element of the list;
        \item second element;
        \item last element:
        \begin{itemize}      % beginning of a sub-list
            \item first sub-element;
            \item second sub-element.
        \end{itemize}
    \end{itemize}
this increases legibility, but works well only on short lines, without text wrapping; or if one chooses not to use text wrapping by un-checking Format / Wrap lines. The command Format / Indent or the short-cut “`Ctrl+]`” (Mac OS X “`Cmd+]`”) will indent the line, or the selected lines, by inserting a tab character. You can repeat the process to increase the indent. To remove one indentation: Format / Unindent or the short-cut “`[Ctrl+[`” (“`Cmd+[`” on Mac OS X) 18. As indent only indents the first line of multiline (if wrapped) lines, this is not very satisfactory. But one can ask TEXworks to split a long line (longer than the width of the editing panel) into short ones adding a hard coded line feed: Format / Hard Wrap... opens a dialog box in which you can specify the width of the lines; you can also re-format lines which have already been split. ### 5.4 Showing the tags When a document is becoming long and you want to move to a specific place (a chapter, a section, a sub-section, …) you need to scroll the editing window to find the desired location. You can also use the structural information in the document to navigate the source: Window / Show / Tags opens a panel showing the information detected by TEXworks. Clicking on an item in the panel selects the corresponding part of the source. That panel, like any other, can be resized by dragging its border. The same action is possible in the .pdf window from Window / Show / Table of contents, but this only works if one has created structure tags in the .pdf file using the package `hyperref`. ### 5.5 Organising the windows By default, the editor/source window opens on the left and the preview one on the right (when the corresponding PDF file exists), thus splitting the screen in two. You can change the position of the windows in the menu Window. Stack and Side by side give the same effect if there is only one document open, if not, Stack creates a mosaic with all the windows. The other options allow to place the windows for your convenience. It is also always possible to resize and move the windows. For the preview you can change the way it is presented and of course the zoom by Actual size, Fit to width and Fit to window using the options of the View menu; you can also zoom in and out. Shortcuts exist for all these actions and are shown next to the option in the menu. ### 5.6 Cleaning the working folder Very soon when one uses (LA)TEX, one discovers that the working folder is cluttered by many files which have the name of the source file but different extensions: `.aux`, `.log`, `.toc`, `.lof`, `.lot`, `.bbl`,… All these are files needed by (LA)TEX to be able to create the table of contents, lists of figures/tables, the bibliography, the cross references and, also very important, to keep track of what it did (the .log file). Apart from the external files, images, pictures,…, the only files required are the `.tex` files, the sources of the document. One can erase all the others. This can be done using a TEXworks command from the File menu: Remove Aux files…. When you ask for this command, a dialog box opens in which you can check/uncheck the files you want to remove 19; you have the choice for `aux`, `log`, `toc` and others depending of what you did. If you already removed some of these files, the choices may differ in the dialog box; if you removed all, you get a message box saying that there is no file to remove at the moment. The list of auxilliary files which are shown is in the file `texworks-config.txt` in the `configuration` folder of the TEXworks resources folder. You could add some if required. ### 5.7 Changing the configuration We have seen in section 2 that at first use TEXworks creates a resource folder in `home` (variable on the different systems) and also that it saves preference information (under Windows in a registry key). But it is possible to define a personal place where one wants the resource folder and the preferences. This can be handy when one wants a portable system or when one wants to easily access the templates or completion folders for modifications. For this create in the programme folder a file `texworks-setup.ini` in which one specifies the path to the folder containing the completion, configuration, dictionaries,…folder and the configuration file (`texworks.ini`); there will be two lines:
    inipath=C:/myfolder/TW_conf/\index{configuration!inipath}
    libpath=C:/myfolder/TW_conf/\index{configuration!libpath}
`inipath` for the configuration file and `libpath` for the necessary folders. Here `TW_conf` would replace the resource folder `TeXworks`. Notice first that the referenced folder (here `TW_conf`) should exist, it will not be created, and second the use of `/` and not the backslash generally used under Windows. If one wants to put the resource folder in the programme folder, as a sub-folder, one can use an instruction like `“inipath=./TW_conf/`”; this reference and the other relative references are always related to the TEXworks programme folder. One could add a first line: `defaultbinpaths=C:/Program Files/MiKTeX 2.7/miktex/bin` to specify where are the programmes of the TEX distribution; but this instruction is not yet completely operational, especially under Windows.