Compare commits

...

7 Commits

244
README.md
View File

@@ -48,6 +48,9 @@ automatically styled correctly.
| `\subsubsection{<YOUR_TITLE>}` | This is the second subtitle. It is numbered with three numbers (e.g. 1.1.1 Subsubtitle). |
| `\subsubsubsection{<YOUR_TITLE>}` | This is the third subtitle. It is not numbered at all and is also not showing up in the table of contents. |
If the section should not be numbered, you can use a * before the opening bracket. Should look like this:
`\subsection*{<YOUR_TITLE>}`.
## Formatting text
The following commands are used to format normal paragraphs. However, most commands can be used in other environments (
@@ -60,6 +63,16 @@ e.g. tables) as well.
| `\textit{<TEXT>}` | Formats the text inside the brackets italic. |
| `\underline{<TEXT>}` | Underlines the text inside the brackets. |
## Escaping characters
Some characters are used as a part of a command for latex. Due to that, they need to be escaped when they should be
printed specifically. To escape a character, you use a '\\' before the character or symbol. Typical symbols you need to
escape are:
| Symbol | Escaped |
|--------|---------|
| \\ | \\\ |
## Bulletpoints and Enumerations
### Bulletpoints
@@ -232,3 +245,234 @@ The full table-definition defined with placeholders looks like this:
Here, we also have the table captioned (which enables us to create a table-directory) and we also gave the table a
label. The label is (as with graphics) important to reference it in the text, that it can be placed correctly by the
compiler.
# Reference tables and images in text
With the compiler in LaTeX you get the best results with the placement of pictures and tables, if you reference them in
the text they belong to. The compiler then places them near that text automatically. You can also reference to a
section, in which case the title of the section gets automatically updated.
## Referencing tables & images
The process of referencing tables and images is the same for both of them. In the preceeding chapters of this manual we
have seen the labelling process for tables and images.
### Labelling tables & images
To create a reference, the target-element has to be given an id first. That id is called label in LaTeX. Its best
practice, to label tables and images differently. I personally like to use the following prefixes for tables and images,
followed by a short 1-3 word description of the image or table.
| type | label |
|-------|----------------------------|
| Table | tab:<DESCRIPTION_OF_TABLE> |
| Image | fig:<DESCRIPTION_OF_IMAGE> |
```latex
\begin{figure}
\centering
\includegraphics[width=\linewidth]{graphics/examplegraphic}
\label{fig:exampleimage}
\end{figure}
\begin{center}
\begin{tabularx}{\textwidth}{| m | m |}
\hline
\textbf{Header 1} & \textbf{Header 2} \\ \hline
Content 1.1 & Content 1.2 \\ \hline
\end{tabularx}
\label{tab:exampletable}
\end{center}
```
### Referencing on tables & images in the text
To reference on tables and images in the text, we use the command `cref`. It takes the label of the element you want to
reference as a parameter. So an example-usage in a text would be the following:
```latex
This is a text example. You can see its usage in the image \cref{fig:exampleimage}.
You can also view the table \cref{tab:exampletable} for the full command reference.
```
## Referencing sections
Referencing sections works basically the same way as referencing tables or images. It also uses labels on the sections,
but it does not use `cref` to create the reference. Instead we just use `ref`.
### Labelling sections
For labelling sections, I also like to use a prefix. I use the prefix `sec:` for sections. After the prefix, there is a
short description of the section (or the whole title if it's just 1-3 words) to identify the section uniquely.
| type | label |
|----------|------------------------------|
| sections | sec:<DESCRIPTION_OF_SECTION> |
```latex
\section{This is a section.}
\label{sec:examplesection} This is the text that is displayed directly after the title.
```
### Referencing a section in the text
As mentioned, we reference a section similarly to tables and images. We just use another command to reference it. We use
`\ref`, which takes the label of the section as an argument.
```latex
This is a text. In this text we reference to the chapter \ref{sec:examplesection}.
```
# Citing with BibTeX
This template is already setup to use citations with BibTeX. To define your sources to cite from, you need to use the
`bibliography.bib` file.
## Defining sources
When defining sources, it's important to know, what type of source you want to create and cite.
For mor information you can visit https://www.bibtex.com/e/entry-types/. There all BibTeX types are documented.
### Defining Web-Sources
To define web sources, I've found the type "misc" perfect. You can always use the following template and fill in the
variables in with blanks.
> It's **very important** to fill out the variable `<CITING_ID>`. This variable is used to reference the reference in
> the
> text to the correct BibTeX entry.
```latex
@misc{<CITING_ID>,
author = {<AUTHOR_NAME>},
title = {<WEBSITE_TITLE>},
date = {<PUBLISHED_DATE>},
year = {<PUBLISHED_YEAR>},
urldate = {<VIEWED_ON_DATE>},
note = {Abgerufen am <VIEWED_ON_DATE>},
howpublished = {<URL_TO_PAGE>}
}
```
### Defining a Book-Source
To define a book source, it's basically the same principle as a web source. You just got other variables / fields to
fill in.
```latex
@book{<CITING_ID>,
author = {<AUTHOR_NAME>},
title = {<BOOK_TITLE>},
publisher = {<PUBLISHER>},
year = {<YEAR_PUBLISHED>},
pages = {<PAGES_RELEVANT>}
}
```
### Defining a Newspaper-Source
Newspaper sources work the same. You got a few more variables to fill, because there are more informations relevant.
```latex
@article{<CITING_ID>,
author = {<AUTHOR_NAME>},
title = {<ARTICLE_TITLE>},
journal = {<NEWSPAPER_NAME>},
year = {<YEAR_PUBLISHED>},
volume = {<NEWSPAPER_VOLUME>},
number = {<NUMBER>},
pages = {<PAGES_OF_NEWSPAPER_RELEVANT>},
}
```
## Citing defined sources in LaTeX
To cite your sources you've defined in your bibliography file, you can use the syntax of `\cite{<CITING_ID>}` as you can
see, you need your citing-id here again. This is to reference your citing in the text to the correct entry in your
bibtex-file.
# Importing other files
With LaTeX you can import other files (such as other LaTeX files or pdfs) into your main file. This is very useful for
attachments or external documents, which you want to include in your documentation.
## Import .tex files
To import .tex files, you can use `\input{<FILEPATH>}` or `\import{<FILEPATH>}`.
## Import one .tex file
To import a single text file, you can just use `\input{<FILEPATH>}`.
## Import multiple .tex files after each other
If you want to import multiple .tex files directly after each other, the syntax is a bit special. You use
`\input{<FILEPATH>}` for the first .tex file, and `\import{<FILEPATH>}` for all the following .tex files. As soon as
there is a text, heading or float (graphics/tables) between two imported .tex files, you can use `\input{<FILEPATH>}`
again. See the example below for clarification.
```latex
\input{<FILEPATH_1>}
\include{<FILEPATH_2>}
\include{<FILEPATH_3>}
\include{<FILEPATH_4>}
\section{New header}
This is a text for this header.
\input{<FILEPATH_5>}
```
## Importing external pdf's
Importing pdfs is especially interesting for attaching sources to your documentation. The most practical way is to use a
special configuration of the `\includegraphics` command.
```latex
\includegraphics[height=0.9\textheight]{<PDF_FILEPATH>}
```
With this configuration you also have enough room to add a header above the included pdf.
### Importing a selection of pdf pages
There is a possibility to import only two pages of a pdf into your document. Use the following configuration for this:
```latex
\includepdf[pages={<PAGE_RANGE>}, noautoscale=true, scale=0.9, pagecommand={\thispagestyle{fancy}}]{<PDF_FILE_PATH>}
```
In page range its possible to use a number-range. To include from the first to for example 3rd page you can also use the
keyword `first`. The same is possible with the last page by using the keyword `last`.
### Importing the whole multipage pdf document
To import a full pdf document with multiple pages, you need a combination of the above standing commands. This is
because if you want to have a title above the first page, you need to make space for the title. With the
`\includegraphics` command, we make that space by making the height of the float smaller.
So to import multiple pages of the same document, use the following syntax:
```latex
\includegraphics[height=0.9\textheight]{<PDF_FILEPATH>}
\includepdf[pages={2-last}, noautoscale=true, scale=0.9, pagecommand={\thispagestyle{fancy}}]{<PDF_FILEPATH>}
```
The first command imports the first page of your pdf. The second command includes the 2nd to last page into your main
file. You can also change the page-range of the second command, in case you don't want all pages to the last inculded.
# Create a landscape page inside a document
To create a landscape page inside a portrait document, you can use `\begin{landscape}`. In the following example this is
explained better:
```latex
This paragraph is still in portrait.
\pagebreak
\begin{landscape}
This paragraph is in landscape.
\end{landscape}
This paragraph is in portrait again.
```