
我正在使用 Tabular 製作一個簡單的表格。對於三列,我的表格顯示得很好。當我新增第四列時,水平線不再一直延伸到我的桌子上。我還有一點水平線突出在桌子的左側。我的桌子出了什麼問題?
\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*}
答案1
如果可以的話,我建議重新設計整個表格。上面發布的程式碼太寬了。
% 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}
您的表格的問題是0.75\textwidth
表格內容超出了給定的寬度。他們\hlines
停在了你想讓他們停的地方,但文字卻沒有。您必須使用p{}
-columns 減少列寬或使用tabularx
代替tabular*
.
答案2
要刪除表格左側突出的水平線,只需使用其中的一條|
而不是兩條||
\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill } } | l | c | c | c || }
因此你的程式碼應該看起來像:
\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill } } | l | c | c | c | }