Graphics, Figures & TablesFigure below Paragraph

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
kangaro0
Posts: 3
Joined: Thu Sep 07, 2017 3:01 pm

Figure below Paragraph

Post by kangaro0 »

Hey folks,

I have a problem with my latex code. The figure shows up above the paragraph, but I wrote it the other way around in my source code. I tried placing the figure in different ways [h], [h!], [ht], [ht!] but I always get the same output..

Code: Select all

\subsubsection{Messung 1, Protokoll: UDP, FPS: 15}

% THIS IS BELOW ....
\paragraph{Balkendiagramm}
% ... THIS :/
\begin{figure}[hb!]
	\centering
	\includegraphics[width=\textwidth]{pictures/latencies/messung1,udp.png}
	\caption{Messung 1: Diagramm}
\end{figure}

% SAME SITUATION ...
\paragraph{Durchschnittliche Latenzen}
% ... HERE
\begin{table}[h!]
	\centering
	\begin{tabular}{ | l | l | }
		\hline
		\textbf{Latenz} & \textbf{Ø in ms} \\
		\hline
		Round-Trip-Time & 52,85320833 \\
		\hline
		JPEG-Kompression & 10,492475 \\
		\hline
		Kodierung: Client & 0,675591667 \\
		\hline
		Latenz: Client -> Server & 7,213616667 \\
		\hline
		Positionserkennung & 4,818333333 \\
		\hline
		Rendering & 4,818333333 \\
		\hline
		Kodierung: Server & 5,981666667 \\
		\hline
		Latenz: Server -> Client: & 7,608333333 \\
		\hline
		Zeichnung & 0,347675 \\
		\hline
	\end{tabular}
	\caption{Messung 1: Ø-Latenzen}
\end{table}
Is there anything I can do to get my code working as expected?

Regards,
kangaro0

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Figure below Paragraph

Post by Johannes_B »

Do not use a figure environment, all its purpose is to move your figure to a good place.

You can use package capt-of to get a caption.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kangaro0
Posts: 3
Joined: Thu Sep 07, 2017 3:01 pm

Figure below Paragraph

Post by kangaro0 »

Hey Johannes_B,

thanks for the quick answer. In case somebody stumbles on this, I solved it according to your proprosal.

Code: Select all

% NECESSARY IMPORT
\usepackage{capt-of}

% ...

\subsubsection{Messung 1, Protokoll: UDP, FPS: 15}

% THIS IS NOW ...
\paragraph{Balkendiagramm}
% ... ABOVE THIS
\begin{center}
	\begin{minipage}{\linewidth}
		\centering
		\includegraphics[width=\textwidth]{pictures/latencies/messung1,udp.png}
		\captionof{figure}{Messung 1: Diagramm}
	\end{minipage}
\end{center}

% SAME BEHAVIOUR ...
\paragraph{Durchschnittliche Latenzen}
% ... HERE!
\begin{center}
	\begin{minipage}{\linewidth}
		\centering
		\begin{tabular}{ | l | l | }
			\hline
			\textbf{Latenz} & \textbf{Ø in ms} \\
			\hline
			Round-Trip-Time & 52,85320833 \\
			\hline
			JPEG-Kompression & 10,492475 \\
			\hline
			Kodierung: Client & 0,675591667 \\
			\hline
			Latenz: Client -> Server & 7,213616667 \\
			\hline
			Positionserkennung & 4,818333333 \\
			\hline
			Rendering & 4,818333333 \\
			\hline
			Kodierung: Server & 5,981666667 \\
			\hline
			Latenz: Server -> Client: & 7,608333333 \\
			\hline
			Zeichnung & 0,347675 \\
			\hline
		\end{tabular}
		\captionof{table}{Messung 1: Ø-Latenzen}
	\end{minipage}
\end{center}
Maybe someone can explain why the error was happening beforehand? In my understanding 'H' (here) means HERE!

Regards,
kangaro0
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Figure below Paragraph

Post by Johannes_B »

