
\documentclass[12pt]{article}
\usepackage{tabularx}
\begin{document}
\section{section 1}
\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill} } | c | c | c | r | }
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular*}
\end{document}
並且在生成的結果中,有一些額外的行。為什麼我會看到這些多餘的邊框以及如何刪除它們?
更新:
刪除第一條管道|
沒有幫助:
\documentclass[12pt]{article}
\usepackage{tabularx}
\begin{document}
\section{section 1}
\begin{tabular*}{0.75\textwidth}{@{\extracolsep{\fill} } c | c | c | r | }
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular*}
\end{document}
刪除@{\extracolsep{\fill} }
給了我:
\documentclass[12pt]{article}
\usepackage{tabularx}
\begin{document}
\section{section 1}
\begin{tabular*}{0.75\textwidth}{ | c | c | c | r | }
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular*}
\end{document}
答案1
感謝 AboAmmar,我解決了這個問題:
\documentclass[12pt]{article}
\usepackage{tabularx}
\begin{document}
\section{section 1}
\begin{tabular*}{0.75\textwidth}{ | c @{\extracolsep{\fill} } | c | c | r | }
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular*}
\end{document}
他的另一個建議:
您指定的寬度 (.75\textwidth) 比表格內容寬。使用普通表格並刪除 .75\textwidth
答案2
此 MWE 有兩種可能的方式。第一個以自然的方式適合盒子,第二個將盒子放大到比標準尺寸大 50%。
\documentclass[12pt]{article}
\usepackage{tabularx}
\begin{document}
\section{section 1}
\begin{tabular}{|c|c|c|r|}
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular}
\vspace{5mm}
\scalebox{1.50}{ %scales the box 1.5 times the normal size
\begin{tabular}{|c|c|c|r|}
\hline
label 1 & label 2 & label 3 & label 4 \\
\hline
item 1 & item 2 & item 3 & item 4 \\
\hline
\end{tabular}
}
\end{document}