2

I want to put a table under a paragraph, and here are the codes:

\documentclass{article}


\usepackage{ragged2e}
\usepackage{tabularx, makecell}
\setlength{\extrarowheight}{2pt}
\setlength{\tabcolsep}{3pt}%

\begin{document}


\section{Modelling}
We propose a model based on the data described in Chapter 1, with an endpoint and a large number of SNPs. To predict the toxicity, a prediction rule is constructed. We use the maximum likelihood estimator (MLE) and then propose shrinkage estimators to improve the MLE. All shrinkage estimators are formulated in a Bayesian sense. Details on this will follow later.
Important notations used for mathematical convenience are listed in Table \ref{notaion}. Throughout the thesis, the notation $X_i$ represents the \ith SNP, and the notation $X_{ik}, k =1,\ldots,n$, represent the $i$th SNP of the $k$th patient. The endpoint is denoted as $Y$. For conditioning, we will use the symbol "$\mid$". And the probabilities are denoted as "P". 

 \begin{table}
  \FloatBarrier
    \begin{tabular}{l|L{11cm}}
    Symbols  & Description  \\\hline 
    $N$      & The number of SNPs \\ 
    $n$      & The number of patients \\ 
    $X_i$    & $i$th SNP \\ 
    $Y$      & The endpoint  \\
   $\beta_i$   & Effect size for $i$th SNP   \\
    $\mathrm{p}_{i+}$ & The probability of patients having a major allele for $i$th SNP given that              patient experience toxicity \\
  $\mathrm{p}_{i-}$   & The probability of patients having  a minor allele for $i$th SNP given that patient do not experience toxicity \\

   $n_{+}$  &The number of patients experience toxicity \\
   $n_{-}$  &The number of patients do not experience toxicity \\


   $Z_{i+}$ & The number of patient having a major allele for $i$th SNP given that patient             experience toxicity \\
   $Z_{i-}$ & The number of patient having a minor allele for $i$th SNP given that patient do not experience toxicity
   \\\hline
   \end{tabular}
    \caption{List of notations } 
    \label{notaion}
  \end{table}

     \FloatBarrier


\end{document}

However, it displays as

enter image description here

How can I fix the table under the texts?

5
  • 1
  • 1
    in your mwe is missing defined \newcommands as well some package ...
    – Zarko
    Aug 29, 2017 at 20:09
  • In particular, do tell us how the L column type is defined. By the way, judging purely by the screenshot you posted, the tabular environment would appear to be much wider than the text block. Is this something you'd like to fix as well?
    – Mico
    Aug 29, 2017 at 20:13
  • 3
    Using an X column type and the [!htb] optional argument for the table environment, you have what you want without any \FloatBarrier.
    – Bernard
    Aug 29, 2017 at 20:18
  • 1
    the only reason to use a table environment is to allow the table to move to help with page breaking, if the table is part of the text flow and should never move, just use tabular Aug 29, 2017 at 20:27

1 Answer 1

2

I suggest you add [h!] as the placement preference specifier to the table environment. I would also like to suggest that you use a tabularx environment, with X for the second column.

enter image description here

\documentclass{article}
\usepackage{ragged2e,tabularx, makecell}
\setlength{\extrarowheight}{2pt}
\setlength{\tabcolsep}{3pt}%

\begin{document}    

\section{Modelling}
We propose a model based on the data described in Chapter~1, with an endpoint and a large number of SNPs. To predict the toxicity, a prediction rule is constructed. We use the maximum likelihood estimator (MLE) and then propose shrinkage estimators to improve the MLE\@. All shrinkage estimators are formulated in a Bayesian sense. Details on this will follow later.

Important notations used for mathematical convenience are listed in Table~\ref{notaion}. Throughout the thesis, the notation~$X_i$ represents the $i$th~SNP, and the notation $X_{ik}$, $k =1,\ldots,n$, represents the $i$th SNP of the $k$th~patient. The endpoint is denoted by~$Y$. For conditioning, we will use the symbol~$\vert$. Probabilities are denoted by~$p$. 

\begin{table}[h!]
\begin{tabularx}{\textwidth}{@{} l>{\raggedright\arraybackslash}X @{}}
    Symbols  & Description  \\\hline 
    $N$      & Number of SNPs \\ 
    $n$      & Number of patients \\ 
    $X_i$    & $i$th SNP \\ 
    $Y$      & Endpoint  \\
    $\beta_i$& Effect size for $i$th SNP   \\
    $\mathrm{p}_{i+}$ & Probability of patients having a major allele for $i$th SNP given that patient experience toxicity \\
    $\mathrm{p}_{i-}$ & Probability of patients having a minor allele for $i$th SNP given that patient do not experience toxicity \\
    $n_{+}$  & Number of patients who experience toxicity \\
    $n_{-}$  & Number of patients who do not experience toxicity \\
    $Z_{i+}$ & Number of patients having a major allele for $i$th SNP given that patients experience toxicity \\
    $Z_{i-}$ & Number of patients having a minor allele for $i$th SNP given that patients do not experience toxicity
    \\
\end{tabularx}
\caption{List of notations } 
\label{notaion}
\end{table}

\end{document}
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .