Outils pour utilisateurs

Outils du site


issue171:tutoriel1

Ceci est une ancienne révision du document !


When it comes to typesetting, LaTeX is the undisputed champ. Boika, Boika… It outweighs its opponents in the sheer number of options alone. At first, LaTeX is a bit confusing and difficult to use. Not to scare you, but I suggest looking here: http://tug.ctan.org/info/symbols/comprehensive/symbols-a4.pdf

So by this point you have an understanding of inserting pictures into your LaTeX document, but let’s say you want to add some data. I am unashamedly stealing this from Wikipedia as I just needed some values (and because if I steal it anywhere else, people get upset about copyright nonsense).

So If I wanted to have a table with the maximum temperatures for British Columbia, how would you think that we would do it? With a subsection of Tables! This can be sales figures or whatever you want, we are just going to use temperatures as a neutral example. I hope you have your practise document from the last issue. Delete everything between \begin{document} and \end{document} so we can start fresh.

This is what we will be covering if you are interested in the long explanation: https://latex.wikia.org/wiki/Tabular_(LaTeX_environment)

Our code (or skeleton, per-se) will be, if you deleted last month’s file:

\documentclass[a4paper, twocolumn]{article} \usepackage{graphicx} \usepackage{subcaption} \graphicspath{dir-list} \usepackage{lipsum}

\begin{document}

\end{document}

If you looked at the Wiki, you would have seen a bunch of “c’s” following the word ‘tabular’. Now what is all this about? Well, the ‘c’ is shorthand for centre, so it is the alignment of your columns. From this you should be able to figure out that ‘l’ will be left alignment, and ‘r’, right alignment. The pipe symbol is the line, separating the columns. Starting to make sense? I thought so! We generally do have smart readers.

I am going with four columns, as our stolen data has four months listed. We can do that first and see what it looks like. You can name your columns and use the ampersand “&” to separate them.

Monkey see, monkey do quickly and I will explain.

\subsection{Tables}

\begin{table}

\begin{tabular}{||c|c|c|c||}

Jan & Apr & Jul & Oct

\end{tabular}

\end{table}

I inserted two pipe symbols on either side of my columns, to get double lines. Pipe symbol = line, if that was not clear. It looks very ugly, but it illustrates something you needed to learn. Tabular is included in LaTeX and does not require you to import any packages. We use {Tables} to make our tabular columns float. That way we can align our table with text. Please, at any time, feel free to play with the options you have learned so far. Make more columns, change the amount of lines, whatever makes you happy. If you make a mistake, see if you can rectify it before looking back here. Feel free to add some ipsum text, to see what it looks like.

We have columns, but how do we get rows? In LaTeX, rows are called horizontal lines, so you will need to pre-fix and post-fix each data line with ‘hline’. The other thing you need to know is that two slashes “\\” end a line.

If you looked at the example on the Wiki, did you figure it out? Don’t worry, me neither. Monkey see, monkey do time. I will do the first and you see if you can do the rest from our stolen table.

\begin{tabular}{||c|c|c|c||}

\hline
Jan & Apr & Jul & Oct \\ \hline
5.6C & 10.2C & 16.2C & 11.1C \\ \hline

\end{tabular}

I added the Celsius symbol so you can see that it is not numeric only. Go ahead and make a table. Admit it, it was easier than you thought.

Homework: add a caption to the table explaining what we are looking at.

This is the basics of tables, we can go deeper, but we have a lot to cover, and this series is aimed at newbies who have no idea what LaTeX is. They are kept short on purpose, as LaTeX can overwhelm those who have no idea how complex it can be.

Reference for you: https://riptutorial.com/latex/example/17506/the-tabular-environment

If you managed to keep up, well done! See you next issue with more cryptic codes.

There are more graphics options available from the tikz package. That is another kettle of fish completely. Tikz can net you a 12-part series on its own. We will maybe touch on it at the end of this series.

Did I make a mistake? Do you have questions? E-mail us at: misc@fullirclemagazine.com

issue171/tutoriel1.1627838311.txt.gz · Dernière modification : 2021/08/01 19:18 de auntiee