3

Following is the easiest example I could make to represent my problem.

\documentclass[10pt,a4paper]{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[ngerman]{babel}
\usepackage{tkz-euclide}

\title{Mathematik II}
\subtitle{SoSe 2017}
\date{}

\begin{document}
\setcounter{section}{5}
\maketitle
\tableofcontents
\section{Lineare Algebra}
\newpage
\subsection{Vektoren}{
Größen die durch mehrere Zahlen gekennzeichnet werden.

Größen mit Betrag und Richtung.

Ort $\vec{r}$

Geschwindigkeit $\vec{v}$

Kräfte $\vec{F}$

Rechnen mit Vektoren

\begin{figure}
\begin{tikzpicture}[
scale=0.9,
axis/.style={very thick, ->, >=stealth'},
important line/.style={thick},
dashed line/.style={dashed, thin},
pile/.style={thick, ->, >=stealth', shorten <=2pt, shorten
    >=2pt},
every node/.style={color=black}
]
\tkzInit[xmax=6,ymax=6,xmin=-6,ymin=-6]
\tkzGrid
\tkzAxeXY
\end{tikzpicture}
\end{figure}
}
\end{document}

I am new to latex and am trying to place the tikzpicture below the text of the subsection, which seems to be something no one else has a problem with since there are no related searchresults.

What am I missing or doing wrong?

Torbjørn T.
  • 206,688
  • Welcome to TeX.SE! (Mathematik II ... da werden Erinnerungen wach ;-)) –  Apr 21 '17 at 22:04

1 Answers1

2

You are typesetting it in a floating environment, which is figure.

Figures and tables are usually and most always best typeset that way: they can occupy the needed space without disturbing the color, spacing and harmony of the text composition, but still being conveniently near to the text referring to them.

LaTeX tries to give the best result either putting the floating environment on top, or on bottom of the page or, if it deems it best, on a page by itself.

If you want to change the position of your float, please look at this and this (thanks@Torbjørn) questions.

Briefly you can give the [h] option to the float, or remove it at once, in order to obtain what you want.

Moriambar
  • 11,466
  • Exactly what I needed, thank you! adding [h] after {figure} did place it below the text. – Meik Vtune Apr 21 '17 at 22:05
  • @MeikVtune See also https://tex.stackexchange.com/questions/2275/keeping-tables-figures-close-to-where-they-are-mentioned for some options on controlling float placement -- that one is more "practical" than the question Moriambar referred to. However, most likely you should replace \begin/\end{figure} with \begin/\end{center}, if you don't want/need the diagram to move. (By the way, this is actually one of the most asked questions around here, because a lot of users hasn't quite grasped the concept of floating environments`. It doesn't really have anything to do with TikZ.) – Torbjørn T. Apr 21 '17 at 22:15
  • @MeikVtune [h] is a bad choice (usually it generates a warning) and it makes it highly likely that the float can not be placed so goes to the end of the document. [htp] is a more reasonable option that allows h – David Carlisle Apr 21 '17 at 22:36
  • @DavidCarlisle I've changed from figure to center, which seems to not need optional commands and also centers the float, but for the future I will keep this in mind, thank you. – Meik Vtune Apr 21 '17 at 22:38
  • @MeikVtune center stops it floating altogether (so typically chooses excessive space at the page breaks (since avoiding bad page breaks is why typesetting systems move figures) – David Carlisle Apr 21 '17 at 22:40
  • Why does LaTeX think that to place a float above text is better? How does it count that? – Yaroslav Nikitenko Sep 06 '18 at 16:48