0% found this document useful (0 votes)
6 views6 pages

Latex Example program

The document provides examples of LaTeX code for creating various types of documents, including articles and tables. It explains the use of document classes, commands for formatting text, and mathematical expressions. Additionally, it highlights the importance of the document preamble and the structure of LaTeX documents.

Uploaded by

Khyathi Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Latex Example program

The document provides examples of LaTeX code for creating various types of documents, including articles and tables. It explains the use of document classes, commands for formatting text, and mathematical expressions. Additionally, it highlights the importance of the document preamble and the structure of LaTeX documents.

Uploaded by

Khyathi Kiran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Examples of Latex

Here an example of a very small Latex document

\documentclass{article}
\begin{document} example for a very \tiny{tiny} \normalsize \LaTeX \ document
\end{document}

A small Latex document

\documentclass[12pt,twoside,a4paper]{article}
\begin{document}
a small \LaTeX document
\end{document}

Class options

12pt Character size 12 points

twoside Reciprocally front and back

a4paper DIN A4 format

There are four standard documents letting.

 book
 report
 article
 letter (normally American format)

Each document use exactly one document class.


so

\documentclass{article} or \documentclass{report}
Not
\documentclass{article, report}

Tables in Latex
\documentclass[12pt,twoside,a4paper]{article}
\begin{document}
\begin{tabular}{|c|c|c|}
\hline
A & B & C \\
\hline
1 & 2 & 3 \\
\hline
4&5&6
\\
\hline
\end{tabular}
\end{document}

Still another table

\documentclass[12pt,twoside,a4paper]{article}
\begin{document}
\begin{tabular}{c|c|c}
A & B & C \\
\hline
1 & 2 & 3 \\
\hline
4 & 5 & 6 \\
\end{tabular}
\end{document}

A third table

\documentclass[12pt,twoside,a4paper]{article}
\begin{document}
\begin{tabular}{|c|c|c|l|r|}
\hline
\multicolumn{3}{|l|}{test} & A & B \\
\hline
1 & 2 & 3 & 4 & 5 \\
\hline
\end{tabular}
\end{document}
Something mathe with Latex

Are $a, b \in \mathbb{R}, then applies (a+b)^{2} = a^{2} + ab + b^{2} $ \\


better \\
are $a, b \in \mathbb{R}, \textrm{then apply} \, (a+b)^{2 } = a^{2 } + ab + b^{2}$\\

Here's a brief explanation of what some of the commands in the file above do:

\documentclass[12pt]{article}
This says to use 12pt type, which is a large readable size (10 and 11 are also used a lot). It
also specifies that the article style be used, which is what you will use for linguistics
papers.
\usepackage{lingmacros}
\usepackage{tree-dvips}
lingmacros and tree-dvips are style files that have been written by people to help you do
example sentences and draw trees.
\section*{Notes for My Paper}
This says to make a section heading consisting of what is between the curly brackets, and
the * says not to number it. Without the * you would get a numbered heading which would
increment with each following section heading.
\subsection*{How to handle topicalization}
This says to make a subsection heading, which is smaller sized than the section heading.
You can even do \subsubsection headings!
\enumsentence, \ex and \shortex{7}
These are control commands for numbering example sentences and giving examples with
glosses and translation lines. You separate each word by & in the \shortex environment,
and tell it the number of words you plan to enter (in curly brackets). \ex allows you to refer
to numbered examples with a number relative to the current point in the file (rather than
with an absolute number).
\begin{tabular}[t]{cccc}
This is how the tree was drawn.
\emph{Irrealis}
This says to make what is in curly brackets into italics. You can also do \textbf{Hi
There} to get bold Hi There and \textsc{Hi There} to get HI THERE.
\small
This makes the type size smaller. The braces delimit the range of text over which this
command has an effect.
\begin{document} and \end{document}
These must be put around the text of your paper.

% This is a simple sample document.

For more complicated documents take a look in the exercise tab.

Note that everything that comes after a % symbol is treated as comment and ignored when the
code is compiled.

\documentclass{article} % \documentclass{} is the first command in any LaTeX code. It is used


to define what kind of document you are creating such as an article or a book, and begins the
document preamble

\usepackage{amsmath} % \usepackage is a command that allows you to add functionality to your


LaTeX code

\title{Simple Sample} % Sets article title


\author{My Name} % Sets authors name
\date{\today} % Sets date for date compiled
% The preamble ends with the command \begin{document}
\begin{document} % All begin commands must be paired with an end command somewhere
\maketitle % creates title using information in preamble (title, author, date)

\section{Hello World!} % creates a section

\textbf{Hello World!} Today I am learning \LaTeX. %notice how the command will end at the first
non-alphabet charecter such as the . after \LaTeX
\LaTeX{} is a great program for writing math. I can write in line math such as $a^2+b^2=c^2$ %$
tells LaTexX to compile as math
. I can also give equations their own space:
\begin{equation} % Creates an equation environment and is compiled as math
\gamma^2+\theta^2=\omega^2
\end{equation}
If I do not leave any blank lines \LaTeX{} will continue this text without making it into a new
paragraph. Notice how there was no indentation in the text after equation (1).
Also notice how even though I hit enter after that sentence and here $\downarrow$
\LaTeX{} formats the sentence without any
break. Also look how it doesn't matter how many spaces I
put between my words.
For a new paragraph I can leave a blank space in my code.

\end{document} % This is the end of the document

You might also like