LaTeX Basics

Forum rules
Share your brain ;)
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

LaTeX Basics

Unread post by machinebacon » Thu Jun 26, 2014 11:28 pm

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 ;)
..gnutella..

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: LaTeX Basics

Unread post by GekkoP » Fri Jun 27, 2014 9:40 am

It is really useful. I'll do some tests today. Thanks.

User avatar
z3bra
Window Manager
Posts: 53
Joined: Fri Jun 27, 2014 8:34 am
Location: France
Contact:

Re: LaTeX Basics

Unread post by z3bra » Fri Jun 27, 2014 11:16 am

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
Last edited by z3bra on Fri Jun 27, 2014 11:34 am, edited 1 time in total.
BANGARANG, MOTHERFUCKER.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: LaTeX Basics

Unread post by machinebacon » Fri Jun 27, 2014 11:19 am

Excellent, thanks Zeb!
..gnutella..

User avatar
ivanovnegro
Minister of Truth
Posts: 5448
Joined: Wed Oct 17, 2012 11:12 pm

Re: LaTeX Basics

Unread post by ivanovnegro » Fri Jun 27, 2014 2:10 pm

Fantastic Bacon.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: LaTeX Basics

Unread post by machinebacon » Thu Aug 28, 2014 7:00 pm

Very cool - if you need a certain symbol in your LaTeX file, go here: http://detexify.kirelabs.org/classify.html
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: LaTeX Basics

Unread post by rhowaldt » Thu Aug 28, 2014 7:55 pm

^ 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.
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: LaTeX Basics

Unread post by dkeg » Thu Aug 28, 2014 9:10 pm

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.

Work hard; Complain less

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: LaTeX Basics

Unread post by rhowaldt » Thu Aug 28, 2014 9:30 pm

^ 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.
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: LaTeX Basics

Unread post by machinebacon » Thu Aug 28, 2014 9:33 pm

WYSIWYG? apt-get install gummi (or lyx)
..gnutella..

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: LaTeX Basics

Unread post by rhowaldt » Thu Aug 28, 2014 9:53 pm

^ will check it out, thanks brother :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: LaTeX Basics

Unread post by dkeg » Thu Aug 28, 2014 10:07 pm

I used and liked gummi. This also looks useful https://www.writelatex.com/

Work hard; Complain less

User avatar
linuxbbq
Oyster-Slurper
Posts: 27
Joined: Thu Aug 28, 2014 10:03 am

Re: LaTeX Basics

Unread post by linuxbbq » Fri Aug 29, 2014 5:41 am

Congratulations @dkeg - you cracked the 2000th post!
Trailing whitespace? Give me a fucking break, and save me from "experts" and "C-language lawyers."

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: LaTeX Basics

Unread post by rhowaldt » Fri Aug 29, 2014 8:24 am

yeah dkeg! well done with the posting!
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: LaTeX Basics

Unread post by machinebacon » Fri Aug 29, 2014 9:39 am

rhosey passed the quarter ten thousand ;) congrats, by the way! ;)
..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: LaTeX Basics

Unread post by dkeg » Fri Aug 29, 2014 11:34 am

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...'

Work hard; Complain less

machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

Re: LaTeX Basics

Unread post by machinebacon » Fri Aug 29, 2014 12:05 pm

..gnutella..

User avatar
dkeg
Configurator
Posts: 3782
Joined: Sun Nov 18, 2012 9:23 pm
Location: Mid-Atlantic Grill

Re: LaTeX Basics

Unread post by dkeg » Fri Aug 29, 2014 1:40 pm

You're the bestest!

Work hard; Complain less

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: LaTeX Basics

Unread post by GekkoP » Fri Aug 29, 2014 1:42 pm

Very useful tool there for get the symbols right, thanks for sharing.

User avatar
GekkoP
Emacs Sancho Panza
Posts: 5877
Joined: Tue Sep 03, 2013 7:05 am

Re: LaTeX Basics

Unread post by GekkoP » Mon Sep 01, 2014 11:57 am

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.

Post Reply