LaTeX forum ⇒ Graphics, Figures & TablesFigure in subsection

Information and discussion about graphics, figures & tables in LaTeX documents.
LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am

Figure in subsection

Postby LatexBeginnerrrr » Sun Apr 28, 2019 2:27 am

Hello everyone

I'm new to the LaTeX world (read: I've been trying to use it for 3 hours) and I have come across two problems:

1. Everytime I try to post an image, the caption is like 10 centimeters below it. I have tried a lot of different codes, but nothing seems to work.

2. I'm currently trying to add an image and a table in a subsection, but they always end up above my section. I can't figure out why. This is what i've entered to add the table:
\section{Soorten modellen}
\subsection{Title}
Random text
\\
More random text
\\
\subsection{Title}
Text
\\
Text
\\
\begin{table}[]
\begin{tabular}{|l|l|l|}
\hline
\textbf{Word} & \textbf{Word} & \textbf{Word} \\ \hline
Word & Word & Word \\ \hline
Word & Word & Word \\ \hline
Word & Word & Word \\ \hline
Word & Word & Word \\ \hline
\end{tabular}
\end{table}

The table and image always end up before "Soorten modellen" and I really don't know why.

I hope some of you will be able to help this newbie out. :?

Thank you

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

Postby Johannes_B » Sun Apr 28, 2019 12:45 pm

Welcome to the forum.

Your use of \\ is wrong. Don't use it in normal text or between paragraphs.

A table (similar to a figure) can float. Meaning that LaTeX (the software) can put it to a suitable place. That place might be on top of a page (and in another section).
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Sun Apr 28, 2019 2:43 pm

Your code is missing instructions where the table can be placed. I suggest to use `\begin{table}[htbp]`, this will allow the table to be placed [h]ere, or if there is not enough space to place it here, on [t]op of a page, at the [b]ottom or on a separate [p]age if none of the other solutions worked.

  1. \documentclass{article}
  2.  
  3. \begin{document}
  4. \section{Soorten modellen}
  5. \subsection{Title}
  6. Random text
  7.  
  8. More random text
  9.  
  10. \subsection{Title}
  11. Text
  12.  
  13. Text
  14.  
  15. \begin{table}[htbp]
  16. \begin{tabular}{|l|l|l|}
  17. \hline
  18. \textbf{Word} & \textbf{Word} & \textbf{Word} \\ \hline
  19. Word & Word & Word \\ \hline
  20. Word & Word & Word \\ \hline
  21. Word & Word & Word \\ \hline
  22. Word & Word & Word \\ \hline
  23. \end{tabular}
  24. \end{table}
  25.  
  26. \end{document}

LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am

Postby LatexBeginnerrrr » Tue Apr 30, 2019 12:27 am

Thank you very much! The problems are fixed!

LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am

Postby LatexBeginnerrrr » Tue Apr 30, 2019 2:01 pm

  1. 100\% heeft de afwijking niet.
  2. \newline \newline
  3. \begin{table}[tbph]
  4. \centering
  5. \begin{tabular}{l|l|l}
  6. & a & a \\ \hline
  7. A & Aa & Aa \\ \hline
  8. A & Aa & Aa
  9. \end{tabular}
  10. \end{table}
  11. \newline \newline \noindent
  12. 100\% heeft de afwijking niet.
  13. \newline \newline
  14. Er moet dus ten minste 1 ouder homozygoot zijn voor het dominante allel opdat de kans 0 zou zijn om een kind te krijgen met afwijking. Als beide ouders de afwijking hebben, is de kans 100\% dat het kind deze afwijking ook heeft.

This is the only table that seems to appear on the next page and I have no idea why.
What should I change?

user22741
Posts: 33
Joined: Fri Nov 09, 2018 12:03 pm

Postby user22741 » Tue Apr 30, 2019 2:19 pm

Try `[htbp]` instead.

LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am

Postby LatexBeginnerrrr » Tue Apr 30, 2019 2:45 pm

It still didn't work & still appeared on the next page, while the text below the table appeared on the right page.

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

Postby Johannes_B » Tue Apr 30, 2019 3:39 pm

\newline inside normal text is wrong. What are you trying to achieve?
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

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

Postby Johannes_B » Tue Apr 30, 2019 7:11 pm

By the way,l have you considered replacing the table environment with just center environment?
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 1 guest