Professional Documents
Culture Documents
A Short Manual For Texworks: Lowering The Entry Barrier To The Tex World
A Short Manual For Texworks: Lowering The Entry Barrier To The Tex World
Contents i
1 Introduction 1
1.1 Icons and style . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2 Installation 5
2.1 Under Windows . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Under Linux . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3 Under Mac OS X . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.4 Ready! . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3 First steps 8
3.1 Interface summary . . . . . . . . . . . . . . . . . . . . . . . . 8
3.2 Creating a document . . . . . . . . . . . . . . . . . . . . . . . 9
3.2.1 Writing the document . . . . . . . . . . . . . . . . . . 9
3.2.2 Typesetting the document and viewing it . . . . . . . . 10
3.2.3 The work of LATEX . . . . . . . . . . . . . . . . . . . . 11
3.3 And when errors occur? . . . . . . . . . . . . . . . . . . . . . 12
3.4 Changing TEXworks parameters for convenience . . . . . . . . 15
i
Contents ii
A Customizing TEXworks 36
A.1 Syntax highlighting . . . . . . . . . . . . . . . . . . . . . . . . 36
A.2 Keyboard shortcuts . . . . . . . . . . . . . . . . . . . . . . . . 38
A.2.1 Predefined shortcuts . . . . . . . . . . . . . . . . . . . 39
A.2.2 Actions listed alphabetically . . . . . . . . . . . . . . . 41
A.2.3 Actions listed by menu . . . . . . . . . . . . . . . . . . 42
A.2.4 Other actions . . . . . . . . . . . . . . . . . . . . . . . 44
A.3 Roots for completion . . . . . . . . . . . . . . . . . . . . . . . 44
B Regular expressions 57
B.1 Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
B.2 Codes to represent special sets . . . . . . . . . . . . . . . . . . 58
B.3 Repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
B.4 Alternatives and assertions . . . . . . . . . . . . . . . . . . . . 60
B.5 Final notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
Contents iii
C Compiling TEXworks 62
Bibliography 64
Index 65
Introduction
1
Donald E. Knuth decided to create a new typesetting system, which would
be called TEX, because there had been a change in the printing system used
for the volumes of his book The Art of Computer Programming and Knuth
found the result of the new system awful.
The goal of TEX was then to have a system which would always produce
the same documents independently of the actual machine they were processed
on. Knuth also designed the Computer Modern family of typefaces and the
METAFONT language for font description.
The work initiated in 1977 was finished (the languages were “frozen”)
in 1989. TEX and METAFONT are not evolving any more except for minor
bug fixes (TEX versions are numbered following the decimals of π—now
3.1415926—and METAFONT the decimals of the number “e”—now 2.718281).
TEX provides basic tools (commands/instructions/“primitives”) to define
typesetting; almost every detail has to be defined, but the language allows the
creation of macros for repeatedly used constructs. So collections of macros
are loaded through format files (i.e., pre-compiled large macro collections).
Knuth created an original default format (600 commands, more or less)
which is called Plain TEX. This facilitates creating documents.
The most widely used format is LATEX (Leslie Lamport, 1985), which pro-
vides more global commands and structures for documents (article, book,. . . )
allowing easier and faster work, but sometimes with loss of flexibility due
to the more or less rigid framework. But there are many other formats and
TEX-variants in use as well, such as AMS-TEX, AMS-LATEX, ConTEXt, or
XETEX, each having specific goals and advantages (and drawbacks).
To extend the format, one loads “packages” which are collections of macros
specific to some aspect of typesetting.
From its specification in the late 1970s, the TEX family had to evolve until
1
1. Introduction 2
now, last version March 2008, to take into account the developments in the
typesetting world outside TEX.
Some of the problems to answer were/are:
• taking into account other languages with “alphabets” larger than the
ASCII1 one or with non-Latin characters altogether,
• having more fonts, there is not much variety in the fonts created with
METAFONT (few font creators use it),
• using the rich possibilities of other typesetting systems and formats like
PostScript and PDF,
TEXworks is a project to create a text editor for use with the TEX
family of tools; we will refer to these as (LA)TEX. Instead of creating a new
sophisticated program, equipped with multiple tool-bars to meet any need,
TEXworks provides a simple editor, offering at first sight only a limited set
of tools for text editing as well as a single button and a menu to typeset a
(LA)TEX text.
1
“American Standard Code for Information Interchange”: a character encoding scheme
including only Latin characters found in English, some common punctuation characters,
and a few other symbols such as % or $
2
“Device Independent”: format of files produced by TEX
1. Introduction 3
The idea to create the editor came to Jonathan Kew, the initiator and
leader of the project, after a long period of reflection on the reasons why
potential users tend to keep away from (LA)TEX, as well as pondering the
success of the TEXShop editor on the Mac.
Finally the goal was also to provide the same editor on many operating
systems: TEXworks currently runs on Linux, Mac OS X and Windows. The
interface is always the same and the program offers the same functionality on
all three platforms.
After this introduction, the second section of this manual explains how to
install the software. In the third section, we describe the interface and create
a first document as well as show the basics of TEXworks. In the forth and
fifth section, the advanced tools provided by TEXworks are presented; you
should read these sections only after mastering the basic working of TEXworks.
These advanced tools allow much more effective working practices. The sixth
section gives a brief introduction to scripting. This section focuses on using
ready-made scripts, not on writing your own scripts (which is beyond the
scope of this manual and will be presented elsewhere). After that, the seventh
section in which some pointers to further information about TEXworks and
sources for help are compiled concludes the main part.
Finally, the appendices provide additional information how TEXworks can
be customized, about the regular expression search/replace system, and how
TEXworks can be compiled from source. A short bibliography and an index
conclude this manual.
Code examples are set in a fixed-space, typewriter font, with lines above
and below to set it apart from the rest of the text:
Hello \TeX-World!
5
2. Installation 6
2.4 Ready!
Finally, some files may need to be added to the “personal” files that TEXworks
creates. As the exact location of these depends on your platform, this
will be referred to as <resources> or the TEXworks resource folder
throughout this manual. On Linux, this is ~/.TeXworks, on Windows XP
it is C:\Documents and Settings\<your name>\TeXworks, on Windows
Vista/7 it is C:\Users\<your name>\TeXworks, and on Mac OS X it is
~/Library/TeXworks/ by default. The easiest way to locate this folder in re-
cent versions of TEXworks is to use the Help→Settings and Resources. . .
menu item. It opens a dialog which shows you where TEXworks saves its
settings and where it looks for resources.
After installation and first run, have a look in the sub-folders of the
TEXworks resource folder and delete any qt_temp.xxxx files; they are tem-
porary files left behind and could interfere with the normal ones, which are
installed in the same folder, later on.
First steps
3
Let’s now see how to create a first document: for this you’ll need to type
some text in the editor window of TEXworks. (LA)TEX is not WYSIWYG1
software, so you’ll have to type the text and the instructions for formatting it
and you’ll see the result only after “typesetting” the text. This looks a little
bit dry, but one very quickly gets used to it and it is well worth the effort.
8
3. First steps 9
Title bar
Menu bar
Toolbars
Status bar
Even though they are not looking like real buttons, the widgets in the
status bar can be clicked. The widgets showing the current position (line or
page, respectively), for example, open a dialog to enter a line or page to jump
to when clicked. The other widgets typically open contextual menus where
some settings can be changed.
Let’s create our first document now. Enter the following text exactly as
shown. To show some of the features of TEXworks/LATEX, it is in French
intentionally.
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\geometry{a4paper}
\usepackage[frenchb]{babel}
\title{Premier document}
\author{Un TeXnicien}
\date{}
\begin{document}
\maketitle
\end{document}
Notice that the mouse cursor is like a magnifier in the new window. If you
press (and hold) the left button of the mouse you can see the text under the
magnifier much bigger (it is a magnifier, isn’t it!); you can move the magnifier
and so inspect the text in detail.
To go back to the source, you can just click in its window or better use
Ctrl ’ (Mac OS X ’ ). This shortcut toggles between the two
windows. See also section 5.1 to automatically move to a specific location in
the output from the source or vice versa.
in the preview window. If, in addition, you also comment out the line
\usepackage[frenchb]{babel}, LATEX will give an error. Just hit ←- to
continue the typesetting.
After these experiments, let’s modify the text as follows:
\begin{document}
\maketitle
\tableofcontents
\section{Petite démonstration}
\end{document}
Redo the previous experiments and observe the changes which appear.
Note that entering only one carriage return doesn’t create a new paragraph.
In LATEX, one has to have an empty line for that. In TEXworks, the line
number of the source (on the right in the status bar) numbers the lines created
with carriage return, not the wrapped lines.
Output panel
Console bar
Status bar
One sees the typing cursor in the line between the output panel and the
status bar: the console bar.
The error message is on many lines, for example like this:
• Type h ←- to ask for help; this help is not always clearer than the error
message, but often gives a clue.
You should note that sometimes an error appears far from its actual
position. For example, when opening an environment but not closing it,
LATEX doesn’t see the error before it encounters another end of environment
without closing of the first one. The error is often only picked up at the
\end{document} command, which shows that another environment was not
closed!
Sometimes, an error still occurs during subsequent runs of (LA)TEX even
after it was corrected in the document. This can happen because (LA)TEX
creates a number of intermediary files which can still contain the original,
erroneous code. Therefore, it is advisable to remove those files after fixing an
error. TEXworks provides a command to facilitate this—see section 5.6.
After an error occurred, the output panel remains open—even after con-
secutive typesetting runs—to help you fix the problem (which can sometimes
take several attempts and restarts of (LA)TEX). Once all problems are solved,
you can close the panel by the Windows→Hide Output Panel menu
item. As an alternative, you can also configure to output panel to hide
automatically as soon as the typesetting process finishes successfully by set-
ting Edit→Preferences. . . →Typesetting→Hide output panel to On
success. Since one can easily overlook other problems in the document (e.g.,
undefined references) that do not cause (LA)TEX to fail, this option is only
recommended to expert users.
To help you in finding and fixing error (at least if you are using LATEX),
TEXworks comes with a small script that extracts all errors, warnings, and
other noteworthy messages from the console output and presents them to you
in a simple, tabular form.
3. First steps 15
Here, you see a list of LATEX messages, color-coded and sorted by severity.
Red represents errors, yellow indicates warnings, and blue stands for over-
and underfull box warnings. Next to the colour bar, you see the name of the
file in which the error was detected. Next to that, you see the line number (if
the script was able to determine that), as well as an excerpt from the console
output telling you what the error was. Moreover, the filename is a link which
will take you to the file (and, if a line number could be determined, also the
line) where LATEX reported the error. Hopefully, you can quickly fix any errors
that may occur this way.
In case you are not using LATEX, this script may be of little use, particularly
if the console output is formatted differently. In this case, you can simply
disable the error parsing hook script (see section 6.2).
16
4. Going further: Editing tools 17
for example:
If the main file is in the same folder, its name is enough, as in the above
example. Otherwise, you must also give the path to the main document
(preferably relative to the sub-document in question, e.g., ../manual.tex).
Notice that the slash / and not the backslash \ should be used as directory
separator even on Windows.
Further, with MiKTeX, the call to a sub-document \input{name.tex}
should include the extension .tex to ensure proper SyncTeX functionality
(see section 5.1).
4.3 Spell-checking
You can turn on automatic spell-checking of your source document from Edit
→Spelling→<language>. It is also possible to ask TEXworks to enable
spell-checking by default by setting a dictionary in Edit→Preferences. . .
→Editor→Spell-check language.
During typing, every word the spell-checker considers wrong 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: <resources>\dictionaries. The <resources> folder
can be accessed easily via Help→Settings and Resources. . . .
1
Called by the commands \input{} or \include{}, see LATEX manuals for more informa-
tion.
4. Going further: Editing tools 18
On Linux, the dictionaries are usually taken from the folder /usr/share/
myspell/dicts—the default path for myspell dictionaries. Note, though,
that the maintainer of your TEXworks package may have changed this to
reflect the file system layout of your Linux distribution. You can override
this default by setting the TW_DICPATH environment variable before running
TEXworks.
One can use the available dictionaries for OpenOffice.org and other free
software;2 if you have Mozilla Thunderbird with spell-checking, you can copy
its .aff and .dic files as well, for example.
Here, the usual options are available: Wrap around, Find backwards,
Search/Replace within selection, or Find all occurrences. 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 Search/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, though, 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:
2
See, for example, http://extensions.services.openoffice.org/dictionary. The
.oxt files can be renamed to .zip and then uncompressed to find the required .dic and
.aff files.
4. Going further: Editing tools 19
Copy to Find copies the currently selected text into the Find field of the
Find dialogue or the Replace field of the Replace dialogue; you still
need to open the dialogues separately
Copy to Replace copies the currently selected text into the With field of
the Replace dialogue
Find Selection uses the current selection for a search without opening the
Find dialogue—very fast
We want to
1. insert an empty line after each “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
Such manuals exist on the internet.
4. Going further: Editing tools 20
For 1., in the dialogue box Replace ( Ctrl R ) for Replace: we put
›\n‹4 and in With: ›\n\n‹. ›\n‹ is the code to match or insert a line feed.
You will need to select the first four paragraphs and the beginning of the
fifth (the first telephone number) and to tick the Replace within selection
and Regular expression options; if this was not done and an empty line has
been inserted after each line, select the telephone lines and do the reverse
action: replace ›\n\n‹ by ›\n‹. So we replaced one line feed by two, creating
an empty line.
For 2., use ›\t‹ and › ‹5 . ›\t‹ is the code which represents a tab, while
a space is typed in literally (here represented as ).
For 3., find ›-|\.|/‹ and replace with › ‹. Here, ›|‹ provides alternatives
(-, ., or /); for the dot we have used ›\.‹ because the dot alone is a regular
expression code which represents any character and we would have replaced
all the characters by spaces! We therefore have to use a code—prefixing the
dot with a backslash tells specifies that the normal meaning of the dot should
be used instead of the special meaning it usually has in regular expressions.
If one has strings of the same character but of different lengths (for
example 3, 4, or 5 times the sames character e) and one wants to truncate all
these strings to a string with less characters (for example 2), one can ask to
replace the string ›e{3,5}‹ by ›ee‹.
If one wants to insert the same string at the beginning of some paragraphs
separated or not by an empty line, for example ›\noindent ‹ or ›\item ‹,
one can replace ›\n\n‹ or ›\n‹ by ›\n\n\\noindent ‹ or ›\n\\noindent ‹.
Pay attention, we have a double \ in front of noindent to get one (\noindent)
because \ is an escape character in regular expressions (we’ve met it before
in the expression \.)!
If it were making sense, we could replace all the letters between “a” and
“m” by “$” using ›[a-m]‹ and ›$‹.
4
the ›‹ are used here only to show the limits of the entered text and they should not
actually be entered.
5
These are three space characters.
4. Going further: Editing tools 21
TEXworks also provides the standard editing tools such as the clipboard;
therefore one can select, cut/copy and paste a piece of text normally.
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 Shift ⇑
while moving using the arrow keys will select text. You can also move and
select word by word moving left or right holding Ctrl Shift ⇑ down (
Shift ⇑ on Mac OS X). The clipboard shortcuts are the ones you’ll find in
almost every program: Ctrl X to cut, Ctrl C to copy, and Ctrl V
to paste ( X , C and V , respectively, on Mac OS X).
You can easily change the case of a selection—put everything upper
case or lower case—using Edit→Change case and next, depending on
the desired effect, ALL UPPERCASE, all lowercase, or Toggle Case
(which toggles the case of each letter individually).
It is also convenient to show the line numbers, as all error messages refer
to these numbers; you can toggle the line numbers, on the left of the editing
panel, from Format→Line Numbers.
4.5.2 Commenting
When 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 the part which causes the error. For that,
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 Ctrl Shift ⇑ ] (Mac OS X:
Shift ⇑ ] ). To remove the comment, select the lines and choose Format
→Uncomment or Ctrl Shift ⇑ [ (Mac OS X: Shift ⇑ [ ).7
6
Ctrl Y and Alt Shift ⇑ Backspace work as well on Windows. Y work
as well on Mac OS X.
7
On some keyboards, like the French one, it is impossible to use Ctrl Shift ⇑ [ or
4. Going further: Editing tools 22
4.6 Auto-completion
Another 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 the key, and have
TEXworks insert the (LA)TEX command or environment code automatically.
Ctrl Shift ⇑ ] ; these shortcuts can be changed, however—see section A.2
4. Going further: Editing tools 23
\begin{minipage}{}
•
\end{minipage}•
with the cursor between the empty pair of curly brackets where you need to
enter the size of the minipage. See the section A.3 for a list of the keywords
for auto-completion. Notice the “•” in the minipage environment. They are
placeholders which can be reached by Ctrl ( on the Mac),
repeating this shortcut cycles forward through the placeholders; by Ctrl
Shift ⇑ ( Shift ⇑ ), you can also cycle backwards.
If a partial keyword is given, repeatedly hitting will cycle through
possible completions. For example, bali (the b commonly indicates the
beginning of an environment, \begin{}) creates the align environment after
one , next align*, and after that, in succession, alignat, alignat*,
aligned, alignedat, and alignedat with options; to access the last envi-
ronments directly, they have their own codes which start by bali (balis,
baliat, baliats, balied, baliedat and baliedato).
If you want to create your own keywords, you can add a .txt file in the
completion folder inside the resources folder. The entries in the file should
have the following format:
bfigo:=\begin{figure}[#INS#]#RET##RET#\end{figure}•
\bibliography{#INS#}•
In the first case, bfigo is the assigned keyword (with :=) to be converted
into a figure environment with an optional argument; there are two carriage
returns (#RET#) after the begin, i.e., an empty line, and the cursor is placed
between the square brackets (at the position of #INS#). “•” is a place holder
as introduced before.
8
In particular with keyboard layouts where \ is not directly accessible.
4. Going further: Editing tools 24
In the second case, we give ourselves a shortcut, which will let us type
the first part of \bibliography{} and have TEXworks convert it to the full
name plus braces (with the cursor between them). In this case, the keyword
is the instruction itself.
Note that the .txt file containing the auto-completion information needs
to be UTF-8 encoded—this is the default encoding for all files created with
TEXworks.
Going further: Other tools
5
5.1 SyncTeX’ing between source and
preview
When you are reading a document in the preview window and see something
to change, it is convenient to go immediately to the corresponding place
in the source. To do so, hold down Ctrl (Mac OS X: ) and click at
the appropriate place in the preview; the cursor will move and highlight the
corresponding location in the source window. The same is true in the other
direction: Ctrl in the source will highlight the same line in the preview
window. 1
Here a remark for users under Windows: this only works if all the
names for folders/files/. . . do not have accented characters. If, for exam-
ple, your document is in C:\Documents and Settings\Propriétaire\My
Documents\thesis it will not work because of the é in Propriétaire!
25
5. Going further: Other tools 26
To set a different encoding for a specific file one can put the following at
the beginning of that file:
Note that without this line, you must tell TEXworks the correct encoding
manually. Otherwise, your data could be corrupted! To override TEXworks’s
default choice of encoding, use the menu that appears when you click on the
editor window’s middle status bar widget.
If you opened a file in TEXworks that was not saved as utf-8 but is lacking
the % !TeX encoding line, it might be displayed with (some) weird characters.
In that case, you can specify the correct encoding via the status bar widget
menu in the same way, but it is imperative that you then use Reload using
selected encoding from the same menu! This forces TEXworks to open the
document again with the encoding you selected, the weird characters should
be replaced by normal ones, and only then it is safe to continue to work
normally. To avoid having to repeat this procedure each time you open this
file, you should either switch to utf-8 for saving it in the future or add a
proper % !TeX encoding line.
If we want to compile a file with another programme than the default
TEX or LATEX, we put at the beginning of the file:
for example:
Pay attention to this last instruction. You have to use the name of the
programme here which should be used for the whole project, as the first
encountered programme when starting typesetting is used (which is the one
from the sub-document you are in). TEXworks will use that programme, even
if another name appears in the main document!
When opening a document which contains a % !TeX program line, the
specified programme will become the one to use and its name will appear
in the drop down menu in the toolbar; you can, however, override this by
selecting a different one from the drop down list, if you want.
5. Going further: Other tools 27
In addition, you can set the spell checking language by a similar comment
line:
The language codes available on your system are listed in parentheses in Edit
→Spelling next to the human-readable name of the language.
\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 unchecking Format
→Wrap lines.
The command Format→Indent or the shortcut Ctrl ] (Mac OS X:
] ) 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 level of indentation, use Format→Unindent or the
shortcut Ctrl [ ( [ on Mac OS X).2
As indent only indents the first part of very long (wrapped) lines, this is
not very satisfactory in some cases. But one can ask TEXworks to split a long
line (longer than the width of the editing window) 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.
2
See the modified shortcuts if your keyboard layout does not allow these actions.
5. Going further: Other tools 28
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.
Sometimes, this is even necessary when (LA)TEX gets stuck after an error.
This can be done using a TEXworks command from the File menu with
the →Remove Aux files. . . item.
When you use this command, a dialog box opens in which you can
check/uncheck the files you want to remove.3 The dialog box will only list
files that actually exist in the folder; if you removed all these auxiliary files
before, you get a message box saying that there is no file to remove at the
moment.
The list of auxiliary files which are taken into account is defined in the
file texworks-config.txt in the configuration folder of the TEXworks
resources folder. You could add some if required.
inipath=C:/myfolder/TW_conf/
libpath=C:/myfolder/TW_conf/
inipath for the configuration file and libpath for the necessary folders.
Here, TW_conf would replace the resource folder TeXworks. Note that the
referenced folder (here TW_conf) should exist—it will not be created—, and
that the / is used even on Windows (instead of the common \).
If one wants to put the resource folder in the programme folder as a
subfolder, one can use an instruction like inipath=./TW_conf/; all relative
3
The name of the main file is used to list the possible candidates for deletion.
5. Going further: Other tools 30
paths are taken to be relative to the TEXworks programme folder (on Mac
OS X, the folder containing the app package is used).
One can also add a line like
to specify where the programmes of the TEX distribution are located; but
this instruction is not yet completely operational, especially under Windows.
Advanced use: Scripting
6
6.1 Introduction to Scripting
All the functions and utilities described so far were built into TEXworks
by default. While some of them could be configured or customized to a
certain extent, they are intended to suit the most common needs of a general
audience. However, the TEX world is very large and diverse. In order to
enable users to address their special needs—from simply making some text
bold to fulfilling special requirements for the next book or scientific paper
you want to publish—, the core functionality of TEXworks can be extended
or modified by the use of scripts.
Scripts are simple text files that you can open, read, or modify in any
text editor (including TEXworks, of course). They are written in a specific
scripting language that is essentially a programming language. At the time
of writing, TEXworks supports QtScript1 (built-in), Lua (with a plugin), and
Python (with a plugin). To see which scripting languages are available on
your system, use the Scripts→Scripting TEXworks→About Scripts. . .
menu item.
Writing scripts is beyond the scope of this manual, but is documented
elsewhere2 . Here, only the installation and usage of scripts will be discussed.
TEXworks distinguishes between two types of scripts: standalone scripts
and hook scripts. The primary purpose of standalone scripts is to add new
functionality to the program. If you need a new function, such as a command
to make the selected text bold, a standalone script is the one to choose. These
scripts get an item in the Scripts menu, and you can run them simply by
1
A scripting language similar to JavaScript provided by Qt.
2
See, for example, Paul Norman’s page http://twscript.paulanorman.com/docs/
index.html.
31
6. Advanced use: Scripting 32
clicking on that menu item (or by using a keyboard shortcut, if the script
provides one).
Hook scripts, on the other hand, are meant to extend existing TEXworks
functions. They are hooked into the code at specific places, e.g., after the
typeset process has finished or after a file was loaded, and can add or modify
whatever TEXworks is doing. One example for this would be a script that
analyses a newly loaded file and sets the spell-checking language based on
babel commands found in the document. Thus, hook scripts do not show up
in the Scripts menu but are instead run automatically when the TEXworks
function they modify is used.
You can easily determine which type of script you have by opening the
script file. Near the top of the file, you should find a line similar to
// Type: standalone
Alternatively—once the script is installed—, you can use the dialogue available
from Scripts→Scripting TEXworks→Manage Scripts to display this
information.
After having installed a new script file, TEXworks needs to become aware
of it. It automatically scans for all scripts during start-up, so you could close
all TEXworks windows and restart the application. An alternative is provided
by the Scripts→Scripting TEXworks→Reload Script List menu item
which rescans all scripts without otherwise interfering with the program.
You can also disable scripts (or whole directories of scripts) if you want to.
This can be useful if you do not need some scripts for some time and do not
want them to clutter the Scripts menu, but do not want to uninstall them
entirely. Or if you want to prevent hook scripts from being run automatically.
To do this, open the “Manage Scripts” dialogue with the Scripts→Scripting
TEXworks→Manage Scripts menu item. Simply uncheck the script you
want to disable and it won’t bother you again.
34
7. Beyond this manual 35
all information that might help resolving it. That way, you are much more
likely to get many helpful replies.
If you find a bug in TEXworks or want to suggest a new feature you
would like to see in a future version, you should have a look at the issue
list at GitHub (https://github.com/TeXworks/texworks/issues). Before
posting a new item, please make sure that a similar report or request is not
already on the list and that the issue list is indeed the right place, though. If
in doubt, please ask on the mailing list first.
Happy TEXing!
Customizing TEXworks
A
A.1 Syntax highlighting
Among its many other features, TEXworks also include syntax highlighting.
This means that certain things like LATEX commands, environments, or com-
ments are coloured, underlined, or highlighted in some other way. TEXworks
also provides the ability to switch between different highlighting schemes1 ,
and to define your own ones. This is useful if you often work with types of
files for which no highlighting scheme is provided by default, or if you want to
adjust the highlighting schemes to better match your system’s colour scheme.
To modify the highlighting schemes, you have to edit the plain-text file
<resources>/configuration/syntax-patterns.txt. This file can contain
any number of individual sections, each defining a single highlighting scheme
to be displayed in the menu structure of TEXworks. To define a section, just
write the name enclosed in square brackets on a line of its own. Naturally,
these names should not include the ] character. By default, the following two
sections are defined:
[LaTeX]
[ConTeXt]
In addition, you can add comments to the file by starting a line with #. Empty
lines are ignored.
Each section consists of an arbitrary number of styling rules. Each such
instruction consists of three parts: a formatting instruction, a spell-check
1
Use Format→Syntax Coloring to change the highlighting scheme for the current
document, and Edit→Preferences. . . →Editor→Syntax Coloring to set the default one.
36
A. Customizing TEXworks 37
flag, and a regular expression2 defining what part of a text to match. These
parts must all be on the same line, and separated by whitespaces (e.g., spaces
or tabstop characters). Take for example the following line from the default
LaTeX section:
red Y %.*
The first part, red, defines the format (in this case, a red foreground colour
is specified). The second part, Y, defines that spellchecking should be enabled
for text that matches this particular rule. Sometimes, it is useful to put N
here to disable spellchecking. For example, if spellchecking would be enabled
for LATEX commands, most documents would be flooded with red underlines
indicating misspelled words when in fact they are only special commands.
Finally, the third part specifies that this rule should be applied to all text
preceded by %.
Let us take a closer look at the three parts of each rule. In its most general
form, the first part—the format instruction—looks like
<foreground_colour>/<background_colour>;<fontflags>
red
white/#000000
;B
blue;I
#000000/#ffff00;U
2
For some details on regular expressions, see B
3
See https://www.w3.org/TR/SVG11/types.html#ColorKeywords for a list of valid
names.
4
Because # is also used to mark comments if given as the first character of a line, you
need to add a space, tab, or similar before specifying a hexadecimal foreground color.
A. Customizing TEXworks 38
actionHard_Wrap = Shift+F3
actionLast_Page = Ctrl+End
actionFirst_Page = Ctrl+Home
actionWrap_Lines = F3
actionLine_Numbers = F4
actionBalance_Delimiters = F9
The first line defines that using Shift ⇑ F3 should open the hardwrap
dialogue box in the source window; the second ( Ctrl End ) should bring
you to the last page and Ctrl Home (third line) should take you to the
first page; with F3 you want to wrap/unwrap lines in the source, with F4
you will show/hide line numbers and with F9 you intend to select the text
between corresponding delimiters in the source.
A. Customizing TEXworks 39
Shortcut Action
Ctrl+’ Go to Preview
Ctrl+= Show Selection
Ctrl+A Select All
Ctrl+Alt+S Save All
Ctrl+B Balance Delimiters
Ctrl+C Copy
Ctrl+E Copy to Find
Ctrl+F Find...
Ctrl+G Find Again
Ctrl+H Find Selection
Ctrl+L Go to Line...
Ctrl+N New
Ctrl+O Open...
Ctrl+Q Quit TeXworks
Ctrl+R Replace...
Ctrl+S Save
Ctrl+Shift+C Insert Citations...
Ctrl+Shift+E Copy to Replace
Ctrl+Shift+N New from Template...
Ctrl+Shift+R Replace Again
Ctrl+Shift+S Save As...
Ctrl+Shift+Z Redo
Ctrl+Shift+[ Uncomment
Ctrl+Shift+] Comment
Ctrl+T Typeset
Ctrl+V Paste
Ctrl+W Close
Ctrl+X Cut
Ctrl+Z Undo
Ctrl+[ Unindent
Ctrl+\ Hide Console Output
Ctrl+] Indent
A. Customizing TEXworks 40
Shortcut Action
→ 1 character right
Ctrl+→ 1 word right
← 1 character left
Ctrl+← 1 word left
↑ 1 line up
↓ 1 line down
PgUp 1 screen up
PgDown 1 screen down
Home Begin of line
Ctrl+Home Begin of document
End End of line
Ctrl+End End of document
Shortcut Action
Alt+Left Go to previous view
Ctrl+’ Go to Source
Ctrl++ Zoom In
Ctrl+- Zoom Out
Ctrl+1 Actual Size
Ctrl+2 Fit to Width
Ctrl+3 Fit to Window
Ctrl+4 Fit to Content Width
Ctrl+Backspace Clear
Ctrl+C Copy
Ctrl+F Find...
Ctrl+G Find Again
Ctrl+J Go to Page...
Ctrl+N New
Ctrl+O Open...
Ctrl+P Print PDF...
Ctrl+PgDown Next Page
Ctrl+PgUp Previous Page
Ctrl+Q Quit TeXworks
Ctrl+Shift+F Full Screen
Ctrl+Shift+N New from Template...
A. Customizing TEXworks 41
Shortcut Action
Ctrl+Shift+Z Redo
Ctrl+T Typeset
Ctrl+V Paste
Ctrl+W Close
Ctrl+X Cut
Ctrl+Z Undo
actionAbout_Scripts actionPageMode_Single
actionAbout_TW actionPageMode_TwoPagesContinuous
actionActual_Size actionPaste
actionApply_to_Selection actionPlace_on_Left
actionAutoIndent_None actionPlace_on_Right
actionAuto_Follow_Focus actionPreferences
actionBalance_Delimiters actionPrevious_Completion
actionClear actionPrevious_Completion_Placeholder
actionClear_Recent_Files actionPrevious_Page
actionClose actionPrevious_ViewRect
actionComment actionPrintPdf
actionCopy actionQuit_TeXworks
actionCopy_to_Find actionRedo
actionCopy_to_Replace actionRemove_Aux_Files
actionCut actionReplace
actionFind actionReplace_Again
actionFind_Again actionRevert_to_Saved
actionFind_Selection actionSave
actionFirst_Page actionSave_All
actionFit_to_Content_Width actionSave_As
actionFit_to_Width actionScroll
actionFit_to_Window actionSelect_All
actionFont actionSelect_Image
actionFull_Screen actionSelect_Text
actionGoToHomePage actionSettings_and_Resources
actionGo_to_Line actionShow_Hide_Console
actionGo_to_Page actionShow_Scripts_Folder
actionGo_to_Preview actionShow_Selection
actionGo_to_Source actionSide_by_Side
A. Customizing TEXworks 42
actionHard_Wrap actionSmartQuotes_None
actionIndent actionStack
actionInsert_Citations actionSyntaxColoring_None
actionJump_To_PDF actionTile
actionLast_Page actionTo_Lowercase
actionLine_Numbers actionTo_Uppercase
actionMagnify actionToggle_Case
actionManage_Scripts actionTypeset
actionNew actionUncomment
actionNew_from_Template actionUndo
actionNext_Completion actionUnindent
actionNext_Completion_Placeholder actionUpdate_Scripts
actionNext_Page actionWrap_Lines
actionNone actionWriteToMailingList
actionOpen actionZoom_In
actionPageMode_Continuous actionZoom_Out
Edit
actionBalance_Delimiters actionPreferences
actionClear actionRedo
actionCopy actionSelect_All
actionCut actionTo_Lowercase
actionInsert_Citations actionTo_Uppercase
actionNone actionToggle_Case
actionPaste actionUndo
File
actionClear_Recent_Files actionRemove_Aux_Files
actionClose actionRevert_to_Saved
actionNew actionSave
actionNew_from_Template actionSave_All
actionOpen actionSave_As
actionQuit_TeXworks
Format
actionApply_to_Selection actionLine_Numbers
actionAutoIndent_None actionSmartQuotes_None
actionComment actionSyntaxColoring_None
A. Customizing TEXworks 43
actionFont actionUncomment
actionHard_Wrap actionUnindent
actionIndent actionWrap_Lines
Help
actionAbout_TW actionSettings_and_Resources
actionGoToHomePage actionWriteToMailingList
Scripts
actionAbout_Scripts actionShow_Scripts_Folder
actionManage_Scripts actionUpdate_Scripts
Search
actionCopy_to_Find actionGo_to_Line
actionCopy_to_Replace actionReplace
actionFind actionReplace_Again
actionFind_Again actionShow_Selection
actionFind_Selection
Typeset
actionTypeset
Window
actionAuto_Follow_Focus actionShow_Hide_Console
actionGo_to_Preview actionSide_by_Side
actionPlace_on_Left actionStack
actionPlace_on_Right actionTile
Edit
actionCopy actionRedo
actionPreferences actionUndo
File
actionClear_Recent_Files actionOpen
actionClose actionPrintPdf
actionNew actionQuit_TeXworks
actionNew_from_Template
Help
actionAbout_TW actionSettings_and_Resources
actionGoToHomePage actionWriteToMailingList
A. Customizing TEXworks 44
Scripts
actionAbout_Scripts actionShow_Scripts_Folder
actionManage_Scripts actionUpdate_Scripts
Search
actionFind actionFind_Again
Typeset
actionTypeset
View
actionActual_Size actionNext_Page
actionFirst_Page actionPageMode_Continuous
actionFit_to_Content_Width actionPageMode_Single
actionFit_to_Width actionPageMode_TwoPagesContinuous
actionFit_to_Window actionPrevious_Page
actionFull_Screen actionZoom_In
actionGo_to_Page actionZoom_Out
actionLast_Page
Window
actionGo_to_Source actionSide_by_Side
actionPlace_on_Left actionStack
actionPlace_on_Right actionTile
that you can start to enter the (LA)TEX code and try to complete it with .
During completion, the system inserts line feeds and puts the cursor at
the first place where one has to enter information to complete the typing. To
represent the line feeds we used R and I for the input point.
So, a line like “\begin{abstract}RIR\end{abstract}•” should be inter-
preted as
\begin{abstract}
\end{abstract}•
xa \xa \alpha
xb \xb \beta
\bsk \bigskip
\bigskipR
xch \xch \chi
xcd \xcd \Delta
xd \xd \delta
xe \xe \epsilon
xet \xet \eta
xcg \xcg \Gamma
xg \xg \gamma
\hskip
\indent
\input
xio \xio \iota
xcl \xcl \Lambda
xl \xl \lambda
\msk \medskip
A. Customizing TEXworks 46
\medskipR
xm \xm \mu
\noindent
xn \xn \nu
xco \xco \Omega
xo \xo \omega
\par
xcph \xcph \Phi
xph \xph \phi
xcp \xcp \Pi
xp \xp \pi
xcps \xcps \Psi
xps \xps \psi
xr \xr \rho
\scriptsize
xcs \xcs \Sigma
xs \xs \sigma
\ssk \smallskipR
xt \xt \tau
tex \tex \TeX
texs \texs \TeX\
xcth \xcth \Theta
xth \xth \theta
xcu \xcu \Upsilon
xu \xu \upsilon
xve \xve \varepsilon
xvph \xvph \varphi
xvp \xvp \varpi
xvr \xvr \varrho
xvs \xvs \varsigma
xvth \xvth \vartheta
\vskip
xcx \xcx \Xi
xx \xx \xi
xz \xz \zeta
A. Customizing TEXworks 47
bibitem \bibitem{I}R•
bibstyle \bibstyle \bibliographystyle{I}
biblio \bibliography{I}
\boxed{I}
\caption{I}R
\cdots
center \centering
\chapter{I}
chap \chapter{I}R
\cite{I}
\cline{I}
\date{I}R
\ddddot{I}
\dddot{I}
\ddots
\ddot{I}
\documentclass[I]{•}R
\documentclass{I}R
\dots
\dotsb
\dotsc
\dotsi
\dotsm
\dotso
emd \em
em \emph{I}
\end{I}R
\eqref{I}
\fboxrule{I}
\fboxsep{I}
fbox \fbox{I}
\footnotesize
foot \footnote{I}
frac \frac{I}{•}
fboxoo \fboxoo \framebox[I][•]{•}
fboxo \fboxo \framebox[I]{•}
hw \headwidth
\hlineR
\hspace*{I}
\hspace{I}
incgo \includegraphics[I]{•}R
A. Customizing TEXworks 50
incg \includegraphics{I}R
\include{I}R
\input{I}R
\intertext{I}
\itemRI
ito \item[I]R•
itd \itshape
lbl \lbl \label{I}
\large
\Large
latex \latex \LaTeX
latexs \latexs \LaTeX\
latexe \latexe \LaTeXe
latexes \latexes \LaTeXe\
\ldots
\listfilesR
listf \listf \listoffiguresR
listt \listt \listoftablesR
\makeatletter
\makeatother
mboxoo \mboxoo \makebox[I][•]{•}
mboxo \mboxo \makebox[I]{•}
mpar \mpar \marginpar{I}
mbf \mbf \mathbf{I}
mcal \mcal \mathcal{I}
mit \mit \mathit{I}
mnorm \mnorm \mathnormal{I}
mrm \mrm \mathrm{I}
msf \msf \mathsf{I}
mtt \mtt \mathtt{I}
mbox \mbox{I}
mdd \mdseries
multc \multc \multicolumn{I}{•}{•}
multic \multicolumn{I}{•}{•}
nct \newcolumntype{I}{•}
newct \newcolumntype{I}{•}
ncmoo \newcommand{I}[•][•]{•}R
newcoo \newcommand{I}[•][•]{•}R
ncmo \newcommand{I}[•]{•}R
newco \newcommand{I}[•]{•}R
ncm \newcommand{I}{•}R
A. Customizing TEXworks 51
newc \newcommand{I}{•}R
nenvoo \newenvironment{I}[•][•]{•}{•}R
neweoo \newenvironment{I}[•][•]{•}{•}R
nenvo \newenvironment{I}[•]{•}{•}R
neweo \newenvironment{I}[•]{•}{•}R
nenv \newenvironment{I}{•}{•}R
newe \newenvironment{I}{•}{•}R
newlen \newlength{I}R
nlen \newlength{I}R
newlin \newlineR
nline \newlineR
newpg \newpageR
npg \npg \newpageR
\newtheorem{I}[•]{•}R
\newtheorem{I}{•}R
\newtheorem{I}{•}[•]R
\nocite{I}
\normalsize
\pagebreakR
pgref \pageref{I}
pgs \pagestyle{I}R
pars \paragraph*{I}R
paro \paragraph[I]{•}R
par \paragraph{I}R
parboxo \parbox[I]{•}{•}
pboxo \pboxo \parbox[I]{•}{•}
parbox \parbox{I}{•}
pbox \pbox \parbox{I}{•}
rboxoo \rboxoo \raisebox{I}[•][•]{•}
rboxo \rboxo \raisebox{I}[•]{•}
rbox \rbox \raisebox{I}{•}
ref \ref{I}
rncmoo \renewcommand{I}[•][•]{•}R
rnewcoo \renewcommand{I}[•][•]{•}R
rncmo \renewcommand{I}[•]{•}R
rnewco \renewcommand{I}[•]{•}R
rncm \renewcommand{I}{•}R
rnewc \renewcommand{I}{•}R
rmc \rmfamily
\rule[I]{•}{•}
\rule{I}{•}
A. Customizing TEXworks 52
scd \scshape
secs \section*{I}R
seco \section[I]{•}R
sec \section{I}R
\setlength{I}{•}
hw2tw \setlength{\headwidth}{\textwidth}R
sfd \sffamily
sld \slshape
sqrto \sqrto \sqrt[I]{•}
sqrt \sqrt \sqrt{I}
stcount \stepcounter{I}R
spars \spars \subparagraph*{I}
sparo \sparo \subparagraph[I]{•}
spar \spar \subparagraph{I}
ssecs \ssecs \subsection*{I}R
sseco \sseco \subsection[I]{•}R
ssec \ssec \subsection{I}R
sssecs \sssecs \subsubsection*{I}R
\ssseco \subsubsection[I][•]R
ssseco \subsubsection[I]{•}R
sssec \sssec \subsubsection{I}R
tableof- \tableofcontentsR
contents
toc \toc \tableofcontentsR
tilde \tilde \textasciitilde
bf \bf \textbf{I}
— \textemdash\
– \textendash\
it \it \textit{I}
\rm \textrm{I}
sc \sc \textsc{I}
sf \sf \textsf{I}
sl \sl \textsl{I}
tt \tt \texttt{I}
up \up \textup{I}
tw \tw \textwidth
\text{I}
\thanks{I}R
\title{I}R
ttd \ttfamily
upd \upshape
A. Customizing TEXworks 53
url \url{I}
usepo \usepackage[I]{•}R
usep \usepackage{I}R
\vdots
\vspace*{I}R
\vspace{I}R
{abstract}RIR\end{abstract}•
{align*}RIR\end{align*}•
{alignat*}{I}R•R\end{alignat*}•
{alignat}{I}R•R\end{alignat}•
{alignedat}{I}R•R\end{alignedat}•
{aligned}RIR\end{aligned}•
{aligned}[I]R•R\end{aligned}•
{align}RIR\end{align}•
{appendix}RIR\end{appendix}•
{array}RIR\end{array}•
{bmatrix}RIR\end{bmatrix}•
{cases}RIR\end{cases}•
{center}RIR\end{center}•
{compactenum}R\itemRIR\end{compactenum}•
{compactenum}[I]R\itemR•R\end{compactenum}•
{compactitem}R\itemRIR\end{compactitem}•
{compactitem}[I]R\itemR•R\end{compactitem}•
{description}R\item[I]R•R\end{description}•
{document}RRIRR\end{document}
{enumerate}R\itemRIR\end{enumerate}•
{enumerate}[I]R\itemR•R\end{enumerate}•
{eqnarray*}RIR\end{eqnarray*}•
{eqnarray}RIR\end{eqnarray}•
{equation}RIR\end{equation}•
{figure}RIR\end{figure}•
{figure}[I]R•R\end{figure}•
{flalign*}RIR\end{flalign*}•
{flalign}RIR\end{flalign}•
{flushleft}RIR\end{flushleft}•
{flushright}RIR\end{flushright}•
{gather*}RIR\end{gather*}•
{gathered}RIR\end{gathered}•
{gathered}[I]R•R\end{gathered}•
{gather}RIR\end{gather}•
{itemize}R\itemRIR\end{itemize}•
A. Customizing TEXworks 54
{itemize}[I]R\itemR•R\end{itemize}•
{letter}{I}R•R\end{letter}•
{list}{I}{•}R\itemR•R\end{list}•
{minipage}[I]{•}R•R\end{minipage}•
{minipage}{I}R•R\end{minipage}•
{multline*}RIR\end{multline*}•
{multline}RIR\end{multline}•
{picture}RIR\end{picture}•
{pmatrix}RIR\end{pmatrix}•
{quotation}RIR\end{quotation}•
{quote}RIR\end{quote}•
{split}RIR\end{split}•
{subequations}RIR\end{subequations}•
{tabbing}RIR\end{tabbing}•
{table*}RIR\end{table*}•
{table*}[I]R•R\end{table*}•
{table}RIR\end{table}•
{table}[I]R•R\end{table}•
{tabular*}{I}{•}R•R\end{tabular*}•
{tabularx}{I}{•}R•R\end{tabularx}•
{tabular}{I}R•R\end{tabular}•
{thebibliography}RIR\end{thebibliography}•
{theindex}RIR\end{theindex}•
{theorem}RIR\end{theorem}•
{titlepage}RIR\end{titlepage}•
{trivlist}RIR\end{trivlist}•
{varwidth}{I}R•R\end{varwidth}•
{verbatim}RIR\end{verbatim}•
{verse}RIR\end{verse}•
\addbibresource{I}R
botr \bottomruleR
\citep{I}
\citet{I}
cmidr \cmidrule(I){•}
cmidro \cmidrule[I](•){•}
\enquote{I}
geometry \geometry{•}
href \href{I}{•}
A. Customizing TEXworks 55
\midruleR
\printbibliographyR
\printbibliography[I]R
topr \topruleR
{compactenum}R\itemRIR\end{compactenum}•
{compactenum}[I]R\itemR•R\end{compactenum}•
{compactitem}R\itemRIR\end{compactitem}•
{compactitem}[I]R\itemR•R\end{compactitem}•
{tikzpicture}RIR\end{tikzpicture}•
{tikzpicture}[I]R•R\end{tikzpicture}•
\action<I>{•}
\againframe<I>[•]{•}R
\againframe<I>{•}R
\againframe{I}R
\alert<I>{•}
\alert{I}
\alt<I>{•}{•}
bfrm \begin{frame}RIR\end{frame}•
\framesubtitle<I>{•}R
\framesubtitle{I}R
\frametitle<I>[•]{•}R
\frametitle{I}R
\framezoom<I><•>(•,•)(•,•)
\framezoom<I><•>[•](•,•)(•,•)
\includeonlyframes{I}R
\includeonlylecture{I}R
\invisible<I>{•}
\lecture{I}{•}R
\note<I>[•]{•}R
\note<I>{•}R
\note{I}R
\only<I>{•}
\onslide<I>{•}
\pauseR
\pause[I]R
\structure{I}R
\temporal<I>{•}{•}{•}
\uncover<I>{•}
A. Customizing TEXworks 56
\usebeamercolor{I}R
\visible<I>{•}
{actionenv}<I>RR\end{actionenv}•
{alertenv}<I>RR\end{alertenv}•
{altenv}<I>{•}{•}{•}{•}RR\end{altenv}•
{beamercolorbox}[I]{•}RR\end{beamercolorbox}•
{beamercolorbox}{I}RR\end{beamercolorbox}•
{block}<I>{•}RR\end{block}•
{block}{I}RR\end{block}•
{columns}RIR\end{columns}•
{columns}[I]R•R\end{columns}•
{column}[I]{•}RR\end{column}•
{column}{I}RR\end{column}•
{frame}RIR\end{frame}•
{frame}[I]{•}RR\end{frame}•
{frame}{I}RR\end{frame}•
{onlyenv}<I>RR\end{onlyenv}•
{overlayarea}{I}{•}RR\end{overlayarea}•
{overprint}RIR\end{overprint}•
{structureenv}RIR\end{structureenv}•
\starttext
\stoptext
There are also environment codes (above) without \begin{ (which is itself
a keyword); this allows to finish the environment name alone by if one
started to input it manually.
Regular expressions
B
As TEXworks is built on Qt4, the available regular expressions—which are
often referred to as regexp—are a subset of those found in Qt4. See the site
of Qt41 for more information. It is possible to find other information about
regexps on the net2 or from books. But pay attention that not all systems
(programming languages, editors, . . . ) use the same set of instructions; there
is no “standard set”, unfortunately.
B.1 Introduction
When searching and replacing, one has to define the text to be found. This
can be the text itself (e.g., “Abracadabra”), but often it is necessary to define
the strings in a more generic and powerful way to avoid repeating the same
operation many times with only small changes from one time to the next; if,
for example, one wants to replace sequences of the letter a by ones of the
letter o, but only those sequences of 3, 4, 5, 6 or 7 a; this would require
repeating (and slightly adjusting) the find and replace procedure 5 times.
Another example: replace all vowels by §—again, this would take 5 replace
operations. Here come the regular expressions!
A simple character (a or 9) represents itself. But a set of characters can
be defined: [aeiou] will match any vowel, [abcdef] the letters a, b, c, d, e,
and f ; this last set can be shortened as [a-f] using “-” between the two ends
of the range. This can even be combined: [a-zA-Z0-9] will match all letters
and all numbers.
1
http://doc.trolltech.com/4.4/qregexp.html#details—this section is based on the
information provided there
2
see, for example, Wikipedia
57
B. Regular expressions 58
To define a complementary set3 , one uses “ˆ”: the caret negates the
character set if it occurs at the beginning, i.e., immediately after the opening
square bracket. [ˆabc] matches anything except a, b, c.
Element Meaning
c Any character represents itself unless it has a special regexp
meaning. Thus c matches the character c.
\c A special character that follows a backslash matches the char-
acter itself except where mentioned below. For example, if you
wished to match a literal caret at the beginning of a string you
would write “\^”.
\n This matches the ASCII line feed character (LF, Unix newline,
used in TEXworks).
\r This matches the ASCII carriage return character (CR).
\t This matches the ASCII horizontal tab character (HT).
\v This matches the ASCII vertical tab character (VT; almost
never used).
\xhhhh This matches the Unicode character corresponding to the hex-
adecimal number hhhh (between 0x0000 and 0xFFFF). \0ooo
(i.e., zero-ooo) matches the ASCII/Latin-1 character correspond-
ing to the octal number ooo (between 0 and 0377).
. (dot) This matches any character (including newline). So if you want
to match the dot character iteself, you have to escape it with
“\.”.
\d This matches a digit.
\D This matches a non-digit.
\s This matches a white space.
\S This matches a non-white space.
\w This matches a word character or “_”).
\W This matches a non-word character.
\1, . . . The n-th back-reference, e.g. \1, \2, etc.; used in the replace-
ment string with capturing patterns—see below
Using these abbreviations is better than describing the set, because the
abbreviations remain valid in different alphabets.
Pay attention that the end of line is often taken as a white space. Under
TEXworks the end of line is referred to by “\n”.
B.3 Repetition
One doesn’t work only on single letters, digits, symbols; most of the time,
these are repeated (e.g., a number is a repetition of digits and symbols—in
the right order).
B. Regular expressions 60
specify that apple should be standalone, a whole word (as is often called in
the search dialog boxes).
To specify that a string should be considered standalone, we specify
that it is surrounded by word separators/boundaries (begin/end of sentence,
space), like \bapple\b. For our alternatives example we will group them
by parentheses and add the boundaries \b(apple|pear|cherry)\b. Apart
from \b we have already seen ˆ and $ which mark the boundaries of the
whole string.
Here a table of the “assertions” which do not correspond to actual charac-
ters and will never be part of the result of a search. 6
^ The caret signifies the beginning of the string. If you wish to
match a literal ˆ, you must escape it by writing \^
$ The dollar signifies the end of the string. If you wish to match
a literal $, you must escape it by writing \$
\b A word boundary.
\B A non-word boundary. This assertion is true wherever \b is
false.
(?=E) Positive lookahead. This assertion is true if the expression E
matches at this point.
(?!E) Negative lookahead. This assertion is true if the expression E
does not match at this point.
Notice the different meanings of ˆ as assertion and as negation inside a
character set!
6
simplified from Qt4 at trolltech, see note 1
Compiling TEXworks
C
A complete guide how to compile TEXworks is far beyond the scope of this
manual. However, most users should find precompiled versions suitable for
their system come either with their TEX distribution or their operating system.
If this is not the case, several precompiled versions can also be downloaded
from http://www.tug.org/texworks/.
Compiling TEXworks yourself is only necessary if your system is not (yet)
supported, if you want to always have the latest features (and bugs), or
generally want to help in improving TEXworks further. To this end, there are
some documents giving detailed instructions to compile TEXworks on different
machines.
https://github.com/TeXworks/texworks/wiki/Building
https://github.com/TeXworks/texworks/wiki/Building-on-Mac-
OS-X-(Homebrew)
https://github.com/TeXworks/texworks/wiki/Building-on-
Windows-(MinGW)
62
Acknowledgements
63
Bibliography
64
Index
% !TeX texworks-config.txt, 29
encoding, 26 texworks-setup.ini, 29
program, 26 texworks.ini, 29
root, 17 console bar, 13
spellcheck, 27 CTAN, 11
Ctrl+’, 11
actions Ctrl+T, 10
alphabetically, 41
by menu, 42 document
auto-completion, 22 creation, 10
roots, 44 previewing, 10
tw-basic.txt, 45 source, 2
tw-beamer.txt, 55 typesetting, 10
tw-context.txt, 56
tw-latex-pkg.txt, 54 editing
tw-latex.txt, 47 change case, 21
comment, 21
cleaning folder, 28 indentation, 27
aux files, 29 line numbers, 21
comments, 11 redo, 21
compiling TEXworks, 62 search/replace, 18
completion, see auto-completion select a block, 22
configuration, 29 tools, 21
defaultbinpaths, 30 uncomment, 21
inipath, 29 undo, 21
libpath, 29 editor, 2
65
Index 66
font, 15 hide, 14
encoding, 26
latin1, 25 packages, 1, 11
utf-8, 11, 25 PDF, 2
errors, 12 Portable Usage, 29
extension .tex, 10 PostScript, 2
preamble, 11
files preferences, 15
format, 1 preview, 8
folder preview window, 10
hresourcesi, 7 programme
.TeXworks, 7 default, 26
.config/TUG, 7 project, 16
auto-completion, 6
configuration, 6 regular expressions, 19, 57
dictionaries, 6 alternatives/assertions, 60
resource, 6 introduction, 57
resource Mac, 7 repetition, 59
templates, 6 sets, 58
TeXworks, 6
scripts, 31
translations, 6
installing, 32
installation, 5 managing, 33
Linux, 6 using, 33
Mac, 7 writing, 31
Portable Usage, 29 search/replace, see editing
Windows, 6 shortcuts, see keyboard shortcuts
interface, 8 source/editor, 8
spell-checking, 17
Kew, Jonathan, 3 .aff files, 18
keyboard shortcuts, 38 .dic files, 18
actions, 38 SyncTeX, 25
predefined, 39 syntax highlighting, 36
shortcuts.ini, 38
Knuth, Donald E., 1 tags, 28
structure, 28
Lamport, Leslie, 1 table of contents, 28
log, 10 template, 16
METAFONT, 1 TEX, 1
METAPOST, 2 AMS-TEX, 1
ConTEXt, 1
output panel, 10 LATEX, 1, 9
Index 67
zoom, 28