added picture example

This commit is contained in:
Sven Vogel 2023-09-28 13:50:52 +02:00
parent 94cfc039fd
commit af5fc91fcd
4 changed files with 200 additions and 0 deletions

64
pictures/.latexmkrc Normal file
View File

@ -0,0 +1,64 @@
# =====================================================================
# Custom latex make file to bew used with TexLive and Latexmk
# _ _ __ __ _ ______ ____
# | | __ _| |_ _____ _| \/ | |/ / _ \ / ___|
# | |/ _` | __/ _ \ \/ / |\/| | ' /| |_) | |
# | | (_| | || __/> <| | | | . \| _ <| |___
# |_|\__,_|\__\___/_/\_\_| |_|_|\_\_| \_\\____|
# main file to compile
# this is the entry point file
@default_files = ('main.tex');
# =====================================================================
# custom folders to store auxilary and build files inside
# so they don't clutter everything
# Move all axuiliary files to a separate directory, so they do not clutter up the project directory
$emulate_aux = 1;
$aux_dir = ".tmp";
# Move the compiled files (and synctex) to a separate directory
$out_dir = '.tmp';
# command to compile and run
$pdflatex = 'pdflatex %O -interaction=nonstopmode -shell-escape %S';
# =====================================================================
# bibtex
# Specify the bibliography
$bibtex = 'bibtex %O %B';
$makeglossaries = 'makeglossaries %O %B';
# Continuous preview mode
$continuous_mode = 1;
# Set the program used to generate the PDF
# 1: pdflatex
# 2: postscript conversion, don't use this
# 3: dvi conversion, don't use this
# 4: lualatex
# 5: xelatex
$pdf_mode = 1;
# Keep auxiliary files
$clean_ext = " ";
# =====================================================================
# custom dependency handling for glossaries
add_cus_dep( 'acn', 'acr', 0, 'makeglossaries' );
add_cus_dep( 'glo', 'gls', 0, 'makeglossaries' );
$clean_ext .= " acr acn alg glo gls glg";
sub makeglossaries {
my ($base_name, $path) = fileparse( $_[0] );
my @args = ( "-q", "-d", $path, $base_name );
if ($silent) { unshift @args, "-q"; }
return system "makeglossaries", "-d", $path, $base_name;
}
# =====================================================================
# Silence warnings
$silent = 1;

136
pictures/main.tex Normal file
View File

@ -0,0 +1,136 @@
\documentclass[12pt]{article}
% ===================================================
% _____ _
% | ____|_ ____ _ _ __ ___ _ __ | | ___
% | _| \ \/ / _` | '_ ` _ \| '_ \| |/ _ \
% | |___ > < (_| | | | | | | |_) | | __/
% |_____/_/\_\__,_|_| |_| |_| .__/|_|\___|
% |_|
% License: MIT
% Author: Sven Vogel
% Copyright: Sven Vogel (2023)
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{tikz-imagelabels}
\usepackage{caption}
% ===================================================
\title{Abbildungen}
\author{Sven Vogel}
\date{September 2023}
\begin{document}
\maketitle
\makeatletter
% apply this as scaling for images to make them fit available space
\def\ScaleIfNeeded{
\ifdim\Gin@nat@width>\linewidth
\linewidth
\else
\Gin@nat@width
\fi
}
\makeatother
% ===================================================
% Picture
\section{Picture}
The following picture (\ref{fig:a-field}) depicts a yellow field with a tree and spans over the entire line width:
% More information about figures: https://latex-tutorial.com/tutorials/figures/
\begin{figure}[h]
\centering
\noindent
\includegraphics[width=\linewidth]{res/image.jpg}
\caption{Ein wunder schönes Feld}
\label{fig:a-field}
\end{figure}
\cleardoublepage
% ===================================================
% Wrapfigure
\section{Wrap text around figure}
% More about warpfigure: https://www.overleaf.com/learn/latex/Wrapping_text_around_figures
\begin{wrapfigure}{l}{0.5\linewidth}
\centering
\noindent
\includegraphics[width=\ScaleIfNeeded]{res/adam.jpg}
\caption{Adam Cole}
\label{fig:some-adam}
\end{wrapfigure}
It may be noted that the width of the image included was specified relative to width of the text.
It is a good idea to use relative sizes to define lengths, particularly when using wrapfigure.
In the example above, the figure covers exactly half of the the textwidth, and the actual image uses a slightly smaller width, so that there is a pleasing small white frame between the image and the text. The image should always be smaller (less wide) than the wrap, or it will overrun the text.
Take care while using adding wrapfigures very near the top or bottom of a page, as this can often cause unwanted effects that are hard or near-impossible to solve. It is not advisable to try to use wrapfigures alongside equations or sectional headers. They also cannot be used in lists, such as itemize and enumerate environments.
% ===================================================
% Include a PDF as picture
\cleardoublepage
\section{PDF as image included}
\subsection{as vector graphic}
The following picture (\ref{fig:a-field}) depicts a yellow field with a tree and spans over the entire line width:
\begin{figure}[h]
\centering
\noindent
\includegraphics[width=0.5\linewidth]{res/document.pdf}
\caption{Nginx Proxy Manager}
\label{fig:npm}
\end{figure}
% with labels
\cleardoublepage
\section{Image with labels}
\begin{wrapfigure}{r}{0.5\linewidth}
\begin{tikzpicture}[remember picture]
\node[anchor=south west, inner sep=0] (image) at (0,0){\includegraphics[width=\ScaleIfNeeded]{res/adam.jpg}};
\foreach \i/\j/\k in {1/1/1, 4.3/6.3/2} {
\node[circle, draw, fill=white] at (\i,\j) {\k};
}
\end{tikzpicture}
\end{wrapfigure}
It may be noted that the width of the image included was specified relative to width of the text.
It is a good idea to use relative sizes to define lengths, particularly when using wrapfigure.
In the example above, the figure covers exactly half of the the textwidth, and the actual image uses a slightly smaller width, so that there is a pleasing small white frame between the image and the text. The image should always be smaller (less wide) than the wrap, or it will overrun the text.
Take care while using adding wrapfigures very near the top or bottom of a page, as this can often cause unwanted effects that are hard or near-impossible to solve. It is not advisable to try to use wrapfigures alongside equations or sectional headers. They also cannot be used in lists, such as itemize and enumerate environments.
\cleardoublepage
\section{Minipage}
\subsection{Two images side by side}
\begin{figure}[h]
\begin{minipage}[b]{0.49\linewidth}
\includegraphics[width=\ScaleIfNeeded]{res/image.jpg}
\captionof{figure}{Caption for image}
\end{minipage}
\hfill
\begin{minipage}[b]{0.5\linewidth}
\includegraphics[width=\ScaleIfNeeded]{res/image.jpg}
\captionof{figure}{Caption for image}
\end{minipage}
\end{figure}
It may be noted that the width of the image included was specified relative to width of the text.
It is a good idea to use relative sizes to define lengths, particularly when using wrapfigure.
In the example above, the figure covers exactly half of the the textwidth, and the actual image uses a slightly smaller width, so that there is a pleasing small white frame between the image and the text. The image should always be smaller (less wide) than the wrap, or it will overrun the text.
Take care while using adding wrapfigures very near the top or bottom of a page, as this can often cause unwanted effects that are hard or near-impossible to solve. It is not advisable to try to use wrapfigures alongside equations or sectional headers. They also cannot be used in lists, such as itemize and enumerate environments.
\end{document}

BIN
pictures/res/adam.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 112 KiB

BIN
pictures/res/image.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 MiB