3

I am using Tabular to make a simple table. For three columns, my table displayed fine. When I added a fourth column, the horizontal lines stopped reaching all the way across my table. I also have a little bit of horizontal line that sticks out on the left side of the table. What went wrong with my table?

enter image description here

\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill } }  | l | c | c |  c  || }
  \hline 
  \textbf{GENE} &   \textbf{Allele of interest} &  \textbf{Outcomes}   &   \textbf{Dominance}  \\
  \hline \hline  
  MAOA  & 2.5, 3, 5     & Agression     &  Recessive, Sex-selective \\  \hline
  DAT1      & 10R       &  ADHD         & hz. disadvantage          \\  \hline
  DRD4  & 7R        & ADHD      &  -                        \\  \hline
  5-HTT     & 14 (s)    & Negative Thoughts, Fear  & Dominant           \\ \hline
  TRI   & S         & Depression        & Codominant                \\  \hline
  DRD2  & A         & Alcoholism        & Dominant                  \\ \hline
  DRD5  & 148   & ADHD          &  -                        \\  \hline
  S000005 & A       & Stress            & -                         \\ \hline
  S000006 & T       & ADHD          & -                         \\ \hline
  MAOCA1 & 115+     & Alcoholism        & Sex selective             \\ \hline
\end{tabular*}
2
  • 2
    It appears to me, as if the lines are just set to .75\textwidth, while the actual table is much wider. Do you really need this constrain?
    – LaRiFaRi
    Commented Dec 10, 2014 at 6:30
  • 1
    Thanks! The .75\textwidth constraint was not needed. I see that removing that makes the lines go all the way across. But the code below looks much better! I have used LaTex for math homework for years, but am only just starting to use it for papers so the formatting is all new to me. Commented Dec 10, 2014 at 6:54

2 Answers 2

2

If I may, I would recommend to redesign the complete table. The code posted above is much to wide.

% arara: pdflatex

\documentclass{article}
\usepackage{showframe} % for demo that the table fits into the page limits
\usepackage{booktabs}

\begin{document}
\begin{table}
\centering
\caption{the caption}
\begin{tabular}{lp{1.5cm}ll}
    \toprule 
    \textbf{GENE} & \textbf{Allele of interest} & \textbf{Outcomes} & \textbf{Dominance} \\
    \midrule  
    MAOA    & 2.5, 3, 5 & Agression               & Recessive, Sex-selective \\
    DAT1    & 10R       & ADHD                    & hz.\ disadvantage \\
    DRD4    & 7R        & ADHD                    & - \\
    5-HTT   & 14 (s)    & Negative Thoughts, Fear & Dominant \\
    TRI     & S         & Depression              & Codominant \\
    DRD2    & A         & Alcoholism              & Dominant \\
    DRD5    & 148       & ADHD                    & - \\
    S000005 & A         & Stress                  & - \\
    S000006 & T         & ADHD                    & - \\
    MAOCA1  & 115+      & Alcoholism              & Sex selective \\ 
    \bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here


The problem with your table was that the given width of 0.75\textwidth was exceeded by the tables content. The \hlines stopped, where you wanted them to stop, but the text didn't. You will have to reduce the columns width using p{}-columns or use an tabularx instead of the tabular*.

0

To remove the horizontal line that sticks out on the left side of the table, just you need to use only one | not two of them ||

\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill } }  | l | c | c |  c  || }

Thus your code should looks like instead:

\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill } }  | l | c | c |  c  | }
1
  • Welcome to TeX.SX! Please do not post only fragments of code but provide a working example, with a screen shot
    – user31729
    Commented Apr 29, 2015 at 16:46

You must log in to answer this question.

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