From c408b1d944ab8fb1d8078788a03dae9ea7331cfe Mon Sep 17 00:00:00 2001 From: Tobias Hilfiker Date: Thu, 9 Jan 2025 18:52:02 +0000 Subject: [PATCH] Add table-section to readme Added the table-section to the readme document --- README.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 65 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 07af7fb..9cba3dc 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,22 @@ This is a LaTeX Template Repo to create other Documents. The contents include: Use this Template to create your own repo with the starter-documents and an integrated Action to build and publish your LaTeX-Projects on Push. # Files Here, the various contents and variables of the files get explained. This is especially important for the initial setup of your project. + ## Titlepage.tex The Titlepage-File defines (as the name implies) the layout and contents of the titlepage. It gets imported into the main.tex document, that you only get one PDF with all the contents in it. + ### Placeholders The File holds multiple placeholders, which should be replaced with the actual value. + |Placeholder|Meaning| |--|--| |``|Path to the image that is placed over the title/subtitle. Refer to the graphics-section for more information on graphic files.| |``|Main title of the document| |``|Subtitle of the document| +# Basic LaTeX formatting + + # Use of Graphics Using graphics in LaTeX is not difficult. It's best practice to create a new subfolder (e.g. `graphics`) in your project to store all the graphics. To embed a graphic into your document, two steps are required. First, you need to insert the graphic with all information associated with it into the document. Idealy you position this part near the position in the real document. > ⚠️ Attention: @@ -31,7 +37,7 @@ Using graphics in LaTeX is not difficult. It's best practice to create a new sub \includegraphics[width=0.8\linewidth]{} \caption{ (Quelle: \cite{})} \label{fig:} -\end{figure} + \end{figure} ``` The example places the Figure in the middle ( `\centering`). It's width is defined as 80% of the linewidth (linewidth equals the width of a text-line). The percentage-value can be changed as needed. If the width should be 100% of the line, you just use `\linewidth`. @@ -43,5 +49,61 @@ It's important that the graphics that you use are referenced in the text, so tha ``` ## Special graphic-options > **⚠️USE THESE WITH EXTREME CAUTION⚠️** -- `\begin{figure} [h]` ➡️ the `[h]` means, that the figure should be placed exactly here in the document. You override the compiler with this setting, so you should only use it if really necessary. -- `\captionof{figure}{}` ➡️ Sometimes you need to use `\captionof` instead of `\caption` to get the caption below a figure working. \ No newline at end of file +- `\begin{figure} [h]` ➡️ the `[h]` means that the figure should be placed exactly here in the document. You override the compiler with this setting, so you should only use it if really necessary. +- `\captionof{figure}{}` ➡️ Sometimes you need to use `\captionof` instead of `\caption` to get the caption below a figure working. +# Use of Tables +In this template some preparations are done, that creating tables is not that difficult. +## Column width +There are five different widths defined for the table columns. The width gets calculated from the value `m`, so a column-width of `m` equals 100% relative width. +|letter defining width|relative percentage to `m`| +|--|--| +|`W`|150%| +|`w`|125%| +|`m`|100%| +|`S`|75%| +|`s`|50%| +## Defining a basic table +To define a table, we start by defining a centred (you probably want your tables centred on the page) block. Then we define a `tabularx` environment, which gives us the functionality of the table itself. In there, we need to define our columns and can define the contents of the table. An example-definition of a table looks like this: +```latex +\begin{center} + \begin{tabularx}{\textwidth}{| S | w |} + \hline + \textbf{Header 1} & \textbf{Header 2} \\ \hline + Content 1.1 & Content 1.2 \\ \hline + Content 2.1 & Content 2.2 \\ \hline + \end{tabularx} +\end{center} +``` +In the example above, the table is defined with a `S` and a `w` column width. Due to the fact, that there are two columns defined, the sum of all width-percentage-values need to get to 200% (per defined column 100% width, so with two columns 200%). +In this case we have a 75% width column (defined with `S`) and a 125% width column (defined with `w`). In sum, we get to 200%. **If this calculation is not done correctly, the table will not be shown correctly in the generated PDF.** + +### Table width +The table width is determined by the first argument of `tabularx`. In the example above, the table-width is defined as the textwidth. If you want 80% of the textwidth, you can do that by typing `0.8\textwidth`. +### Defining columns +To define columns, we use the second argument of `tabularx`. To get vertical lines in the table, they need to be defined in this argument. +The left line (created by AltGR + 7) represents the left table-border. +Then there is a space, following the letter for the column width (as seen in the last chapter). +After another space, the seperator between the two columns follows. +The same is repeated for the second column and it's border to the right of it. +### \\\ \hline? +\\\ creates a new line, as learned in the chapter [Basic LaTeX formatting](#Basic-LaTeX-formatting). It does the same in tables. Just that you only want to generate a new line in tables, when you're actually at the end of the line. + +The command `\hline` creates a horizontal line. If you don't write that command (and just break the line to the next one) you don't get a delimiting line between the lines. +### Separating column content +To separate the contents of two different columns, the `&` symbol is used. You can just place it wherever you need the seperation of the contents to happen. +## Defining a table with all properties +In the previous chapter, you learned how to define a basic table. To define a full table (as probably needed in your documentation) you need to add a few lines of LaTeX. +The full table-definition defined with placeholders looks like this: +```latex +\begin{center} + \begin{tabularx}{\textwidth}{| S | w |} + \hline + \textbf{Header 1} & \textbf{Header 2} \\ \hline + Content 1.1 & Content 1.2 \\ \hline + Content 2.1 & Content 2.2 \\ \hline + \end{tabularx} + \captionof{table}{} + \label{tab: