Showing first {{hits.length}} results of {{hits_total}} for {{searchQueryText}}{{hits.length}} results for {{searchQueryText}}

Aucun résultat pour la recherche

Video 1 | Video 2 | Video 3 | Video 4 | Video 5 | Video 6 | Video 7

This seven-part series of LaTeX tutorial videos was first published in 2013; consequently, today's editor interface has changed considerably due to the development of ShareLaTeX and the subsequent merger of ShareLaTeX and Overleaf. However, the video content is still relevant and teaches you the basics of LaTeX—skills and expertise that will apply across all platforms. You don’t need any previous background knowledge, and by the end of these LaTeX guides you will be able to create and write basic LaTeX documents and have the knowledge to start learning how to create more complicated documents. Each video is accompanied by a transcript (listed below the video)—these in-situ transcripts replace the URLs shown at the start of each tutorial.

Tables and matrices in LaTeX

Note: You can open the project used in the video by following this link.

Video transcript

In the previous video we looked at using BibTeX to add bibliographies into our documents. In this video we’ll look at inserting tables and matrices.

To insert tables in LaTeX we use the tabular environment. So let’s add in our begin and end commands. Immediately following the \begin{tabular} command we need to tell LaTeX the column specifications. There are a few key characters we use to do this. Firstly, a lower case l specifies a left justified column, a lower case r specifies a right justified column and a lower case c specifies a centred column. In my example I’m going to specify six columns, the first and last will be left-justified and the rest will be centred. To put vertical lines between the columns we can use the bar symbol and place it between the letters where we want the lines to appear. When entering the tables’ contents we start each row on a new line, separate column entries using an ampersand and finish each row, except the last, with a double backslash.

Now to add horizontal lines we use the \hline command. To make a double horizontal line simply use the command twice. One potential problem with this table is that if I add a long line of text into one of the cells in the final column it will sprawl off the page. To fix this there is another option we can use when declaring column specifications. It is a lower case p followed by a width in centimetres in curly brackets. So if I change the final l in the declaration to a p with 5cm you will see the text has been wrapped so that the final column’s width is 5cm.

So that’s the basics of writing tables. However, just like with images, we often want more control over positioning and we may want to add a caption and label. To do this we use an environment called table which is similar to the figure environment we used for images. To put our existing table in the table environment we simply enclose the code in \begin{table} and \end{table} commands. We can then set the position specifier using a combination of h, t, b, p and exclamation mark (!). I can also add a caption and label.

We will now briefly look at matrices as they use similar syntax as tables. At this point make sure you’ve loaded the amsmath package. Before we add a matrix we need to tell LaTeX that we are about to add some maths by opening an environment. We could use the equation environment as we did a few videos ago, however here we’ll use the displaymath environment as it has nice LaTeX shorthand. This means instead of using a \begin command we can use a backslash and open square bracket and instead of an end command we can use a backslash and close square bracket. Matrices can be inserted using the matrix environment. With matrices we don’t need to declare how many columns we use, we can simply start adding the entries. Again we enter each row on a new line, separate entries using an ampersand and separate rows using a double backslash. To change the brackets surrounding the matrix, we change the environment. The pmatrix environment uses parenthesis, bmatrix uses square brackets, Bmatrix (with a capital B) uses curly brackets, vmatrix uses vertical lines and Vmatrix (with a capital V) uses double vertical lines.

Finally we’ll finish this video with a more interesting matrix. What we are doing in this example is nesting matrices inside another matrix. So what we actually have here is a two by two matrix built with the pmatrix environment, where the top left and bottom right entries are also matrices, this time built with the matrix environment to avoid multiple brackets.

This concludes our discussion on tables and matrices. In the final video of this series we’ll look at composing larger documents.

Video 1 | Video 2 | Video 3 | Video 4 | Video 5 | Video 6 | Video 7

[edit] Overleaf guides

[edit] LaTeX Basics

[edit] Mathematics

[edit] Figures and tables

[edit] References and Citations

[edit] Languages

[edit] Document structure

[edit] Formatting

[edit] Fonts

[edit] Presentations

[edit] Commands

[edit] Field specific

[edit] Class files

[edit] Advanced TeX/LaTeX