In my understanding 'H' (here) means HERE!
You have never mentioned H in your first post. That indeed would have made the figure lose its floating behaviour, but this is only supported by package float, which is incompatible with some classes.

What you tried means here, if possible and LaTeX just ignores a single h, because that makes positioning the floating box (image and caption) a lot lot harder.

By the way, what's up with Messung 1? This isn't a figure and should not be input as one. The output looks very weird.

Also, tables are usually done using far fewer lines. Have a look at modern journal articles.

Code: Select all

\documentclass{scrartcl}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{siunitx}
\newcommand{\tabhead}[1]{\textbf{#1}}
\renewcommand{\tabhead}[1]{#1}
\begin{document}

% ...

\subsubsection{Messung 1, Protokoll: UDP, FPS: 15}

% THIS IS NOW ...
\paragraph{Balkendiagramm}
% ... ABOVE THIS
\begin{center}
\begin{minipage}{\linewidth}
\centering
\includegraphics[width=\textwidth]{example-image-a}
\captionof{figure}{Messung 1: Diagramm}
\end{minipage}
\end{center}

% SAME BEHAVIOUR ...
\paragraph{Durchschnittliche Latenzen}
% ... HERE!
\begin{center}
\begin{minipage}{\linewidth}
\centering
\captionof{table}{Messung 1: Ø-Latenzen}
\begin{tabular}{  l  S  }
\toprule
\tabhead{Latenz} & {\tabhead{\O{} in \si{\milli\second}}} \\
		\midrule
		Round-Trip-Time & 52,85320833 \\
			JPEG-Kompression & 10,492475 \\
			Kodierung: Client & 0,675591667 \\
			Latenz: Client $\rightarrow$  Server & 7,213616667 \\
			Positionserkennung & 4,818333333 \\
			Rendering & 4,818333333 \\
			Kodierung: Server & 5,981666667 \\
			Latenz: Server $\rightarrow$  Client: & 7,608333333 \\
			Zeichnung & 0,347675 \\
			\bottomrule
			\end{tabular}
			\end{minipage}
			\end{center}
			\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
kangaro0
Posts: 3
Joined: Thu Sep 07, 2017 3:01 pm

Figure below Paragraph

Post by kangaro0 »

Oh, I didn't know the positions were case-sensitive. Forgive me for that. :oops:
I tried it out, and it works indeed.

Can you clarify what you mean by 'Messung 1 looks weird?' For me it looks alright, got a screenshot here for you ( with the new design :) ) http://img4host.net/upload/0811241059b261ba4086f.PNG

Thank you for the modern tables example. It looks really good!

The thing is I'm pretty new to latex and just go by what I find on google, maybe the stuff I find is a little bit 'old' and then there is a hundred ways to do one thing in LaTex. So I just stick with the way I did it sometimes before, but sometimes it breaks and then I don't know what to do.
Can you suggest a good book on latex, which is up to date with the way to write modern LaTex?
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Figure below Paragraph

Post by Johannes_B »

It just looks weird.

Code: Select all

Abbildung 22: Messung 1: Diagram
Tabelle 1: Messung 1: Latenzen
A caption should be descriptive. You might have removed the information because it is sensitive, but if not, let me tell you what i can read from that diagram: Nothing. I know it is about Messung 1, but i don't know what that means. I learn it is a diagram, well i can see that. I have absolutely no clue what you measured, since neither the axis, nor the y axis have a label. What you put in the title of the image should go to the caption, the frame should be removed and the bold Balkendiagramm should be removed as well.


Concerning your workflow: You studied the literature with respect to what others have done before you. So you don't have to repeat that research and have it as a base to get new insights. You had to learn how to get data, how to analyse your data. What you should learn now: How to present your data, as this is one of the most important things. Take the time and read an Introduction to LaTeX (<- Link to a free ebook). LaTeX is also able to represent data sets, you can have a look at pgfplots.net to see some examples. All this is based on TikZ, which can represent all kind of informatioin. Have a look at some examples if you want.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply