Skip to content
/ LaTeX Public

Getting started with LaTeX, including basic templates and a Docker image.

Notifications You must be signed in to change notification settings

b4stet/LaTeX

Repository files navigation

Getting started with LaTeX

In this repository, you will find some basics to create pdf documents without spending more time on the layout than on the content :)

LaTeX installation

Several packages are required to compile tex file and get pdf result. To ease portability, a Docker image is provided in the repository.

docker build -t mylatex .

If you prefer to install packages on your system, just extract the list from the Dockerfile: they are known to work fine on Ubuntu Xenial. If you need a specific language support (for accents for instance), just add the right texlive-lang-** to the list.

In case your favorite editor is vi, you can install the following plugin to get autocompletion and some shortcuts:

aptitude install vim-latexsuite
vim-addons -w install latex-suite

Getting started

Starting a new document

The main document, the one you will compile is ... main.tex. Let start by choosing what you want:

  • type of document: uncomment 'article' or 'book' lines according to your needs.
    article for short document
    book for document with parts/chapters

  • title and author:
    title/subtitle
    author

  • watermark: if needed, uncomment draft or confidential

Writing content

You can now write your content in main.tex between begin{document} and end{document}.

I recommend to split your content with one tex file per section, and include them in main.tex. This way, collaboration is easier and you avoid having a file with thousands of lines to edit ...

Inserting a figure

png format is mandatory here (LaTeX supports many other, but png will avoid lots of issues at compilation time). If needed, imagemagick will help you.

convert image.XXX image.png

Let place all your images in img/ folder. You can insert a figure using the macro fig and the following syntax:

\fig{height}{filename}{caption}{label}
  • height in centimeter
  • filename without the extension
  • caption is a comment of your figure
  • label is a flag to refer to your figure somewhere in your document using \ref{ }

Example in the current main.tex:

\fig{3cm}{sandwich}{illustrating sudo}{fig:sudo}
The figure \ref{fig:sudo} comes from xkcd.

Inserting a table

The macro tab is similar to fig and has the following syntax:

\tab{columns scheme}{content}{caption}{label}
  • columns scheme using c (centered), l (left aligned) or r (right aligned)
  • content using hline and & keywords
  • caption as for images
  • label as for images

Tables can be really complex in latex (merging columns/rows, colors, etc). Just refer to LaTeX wiki on purpose.

Exemple in the current main.tex:

\tab{|c|l|r|}{
\hline
name & color & coat \\ 
\hline\hline
meow & white and black & short \\
\hline
}{Description of my cat}{tab:catdesc}
The table \ref{tab:catdesc} describes my lazzy cat.

Inserting a bibliography

Generating a bibliography for your document requires three steps:

  • fill main.bib, following the rules described in BibTex wiki
  • uncomment the three relevant lines in main.tex
  • compile (you can use the Docker image here too)
pdflatex main.tex
bibtex main.aux (2 times)
pdflatex main.tex

Full example

Let compile the tex file in this repo.

docker run -it -v $(pwd):/code -w /code -u $(id -u $USER):$(id -g $USER) mylatex pdflatex main.tex

Comparing the tex file main.tex and the result main.pdf, you can learn the syntax to get most of the basics: list/ordered list/table/newline/section and subsections/table of contents/figure/... For an advanced usage, you can refer to LaTeX wiki :)

Resources

About

Getting started with LaTeX, including basic templates and a Docker image.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages