LaTeX forum ⇒ Graphics, Figures & TablesFigure below Paragraph

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

Figure below Paragraph

Postby kangaro0 » Thu Sep 07, 2017 3:07 pm

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..

  1. \subsubsection{Messung 1, Protokoll: UDP, FPS: 15}
  2.  
  3. % THIS IS BELOW ....
  4. \paragraph{Balkendiagramm}
  5. % ... THIS :/
  6. \begin{figure}[hb!]
  7. \centering
  8. \includegraphics[width=\textwidth]{pictures/latencies/messung1,udp.png}
  9. \caption{Messung 1: Diagramm}
  10. \end{figure}
  11.  
  12. % SAME SITUATION ...
  13. \paragraph{Durchschnittliche Latenzen}
  14. % ... HERE
  15. \begin{table}[h!]
  16. \centering
  17. \begin{tabular}{ | l | l | }
  18. \hline
  19. \textbf{Latenz} & \textbf{Ø in ms} \\
  20. \hline
  21. Round-Trip-Time & 52,85320833 \\
  22. \hline
  23. JPEG-Kompression & 10,492475 \\
  24. \hline
  25. Kodierung: Client & 0,675591667 \\
  26. \hline
  27. Latenz: Client -> Server & 7,213616667 \\
  28. \hline
  29. Positionserkennung & 4,818333333 \\
  30. \hline
  31. Rendering & 4,818333333 \\
  32. \hline
  33. Kodierung: Server & 5,981666667 \\
  34. \hline
  35. Latenz: Server -> Client: & 7,608333333 \\
  36. \hline
  37. Zeichnung & 0,347675 \\
  38. \hline
  39. \end{tabular}
  40. \caption{Messung 1: Ø-Latenzen}
  41. \end{table}


Is there anything I can do to get my code working as expected?

Regards,
kangaro0

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

Postby Johannes_B » Thu Sep 07, 2017 4:28 pm

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

Postby kangaro0 » Thu Sep 07, 2017 4:44 pm

Hey Johannes_B,

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

  1. % NECESSARY IMPORT
  2. \usepackage{capt-of}
  3.  
  4. % ...
  5.  
  6. \subsubsection{Messung 1, Protokoll: UDP, FPS: 15}
  7.  
  8. % THIS IS NOW ...
  9. \paragraph{Balkendiagramm}
  10. % ... ABOVE THIS
  11. \begin{center}
  12. \begin{minipage}{\linewidth}
  13. \centering
  14. \includegraphics[width=\textwidth]{pictures/latencies/messung1,udp.png}
  15. \captionof{figure}{Messung 1: Diagramm}
  16. \end{minipage}
  17. \end{center}
  18.  
  19. % SAME BEHAVIOUR ...
  20. \paragraph{Durchschnittliche Latenzen}
  21. % ... HERE!
  22. \begin{center}
  23. \begin{minipage}{\linewidth}
  24. \centering
  25. \begin{tabular}{ | l | l | }
  26. \hline
  27. \textbf{Latenz} & \textbf{Ø in ms} \\
  28. \hline
  29. Round-Trip-Time & 52,85320833 \\
  30. \hline
  31. JPEG-Kompression & 10,492475 \\
  32. \hline
  33. Kodierung: Client & 0,675591667 \\
  34. \hline
  35. Latenz: Client -> Server & 7,213616667 \\
  36. \hline
  37. Positionserkennung & 4,818333333 \\
  38. \hline
  39. Rendering & 4,818333333 \\
  40. \hline
  41. Kodierung: Server & 5,981666667 \\
  42. \hline
  43. Latenz: Server -> Client: & 7,608333333 \\
  44. \hline
  45. Zeichnung & 0,347675 \\
  46. \hline
  47. \end{tabular}
  48. \captionof{table}{Messung 1: Ø-Latenzen}
  49. \end{minipage}
  50. \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: 3515
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Thu Sep 07, 2017 6:01 pm

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.

  1. \documentclass{scrartcl}
  2. \usepackage{graphicx}
  3. \usepackage{booktabs}
  4. \usepackage{siunitx}
  5. \newcommand{\tabhead}[1]{\textbf{#1}}
  6. \renewcommand{\tabhead}[1]{#1}
  7. \begin{document}
  8.  
  9. % ...
  10.  
  11. \subsubsection{Messung 1, Protokoll: UDP, FPS: 15}
  12.  
  13. % THIS IS NOW ...
  14. \paragraph{Balkendiagramm}
  15. % ... ABOVE THIS
  16. \begin{center}
  17. \begin{minipage}{\linewidth}
  18. \centering
  19. \includegraphics[width=\textwidth]{example-image-a}
  20. \captionof{figure}{Messung 1: Diagramm}
  21. \end{minipage}
  22. \end{center}
  23.  
  24. % SAME BEHAVIOUR ...
  25. \paragraph{Durchschnittliche Latenzen}
  26. % ... HERE!
  27. \begin{center}
  28. \begin{minipage}{\linewidth}
  29. \centering
  30. \captionof{table}{Messung 1: Ø-Latenzen}
  31. \begin{tabular}{ l S }
  32. \toprule
  33. \tabhead{Latenz} & {\tabhead{\O{} in \si{\milli\second}}} \\
  34. \midrule
  35. Round-Trip-Time & 52,85320833 \\
  36. JPEG-Kompression & 10,492475 \\
  37. Kodierung: Client & 0,675591667 \\
  38. Latenz: Client $\rightarrow$ Server & 7,213616667 \\
  39. Positionserkennung & 4,818333333 \\
  40. Rendering & 4,818333333 \\
  41. Kodierung: Server & 5,981666667 \\
  42. Latenz: Server $\rightarrow$ Client: & 7,608333333 \\
  43. Zeichnung & 0,347675 \\
  44. \bottomrule
  45. \end{tabular}
  46. \end{minipage}
  47. \end{center}
  48. \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

Postby kangaro0 » Fri Sep 08, 2017 11:25 am

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: 3515
Joined: Thu Nov 01, 2012 4:08 pm

Postby Johannes_B » Sat Sep 09, 2017 8:56 am

It just looks weird.
  1. Abbildung 22: Messung 1: Diagram
  2. 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.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests