About
Shop
LaTeX
Software
Books
Gallery
News
Contact
Blog
Settings
Account
Latest news 2024-10-15: New blog post: Tales for Our Times Book Launch.


3.1 TeXWorks

Hopefully you've managed to successfully install TeX and TeXWorks as described in the previous section, so let's test it out.

First run TeXWorks. On Windows, you can access it via the Start menu. On GNU/Linux, it's probably located in ApplicationsOffice, or you can type texworks in a terminal. You should now see the TeXWorks window. The button marked with a grey triangle in a green circle is the build or typeset function. It runs the application in the drop-down list next to it. This is set to pdfLaTeX, which is what we want for now.

It's a good idea to switch on the syntax highlighting, if it isn't already on. This is done via the FormatSyntax Coloring sub-menu. Make sure the LaTeX item is selected.

Next, type in the following sample source code, as shown in Figure 3.1 (the commands used here will be described in more detail in §4. Creating a Simple Document):

\documentclass{scrartcl}

\begin{document}

This is an example document.

\end{document}

Pay close attention to the backslashes at the start of each command name. If you find the font is a bit too small for you, you can make it larger using the FormatFont menu item. This doesn't affect the font size in your PDF file, just the font size of your code. This displays the “Select Font” dialog box. Set the font size as appropriate.

Then save the document, using the FileSave As menu item. I called my document example1.tex (remember the .tex extension and stick to file names that only consist of alphabetical characters, digits and hyphens—don't uses spaces or underscores).

Figure 3.1: Source Code for an Example Document. (Syntax highlighting switched on.)
 

Now that you have saved the file, you can run pdfLaTeX. Make sure the drop-down list next to the build button has “pdfLaTeX” selected and click on the build button. If all goes well, a new window should open displaying the typeset document (Figure 3.2).

Figure 3.2: The Typeset Document
 

Figure 3.3: The Source Code Has a Misspelt Command
 

Now let's see what happens if there is an error in the source code. In Figure 3.3 I have misspelt the \documentclass command. This time, when I click on the build button, I get the error message:

! Undefined control sequence.
l.1 \documentclas
                 {scrartcl}
?
(Shown in Figure 3.4.)

Figure 3.4: An Error Message is Displayed
 

Here “Undefined control sequence” means an unrecognised command, and below that message, “l.1” means the error was encountered on line 1. An input line at the bottom of the window has appeared with a cursor. LaTeX is in interactive mode and is awaiting a response. There are several responses, but I'm only going to mention two of them:

  1. Type h and press the Return/Enter key return key symbol. This displays a short help message and awaits a new response (see Figure 3.5).

  2. Type x and press Return/Enter. This aborts the LaTeX run.

Notice that the green circle button with the grey triangle has turned into a red stop button. This button can be used to abort the process instead of typing x.

Figure 3.5: A Short Help Message
 

Now, there is a second tab at the bottom of the TeXWork's window (Figure 3.6). This lists the error message and provides a link to the line where the error occurred. Clicking on this link highlights line 1. Next I need to fix the error by correcting the spelling of the command. Once it's fixed, I can click on the build button.

Figure 3.6: Error Tab
 

Here's another error you might encounter: I'm now going to misspell the class name. It should be scrartcl, but in Figure 3.7 it has been misspelt. This time, when I click on the build button, I get the error:

! LaTeX Error: File `scrartc.cls' not found.
I have two choices: type in the correct name on the line below “Enter file name:” or I can abort the process using the red abort button. In either case I need to go back and fix the error in my code.

Figure 3.7: Misspelt Class File
 


This book is also available as A4 PDF or 12.8cm x 9.6cm PDF or paperback (ISBN 978-1-909440-00-5).

© 2012 Dickimaw Books. "Dickimaw", "Dickimaw Books" and the Dickimaw parrot logo are trademarks. The Dickimaw parrot was painted by Magdalene Pritchett.

Terms of Use Privacy Policy Cookies Site Map FAQs