LaTeX forum ⇒ Graphics, Figures & Tables ⇒ Figure 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

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} \\ \hlineWord & Word & Word \\ \hlineWord & Word & Word \\ \hlineWord & Word & Word \\ \hlineWord & 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

Johannes_B
Site Moderator
Posts: 4004
Joined: Thu Nov 01, 2012 4:08 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
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.

\documentclass{article} \begin{document}\section{Soorten modellen}\subsection{Title}Random text More random text \subsection{Title}Text Text \begin{table}[htbp]\begin{tabular}{|l|l|l|}\hline\textbf{Word} & \textbf{Word} & \textbf{Word} \\ \hlineWord & Word & Word \\ \hlineWord & Word & Word \\ \hlineWord & Word & Word \\ \hlineWord & Word & Word \\ \hline\end{tabular}\end{table} \end{document}

LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am
Thank you very much! The problems are fixed!

LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am
100\% heeft de afwijking niet.\newline \newline\begin{table}[tbph]\centering\begin{tabular}{l|l|l}  & a  & a  \\ \hlineA & Aa & Aa \\ \hlineA & Aa & Aa\end{tabular}\end{table} \newline \newline \noindent100\% heeft de afwijking niet.\newline \newlineEr 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
Try [htbp] instead.

LatexBeginnerrrr
Posts: 8
Joined: Sun Apr 28, 2019 2:15 am
It still didn't work & still appeared on the next page, while the text below the table appeared on the right page.

Johannes_B
Site Moderator
Posts: 4004
Joined: Thu Nov 01, 2012 4:08 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.

Johannes_B
Site Moderator
Posts: 4004
Joined: Thu Nov 01, 2012 4:08 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.