« The TransistorIntro to KCL and KVL »

Intro to Latex.

02/03/10

Intro to Latex.

Permalink 10:36:17 pm by anthony, Categories: Informative

I know this isn't exactly related to circuitry, but i figured I'd do a quick little writeup on . If you haven't noticed already, throughout this blog i use mathematical formula to describe the phenomena which i happen to be writing about. I use a cgi script to generate the formula into a JPEG from the Latex(Pronounced La-Tek)typesetting commands.

Typesetting vs WYSIWYG:

When you create a document you have two choices, you can use a program like Microsoft Word and how you type the document and format it on the screen is how it comes out (WYSIWYG) or you can use a language like HTML where you use tags to get desired formatting (a Typesetting language)

:

Latex is a typesetting program which is widely used in the physics and engineering community, it uses pre-formatted packages to adhere your document to certain guidelines but also allows you to customize every setting. Instead of trying to explain what Latex is, i am just going to provide a sample document in which i used Latex to make.

Sample Lab Document

Here is the .tex document that we will be referencing through out the post.

Sample tex document

As you can see, Latex makes good looking documents, fairly quickly. Latex has a whole host of useful typesetting features for mathematical formula, Greek letters, operators, figures, symbols and operations. It is a very powerful tool which will help you in any situation where you need to make a professional looking document. How it works: Texmaker is what i use to write my Latex documents, however a basic text editor is all you need. After you write your tex file (with .tex extension) you use Latex to "compile" it into a .dvi, .ps or .pdf format. Just like with any program any syntax errors will result in a compile error. So lets get into the code.

The Preamble:

The preamble of the latex document sets up the basic guidelines the document will follow. i.e. the author information, the font packages to use, other misc packages to use and the document type.

\documentclass[10pt,a4paper,titlepage]{article}
\usepackage[latin1]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{color}
\usepackage{graphicx}
\usepackage{epsfig}
\author{Anthony Tricarichi:106718074}
\title{Lab 09: Radioactive Decay}
begin{document}
\maketitle

In Latex we precede each command by \. Document class tells Latex what font to use, the type and other document settings. Usepackage tell latex what packages to use (use the ones i use as default). Author sets the author information for the document, Title sets the title. Like HTML uses tags, latex has something similar.

Environments:

Latex uses environments to guide the flow of a document. When in an environment Latex follows certain formatting guidelines. We start our document with the document environment, we enter an environment with \begin and exit it with \end In the document environment we denote section with \section{} and subsections with \subsection{}

Tabular Environment:

To create tables in Latex we use the tabular environment.

\begin{tabular}{|l|l|l|l|}
\hline
Column 1& Column 2 & Column 3 & Column 4 \\
\hline
\end{tabular}

We enter a tabular environment with \being{tabular} it accepts a parameter which tells latex how many columns the table will have {|l|l|l|l|} | denotes a horizontal line and l denotes left-justified. r,c,l are all valid parameters. \hline denotes a horizontal line, & denotes a column break and \\ is a new line. That makes the following table.

Math environments: One of latex's most powerful features is it ability to create very elegant and professional math equations. There are several ways to enter math mode in latex. If you want to use math environment tags in your regular document you can temporarily use $ to enter math mode and then another $ to terminate it. A more permanent environment is the equation array environment. It is very similar to the equation environment but allows you to align your equations like a tabular environment.

Math commands:

In math mode, you have access to commands that let you build your equations. +,-,/, and * all have their own symbols and formatting.

^{} is for superscript

_{} is for subscript

\frac{a}{b} is for fractions of the form

There are many more commands which i will outline at the end of the document.

\begin{eqnarray}
P_{abs} &=& P_{atm} + \rho gh \\ \nonumber
&=& 1.01*10^5 + 10*1000*.2 \\ \nonumber
&=& 103000 Pa \\ \nonumber
m_{slope} &=& \frac{\Delta x}  {\Delta y} \\ \nonumber
&=& \frac{0-100}{91807-129549} \\ \nonumber
&=& 377.42 \\ \nonumber
Percent Error &=& \frac{Experimental - Actual}{Actual} * 100 \\ \nonumber
&=& \frac{-243 - -273}{-273} * 100 \\ \nonumber
&=& 10\% \\ \nonumber
\end{eqnarray}

Generates the following -

End note and other commands:

Latex is a fairly simple typesetting language, if you take a look at my sample .tex document you should have all you need to make a Latex document.  This has only been a crash course into latex, more in-depth support on the working of Latex can be found almost anywhere on the internet.

COMMANDS!

\\ - Line break

\footnote{}

\(insert greek letter name) - Insert a greek letter

 

No feedback yet

Leave a comment


Your email address will not be revealed on this site.

Your URL will be displayed.
(Line breaks become <br />)
(Name, email & website)
(Allow users to contact you through a message form (your email will not be revealed.)
This is a captcha-picture. It is used to prevent mass-access by robots.

Please enter the characters from the image above. (case insensitive)

Array
February 2012
Sun Mon Tue Wed Thu Fri Sat
 << <   > >>
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      

Ads By Google

This blog is an extension of Microcontrollers and You! This blog focuses more on the hardware part of design rather than software. This blog will be covering topics such as analog hardware, digital hardware,schematic and printed circuit board design and tons of other things. Topics may overlap for convenience sake.

Search

XML Feeds

powered by b2evolution free blog software