Get Started With Latex on Mac Easy

TeX is a wonderful and very versatile typesetting system that can be used to write almost anything – from reports to letters and even more complicated documents such as books and posters. This tutorial will show you the basics of TeX – how it works and how you can create a nice, simple document with very little effort.


You Can Do It!

What scares people away from TeX is its learning curve. It's not as simple as just opening up a word processor such as Pages or Microsoft Word and tapping away. With TeX, you have to learn the various commands before you can start creating documents. This may sound a bit scary, but TeX is a lot simpler to learn than other programming languages and once you've used it for a while you'll soon pick it up really easy.


What is TeX?

I think it would be prudent to first give you a brief introduction of TeX and why it's so popular within certain circles. Basically, it is a typesetting language that was designed and developed (mostly) by Donald Knuth, a professor at Stanford University, back in the 1970s. His aim with TeX was to create a system so that documents would look the same across all computers and that the look of the documents wouldn't diminish with time.

TeX is used heavily in the academic and scientific world, mostly due to the standardized layout and look of documents (though this can be changed), as well as the fact that TeX renders mathematical formulas extremely well (one of its fortes). If anyone has had to write a long formula in, say, the Equation Editor of Microsoft Word, then they will know how fiddly it is.

Before we get started with our first TeX document, there are a couple of things you need to install on your Mac first.


Getting Started

In order to be able to write TeX documents on your Mac, you'll first need to download and install a distribution, which renders your documents. There are quite a few TeX distributions out there that work with OS X, but my personal recommendation would be MacTeX, which is specifically written for the Mac and supports pretty much all OS X versions (including Mountain Lion).

You can download MacTeX directly here (direct download link – the file is approximately 2.1 GB in size) or via the Torrent network. Once you've installed it (it'll pop up in a dedicated TeX folder in your applications) then run the TeX Live Utility, which will update your TeX distribution to the latest version.

If you've installed all the available updates in the TeX Live Utility, then you should be presented with this screen. If you've installed all the available updates in the TeX Live Utility, then you should be presented with this screen. If you've installed all the available updates in the TeX Live Utility, then you should be presented with this screen.
If you've installed all the available updates in the TeX Live Utility, then you should be presented with this screen.

Just like HTML, you can write TeX is virtually any text editor or word processing package. However, I would recommend a specific TeX editor as you often get a handy list of tools with them (such as auto-complete and error reporting, which flags up any errors in your TeX coding before the document is rendered). With MacTeX, you get a couple of free solutions (TeXworks, which I will use for this tutorial, and TeXShop). There are also other options out there, such as TeXstudio and the commercial Texpad offering, which I reviewed last year on Mac AppStorm. You can also write TeX in commercial code editors such as Sublime Text with the relevant syntax, but you will need to open any documents up in a TeX editor so that they can be rendered. For beginners, I would recommend a dedicated TeX editor as it makes learning to write in TeX a lot easier!

Once you've installed everything, then it's time to create your first TeX document!


Your first TeX document

Tip: I have uploaded the tutorial document so you can download and play around with it. Click here to download the raw document (in .tex format) or here for a PDF example.

Every TeX document starts by defining the document class. This sets the layout and formatting of your document. There are loads of different classes to choose from, but for a standard document the article class is a good one to choose. Therefore, start by typing:

All TeX commands are preceded by a backslash (\) and defined within {curly brackets}. Unlike other programming languages, TeX commands usually are in plain English, so often it's clear what the command is meant to accomplish.

Starting the document

Now that we've defined the document class, it's time to start the document. Here, we type:

Of course, you have to tell TeX where your document ends and this is done by the command \end{document}. Are you starting to see that TeX really isn't that difficult? I usually type these commands at the same time, with four lines in between them. You don't have to, but I find it helps immensely. If you're following this example, then type:

All your TeX coding should lie in between these two commands.


Titles and Authors

Now that we've defined the document class and where the document starts and ends, we need to give our document a title and author. Type:

So far, your coding should look like the following:

First Shot First Shot First Shot

Tip: Syntax colouring can make it a lot easier to spot individual TeX commands and functions. Most TeX editors have it on as default – if you're using TexWorks, then click on Format > Syntax Coloring > LaTeX to activate it!

When you render this (by clicking on the little play button), then it should look like this:

First Shot Rendered First Shot Rendered First Shot Rendered

If the document fails to render, then check the coding against my example. If you haven't included the command \maketitle, for example, then the document won't render as it will simply be empty (the command \maketitle actually places the title in the document, whereas the command \title simply defines it for the document).

Abstracts

If you want to write a little abstract for your document (if you are writing a report or academic paper, for example), then type it in after the \maketitle command:

Sections and Subsections

Sections are defined by the command \section, with the section title again going in between two curly brackets, for example: \section{Introduction}. In our particular document class, article, sections are numbered (so the Introduction section would automatically be rendered as 1. Introduction). You can also create subsections (1.1, 1.2 and so on) and subsubsections (1.1.1, 1.1.2 and so on). The commands for these are \subsection{Subsection Title here} and subsubsection{Subsubsection Title here}.

All text for the individual sections goes straight underneath the section commands and unlike the abstract, you don't have to start every single one with the \begin and \end commands. For this tutorial, I'll create a couple of sample sections (the files above both contain some place filler text as well within each section) so you can see how they work:

Body Text and Formatting

If you're not using sections, then you can simply start writing your main body text after the \maketitle command. Make sure you insert an empty line between paragraphs so that TeX knows when to start a new paragraph.

TeX supports text in bold and in italics through the \textbf and \textit commands. Remember to encase the text you would like in either bold or italics between the two curly brackets. So:

TeX also includes three default fonts, which can be seen in the example below:

TeX Fonts TeX Fonts TeX Fonts

Use the command \textsf{ } for text in the Sans Serif font and \texttt{ } for text in the Typewriter font. The coding for the image above is as follows:

You can mix and match fonts within the same document without any problems – just make sure you watch out for the correct placement of the curly brackets (some TeX editors will do this for you automatically).

TeX also supports different font sizes through a variety of commands.

TeX Font Sizes TeX Font Sizes TeX Font Sizes

To create the document, I used the following:

Note the use of a curly bracket before the \ command and the two curly brackets at the end. If you only use one set of curly brackets (like with other TeX commands), the entire sentence will be in that particular font size.


Lists

Lists are relatively easy in TeX and there are three basic types.

An itemized list uses simply bullet points for your items:

An enumerated list uses the standard sequential numbering for your individual list items:

A descriptive list uses specific labels for each item of your list (for example, a, b and so on). TeX will not automatically generate the numbering and each label must lie within the [ ] as in the example below:

When rendered, this is how the three lists turn out:

TeX Lists TeX Lists TeX Lists


Finishing Up

And that's it for your first TeX document! Hopefully, this tutorial has provided you with enough information to start creating simple documents in TeX that look good. Given the sheer extent of TeX, we can't cover everything in this tutorial, but in later articles we'll have a look at more advanced features, such as mathematical formulas and working with images (which I purposely haven't touched upon in this tutorial as it is quite complicated).

Once again, please feel free to download and play around with the sample document for this tutorial (all the examples listed here are in it) as it's a good way to learn how to use TeX. Yes, it takes a bit of extra time to learn but the main reason to use TeX is that you get standardized and professional-looking documents which can be used in a wide variety of scenarios.

Did you find this post useful?

singerlegiring.blogspot.com

Source: https://computers.tutsplus.com/tutorials/the-beginners-guide-to-using-tex-in-os-x--mac-45177

0 Response to "Get Started With Latex on Mac Easy"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel