Page 1 of 2

LaTeX Basics

Posted: Thu Jun 26, 2014 11:28 pm
by machinebacon
LaTeX is a markup language, mostly used to prepare scientific documents, books, articles, and even presentations. One of the great benefits is that working with LaTeX is completely distraction-free. You just write and don't need to care about formatting. It can automatically create a table of content, bibliography, a list of references and sources, etc.

Another benefit is portability. You can use any editor in any operating system to prepare your document. The .tex files are comparably small, and you can create PDFs or PostScript files from them.

So, where to get our rubber suite?

Firstly, you need at least one package: texlive-base
You can grab a slightly bigger one with: texlive-latex-base
For Emacs users, there is an excellent environment called: whizzytex
You can also add: auctex

Of course, if you plan to work with mathematical formula, or with certain languages, you need to grad suitable packages that can display what you want: apt-cache search texlive|more

A simple document to start with

Fire up your editor of choice and create a file with .tex extension.
We first need to define what type of document we want to create, and we can also set up the font size we want to use throughout the document:

Code: Select all

\documentclass[12pt,a4paper]{article}
Of course there are some other document classes you can use: book, thesis, beamer -- depending on which packages you have installed. "article" is a very common one.

Let's also add some meta information, like the title and the author of our document, along with a date.

Code: Select all

\title{My First Encounter With BDSM}
\author{Larry Satenstein}
\date{\today}
\keywords{BDSM, Slave, Whipping, Banana}
As you can see, the date will always be updated to the day you actually process the document. This block can be before or after the \documentclass line.

The following tells LaTeX where the actual document begins, and where it ends.

Code: Select all

\begin{document}

\end{document}
Everything related to the content of the document will be placed between these two lines. For example:

Code: Select all

\begin{document}

\maketitle

\begin{abstract}
The abstract begins here.
This new line has no line break. 
If we want a line break, we place two backslashes at the end of the line.\\Yeah.
\end{abstract}

\section{Introduction}
This is the introduction. All sections will be enumerated automatically.

\begin{itemize}
\item \emph{Some item in italics.}
\item And a regular one
\end{itemize}

\paragraph{Outline}
And a paragraph.

\bibliography{main}

\end{document}
The good Emacs users can now run M-x whizzytex-mode and see a live preview of what they produced. Those who are afraid of wacky key sequences can try lyx or gummi as WYSIWYG editors. :) Yes, vim has a latexsuite, too!

To create a PDF from this .tex file run:

Code: Select all

pdflatex file.tex
Of course this is really just a very very basic example of a .tex file. Good references are:

- http://en.wikibooks.org/wiki/LaTeX/Document_Structure
- http://texblog.org/tex-resources/
- http://texblog.org/code-snippets/
- http://www.emacswiki.org/emacs/LaTeX


Hope you find it useful ;)

Re: LaTeX Basics

Posted: Fri Jun 27, 2014 9:40 am
by GekkoP
It is really useful. I'll do some tests today. Thanks.

Re: LaTeX Basics

Posted: Fri Jun 27, 2014 11:16 am
by z3bra
That's nice. A clean and simple starter guide !

As a complement, I wrote something about using Makefile to compile LaTeX document. Though I'd share.
Here is the link: Love me some Latex

Re: LaTeX Basics

Posted: Fri Jun 27, 2014 11:19 am
by machinebacon
Excellent, thanks Zeb!

Re: LaTeX Basics

Posted: Fri Jun 27, 2014 2:10 pm
by ivanovnegro
Fantastic Bacon.

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 7:00 pm
by machinebacon
Very cool - if you need a certain symbol in your LaTeX file, go here: http://detexify.kirelabs.org/classify.html

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 7:55 pm
by rhowaldt
^ wow, that is impressive.

EDIT: just been reading through the Latex documentation and the first post here (which i never consciously read because this shit is new to me), and it is really good shit. thanks for that. i will consider using this stuff somewhere in the future.

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 9:10 pm
by dkeg
Agreed. And rho, when i used LaTeX in school for papers it was wierd af first but once you get the hang of it, was much simpler. An no more fighting with formatting and ToC BS. Once you have some nice templates, all you have to be concerned with is the actual content. Well shit, now imagine that.

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 9:30 pm
by rhowaldt
^ ja, that sounds really good. the syntax seems quite logical to me as well. the only thing i am concerned about now is how to get a proper WYSIWYG setup, because i will want to see wtf it looks like in the end. emacs seems the best option for that, but i am quite hesitant to tackle that. will check out the other options Jules mentioned.

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 9:33 pm
by machinebacon
WYSIWYG? apt-get install gummi (or lyx)

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 9:53 pm
by rhowaldt
^ will check it out, thanks brother :)

Re: LaTeX Basics

Posted: Thu Aug 28, 2014 10:07 pm
by dkeg
I used and liked gummi. This also looks useful https://www.writelatex.com/

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 5:41 am
by linuxbbq
Congratulations @dkeg - you cracked the 2000th post!

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 8:24 am
by rhowaldt
yeah dkeg! well done with the posting!

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 9:39 am
by machinebacon
rhosey passed the quarter ten thousand ;) congrats, by the way! ;)

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 11:34 am
by dkeg
linuxbbq wrote:Congratulations @dkeg - you cracked the 2000th post!
rhowaldt wrote:yeah dkeg! well done with the posting!
why thank you!
I slowly and methodically had clicked on the submit button, half wondering if there would be some html5 confetti to rain down on the screen. Alas, my old friend was there, rock solid as always, in a calm and tempered voice, 'This message has been posted successfully...'

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 12:05 pm
by machinebacon

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 1:40 pm
by dkeg
You're the bestest!

Re: LaTeX Basics

Posted: Fri Aug 29, 2014 1:42 pm
by GekkoP
Very useful tool there for get the symbols right, thanks for sharing.

Re: LaTeX Basics

Posted: Mon Sep 01, 2014 11:57 am
by GekkoP
Quick update from a LaTeX newbie: it is just awesome. It's taking me some time to get used to, but creating PDFs through LaTeX makes me forget the old 'export to pdf from LibreOffice' days.