Nicolás Brailovsky


A modern blog

LaTeX: format basics

author Posted by: nico on date Jun 22nd, 2009 | filed Filed under: LaTeX

Basic structure

tex So, what’s the most basic structural elements for any document you write? Paragraphs, of course. I ussualy use LyX for writing paragraph-based documents (i.e. most of them) and presentations don’t have many, so perhaps this is the structural element I use the least. Oh, wait, there’s no element, just a “\n\n”. Point for LaTeX (take that, HTML).

You’ll also need to put titles, sections, subtitles and all that stuff to give your document a nice structure. Well, that’s easy too, just use

  • \section{name}
  • \subsection{name}
  • \subsubsection{name}

Easy, right? Check the example at the end of the post. There are some other commands you’ll use in any LaTeX document:

  • Footnotes
    1. \footnote{ Footnote text }

    Just write your text, it’ll be there when you compile the document

  • Vertical skip
    1. \bigskip

    Because, some times, LaTeX default formatting won’t be enough.

  • Align text Center:
    1. \begin{center}TEXT\end{center}

    Right:

    1. \begin{flushright}TEXT\end{flushright}

    Again, some times you may need it. Not too often, though.

You should now be able to write your first LaTeX document, starting from a template (always start with a template… it’s easier). I’m attaching to this post an example document in LyX, LaTeX and its compiled pdf, in case you’re wondering what does it look like in the end. For the next entry: some “advanced” tips and tricks, now let’s see an example LaTeX document:

  1. \documentstyle[11pt]{article}
  2. \title{LaTeX Example}
  3. \author{Nicol\’as Brailovsky}
  4. \setlength{\topmargin}{-.5in}
  5. \setlength{\oddsidemargin}{.125in}
  6. \setlength{\textwidth}{6.25in}
  7.  
  8. \begin{document}
  9.  
  10. \maketitle
  11. This is just a LaTeX kick off, with some basic commands.
  12.  
  13. \section {Section one}
  14. For example, this is a paragraph.
  15. \begin{quotation}
  16. { \em Lorem ipsum dolor sit amet, consectetur adipiscing elit.}
  17. Donec porta, enim eget tempus tempor, eros sem dapibus diam, vitae lacinia mauris metus id nulla.
  18. \end{quotation}
  19.  
  20. \subsection{Subsection}
  21. You can have subsections too \ldots
  22.  
  23. \subsection{Subsection’}
  24. \ldots as many as you want
  25.  
  26. \subsection{Random stuff}
  27. You can even create a shopping list in LaTeX, if you wish
  28. \begin{center}
  29. \begin{itemize}
  30. \item Beer
  31. \item Beer
  32.         \begin{itemize}
  33.                 \item (Another brand of beer)
  34.         \end{itemize}
  35. \item Pizza
  36. \item Beer
  37. \end{itemize}
  38. \end{center}
  39.  
  40. Or even better, use it to do the homework. \\
  41. Math is a breeze in LaTeX: $x_n = \sqrt{a + b}$ can be typeset inline.
  42. \end{document}

You can download the compiled document from this link. May be it doesn’t look too useful (I’d use LyX instead) but soon we’ll start doing some cool stuff LyX can’t handle. Keep tuned for the next LaTeX article.

     Add A Comment

trackback Trackback URI | rsscomment Comments RSS