114 lines
2.0 KiB
Markdown
114 lines
2.0 KiB
Markdown
@slide(layout=chapter-slide)
|
||
|
||
@number
|
||
9
|
||
|
||
@title
|
||
Graphics
|
||
|
||
|
||
@slide(layout=content-only)
|
||
|
||
@title
|
||
Including graphics <span class="emoji">🖼️</span>
|
||
|
||
@content
|
||
To display graphics, we need the `graphicx` package.
|
||
|
||
``` {.lang-tex .hljs}
|
||
\begin{figure}
|
||
\includegraphics{<file path>}
|
||
\caption[<short caption (table of
|
||
figures)>]{<full caption>}
|
||
\end{figure}
|
||
```
|
||
|
||
Specifying the size:
|
||
|
||
``` {.lang-tex .hljs}
|
||
\includegraphics[width=0.5\textwidth,
|
||
height=5cm]{<file path>}
|
||
```
|
||
|
||
|
||
@slide(layout=content-only)
|
||
|
||
@title
|
||
Layout on the page
|
||
|
||
@content
|
||
|
||
``` {.lang-tex .hljs}
|
||
\begin{figure}[<position code>]
|
||
```
|
||
|
||
LaTeX places graphics automatically. With position codes, we can express our preferences (they can be combined as well).
|
||
|
||
|
||
<table>
|
||
<tr>
|
||
<th style="min-width:4em">code</th>
|
||
<th>position</th>
|
||
</tr>
|
||
<tr class="fragment">
|
||
<td>h</td>
|
||
<td>here, if you don’t mind</td>
|
||
</tr>
|
||
<tr class="fragment">
|
||
<td>t</td>
|
||
<td>top of the page</td>
|
||
</tr>
|
||
<tr class="fragment">
|
||
<td>b</td>
|
||
<td>bottom of the page</td>
|
||
</tr>
|
||
<tr class="fragment">
|
||
<td>p</td>
|
||
<td>on its own page</td>
|
||
</tr>
|
||
<tr class="fragment">
|
||
<td>H</td>
|
||
<td>Here, for God’s sake! <br />(`float` package required)</td>
|
||
</tr>
|
||
</table>
|
||
|
||
|
||
@slide(layout=content-only)
|
||
|
||
@title
|
||
Centred alignment
|
||
|
||
@content
|
||
``` {.lang-tex .hljs}
|
||
\begin{figure}[<position>]
|
||
\begin{center}
|
||
\includegraphics{<path-to-file>}
|
||
\end{center}
|
||
\end{figure}
|
||
```
|
||
|
||
Alternatively:
|
||
|
||
``` {.lang-tex .hljs}
|
||
\begin{figure}[<position>]
|
||
\centering
|
||
\includegraphics{<path-to-file>}
|
||
\end{figure}
|
||
```
|
||
|
||
|
||
@slide(layout=task)
|
||
|
||
@task-number
|
||
9
|
||
|
||
@title
|
||
Inserting graphics
|
||
|
||
@content
|
||
* In the directory `exercises/graphics` you can find an image file named `latex-logo.png`.
|
||
* **Include** the figure in `exercises/graphics/graphics.tex` and place it **exactly** where you include it.
|
||
* The image shall be **centered**.
|
||
* Additionally, add a **caption** for the figure.
|
||
* Adapt the **width** of the image to the width of the text (`\textwidth`).
|