LaTeX video tutorial for beginners (video 4)
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.
Images 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 basic maths and equations in our LaTeX documents. In this video we are going to look at inserting graphics into our documents. Before we can start using images in LaTeX we need to load up the graphicx
package. To do this we use the \usepackage
command in the preamble and enter graphicx
, spelt with an x after the c instead of an s, into the curly brackets, like this: \usepackage{graphicx}
.
Next we need to upload the image we want to use into the ShareLaTeX project. To do this click the ‘new’ button in the left hand panel and select ‘upload file’. Once your image has uploaded it will appear in the project panel and it is now ready for us to use. I have uploaded an image called ‘lion’ which is a PNG file. You can also use JPG files or PDF files.
To put an image into the document we use the \includegraphics
command. Then in the curly brackets you enter the file name of the image you want to use without the extension. If I now compile the document my picture will appear on the page. We can use the square brackets immediately after the command, but before the file name, to give LaTeX more instructions as to how we want our image to look. We can scale the size of the image by using the word scale followed by an equals sign and a number. For example by entering scale=2
we double the size of the image. We can also change the size by setting the height and/or width. When doing this we must tell LaTeX which one we want to edit and then give it a number in centimetres. If we just change one of the two, LaTeX will keep the image’s aspect ratio. To edit both of them we simply add a comma and a space after the first argument and then add the second. We can also rotate the image by using the keyword angle
followed by equals and the number of degrees you want to rotate it in an anticlockwise direction.
Although this method of including graphics is a useful one, we often want more control over the image’s positioning. We may also want to add a caption and reference it. To achieve these things we need to use the figure environment. As with all environments we need to use a \begin
and \end
command to encapsulate it. So let’s add a \begin{figure}
and \end{figure}
command either side of our existing \includegraphics
command. You will notice that the image has now moved onto another page. We can influence where LaTeX puts the figure by adding a specifier in square brackets after the \begin{figure}
command. There are six specifiers you may want to know about. The first is a small h
which stands for ‘here’ and puts the figure roughly where the code appears in the text. You can also use a small t
which puts it at the top of the page, a small b
which puts it at the bottom and a small p
which puts it on a separate page reserved for figures and other floats. An exclamation mark is also a valid specifier which will override LaTeX’s idea of where is a good place to put the figure. Finally there is a special identifier, a capital H
which will place the figure at exactly the place you are at in the LaTeX code, however you need to use the float
package to make this one work. You will often need to include the exclamation mark along with one of the small letter specifiers to get the figure where you want it. You may also want to use the \centering
command to centre the figure.
You can add a caption to your figure by using the \caption
command. If you want the caption to go above the picture add the command into the code above the \includegraphics
command, otherwise put it in below.
Lastly let’s briefly mention labels and referencing. In LaTeX we can label items that are numbered, like figures. This allows us to refer back to a labeled item from somewhere else in the document. To label an item use the \label command and then choose a name. For example I might label this figure fig:lion
. Then If I put a \ref
command somewhere in the document along with the name I chose, it will print the number assigned to my figure. Alternatively I could use the \pageref
command to print the page number where my figure occurs. This is very useful as it means if I add figures in before this one at a later date, LaTeX will give me the the right updated numbers.
This concludes our discussion on using image in LaTeX. In the next video we’ll look at using BibTeX.
Video 1 | Video 2 | Video 3 | Video 4 | Video 5 | Video 6 | Video 7
Overleaf guides
- Creating a document in Overleaf
- Uploading a project
- Copying a project
- Creating a project from a template
- Using the Overleaf project menu
- Including images in Overleaf
- Exporting your work from Overleaf
- Working offline in Overleaf
- Using Track Changes in Overleaf
- Using bibliographies in Overleaf
- Sharing your work with others
- Using the History feature
- Debugging Compilation timeout errors
- How-to guides
- Guide to Overleaf’s premium features
LaTeX Basics
- Creating your first LaTeX document
- Choosing a LaTeX Compiler
- Paragraphs and new lines
- Bold, italics and underlining
- Lists
- Errors
Mathematics
- Mathematical expressions
- Subscripts and superscripts
- Brackets and Parentheses
- Matrices
- Fractions and Binomials
- Aligning equations
- Operators
- Spacing in math mode
- Integrals, sums and limits
- Display style in math mode
- List of Greek letters and math symbols
- Mathematical fonts
- Using the Symbol Palette in Overleaf
Figures and tables
- Inserting Images
- Tables
- Positioning Images and Tables
- Lists of Tables and Figures
- Drawing Diagrams Directly in LaTeX
- TikZ package
References and Citations
- Bibliography management with bibtex
- Bibliography management with natbib
- Bibliography management with biblatex
- Bibtex bibliography styles
- Natbib bibliography styles
- Natbib citation styles
- Biblatex bibliography styles
- Biblatex citation styles
Languages
- Multilingual typesetting on Overleaf using polyglossia and fontspec
- Multilingual typesetting on Overleaf using babel and fontspec
- International language support
- Quotations and quotation marks
- Arabic
- Chinese
- French
- German
- Greek
- Italian
- Japanese
- Korean
- Portuguese
- Russian
- Spanish
Document structure
- Sections and chapters
- Table of contents
- Cross referencing sections, equations and floats
- Indices
- Glossaries
- Nomenclatures
- Management in a large project
- Multi-file LaTeX projects
- Hyperlinks
Formatting
- Lengths in LaTeX
- Headers and footers
- Page numbering
- Paragraph formatting
- Line breaks and blank spaces
- Text alignment
- Page size and margins
- Single sided and double sided documents
- Multiple columns
- Counters
- Code listing
- Code Highlighting with minted
- Using colours in LaTeX
- Footnotes
- Margin notes
Fonts
Presentations
Commands
Field specific
- Theorems and proofs
- Chemistry formulae
- Feynman diagrams
- Molecular orbital diagrams
- Chess notation
- Knitting patterns
- CircuiTikz package
- Pgfplots package
- Typesetting exams in LaTeX
- Knitr
- Attribute Value Matrices
Class files
- Understanding packages and class files
- List of packages and class files
- Writing your own package
- Writing your own class