Compare commits

...

2 Commits

Author SHA1 Message Date
Sven Vogel af5fc91fcd added picture example 2023-09-28 13:50:52 +02:00
Sven Vogel 94cfc039fd updated minted 2023-09-27 17:38:46 +02:00
7 changed files with 273 additions and 4 deletions

3
.gitignore vendored
View File

@ -301,3 +301,6 @@ TSWLatexianTemp*
# Uncomment the next line to have this generated file ignored.
#*Notes.bib
.tmp
.build
*.pdf

64
minted/.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;

View File

@ -21,17 +21,17 @@
% include the required package
% make sure this is installed:
% > tlmgr install minted
\usepackage{minted}
\usepackage[outputdir=.tmp]{minted}
% ===================================================
% set global style for minted
\usemintedstyle{borland}
\usemintedstyle{tango}
% set global options for all listings
% these can also be applied locally to individual listings
\setminted {
linenos=true, % enable line numbers
bgcolor=lightgray, % background color
bgcolor=white, % background color
resetmargins=true,
tabsize=4, % white spaces for tabs
xleftmargin=24pt, % margin to the left side. can be used to include line numbers
@ -60,8 +60,9 @@ The following will show some syntax highlighted source code:
% every minted block is wrapped in a listing block for alignment and
% the option to add some caption and label
\begin{listing}[ht]
% vvvvvvvv <= specifiy language
% specifiy language
\begin{minted}{python}
def incmatrix(genl1,genl2):
for i in range(m-1):
for j in range(i+1, m):
@ -83,6 +84,7 @@ def incmatrix(genl1,genl2):
VT = np.zeros((n*m,1), int)
return M
\end{minted}
\caption{Some python code} % add a caption
\label{listing:1} % add a label for referencing

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