刪除表格標題和行之間的間隙

刪除表格標題和行之間的間隙

我想消除語言和熟練程度之間的差距。這是使用表格元件產生的,我在刪除標題和行內容之間的大空白時遇到了麻煩。如何才能做到這一點?

在此輸入影像描述

這是用於生成此程式碼的程式碼

% Document class and font size
\documentclass[a4paper,9pt]{extarticle}

% Packages
\usepackage[utf8]{inputenc} % For input encoding
\usepackage{geometry} % For page margins
\geometry{letterpaper, margin=0.75in} % Set paper size and margins
\usepackage{tabularx}

% Formatting
\setlist{noitemsep} % Removes item separation
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}[\titlerule] % Section title format
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip} 

\begin{document}

\section*{LANGUAGES}
\begin{center}
    \noindent
    \begin{tabular*}{0.95\textwidth}{
        @{\extracolsep{\fill}}
        l @{\ ---\ \extracolsep{0pt}} l @{\extracolsep{\fill}}
        l @{\ ---\ \extracolsep{0pt}} l @{\extracolsep{\fill}}
        l @{\ ---\ \extracolsep{0pt}} l
        @{}
        }
        \multicolumn{2}{@{}l}{\textbf{English} (Native)} &
        \multicolumn{2}{@{}l}{\textbf{French}} &
        \multicolumn{2}{@{}l@{}}{\textbf{Polish}} \\[2ex]
        Speaking & \textit{Fluent} & Speaking & \textit{Limited} & Speaking & \textit{Proficient} \\
        Listening & \textit{Fluent} & Listening & \textit{Limited} & Listening & \textit{Proficient} \\
        Reading & \textit{Fluent} & Reading & \textit{Proficient} & Reading & \textit{Limited} \\
        Writing &  \textit{Fluent} & Writing & \textit{Intermediate} & Writing & \textit{Basic} \\
    \end{tabular*}
\end{center}

\end{document}

答案1

  • 若要減少標題規則和環境第一行之間的空白量tanular*,請為 的第四個參數設定較小的值\titlespacing*。在您的程式碼中,這個參數是1\baselineskip;我建議你把它減少到0.75\baselineskip

  • 若要減少環境第一行與第二行之間的空白量tabular*,請\\[2ex]改為\\[0.5ex].

在此輸入影像描述

\documentclass[9pt]{extarticle} % no need for 'a4paper' option

\usepackage{iftex}
\ifpdftex
   %\usepackage[utf8]{inputenc} % that's the default nowadays
   \usepackage[T1]{fontenc} % <-- new
\else
   \usepackage{fontspec}
\fi

\usepackage{geometry} 
\geometry{letterpaper, margin=0.75in} % paper size and margins

%\usepackage{tabularx} % not needed
\usepackage{array} % <-- new
\newcolumntype{L}{>{\itshape}l} % <-- automatic italics

%\usepackage{enumitem} % not needed
%\setlist{noitemsep}   % not needed

\usepackage{titlesec}  % <-- new
\titleformat{\section}{\large\bfseries}{\thesection}{1em}{}[\titlerule] 
\titlespacing*{\section}{0pt}{1\baselineskip}{0.75\baselineskip} 

\begin{document}

\section*{LANGUAGES}

\begin{center}
\setlength\tabcolsep{0pt} % <-- new

\begin{tabular*}{0.95\textwidth}{% why not '1\textwidth'?
   @{\extracolsep{\fill}}
   l @{ --- \extracolsep{0pt}} L 
   @{\extracolsep{\fill}}
   l @{ --- \extracolsep{0pt}} L 
   @{\extracolsep{\fill}}
   l @{ --- \extracolsep{0pt}} L 
}
\multicolumn{2}{l}{\textbf{English} (Native)} &
\multicolumn{2}{l}{\textbf{French}} &
\multicolumn{2}{l}{\textbf{Polish}} \\[0.5ex] % '2ex' is too much
Speaking & Fluent & Speaking & Limited & Speaking & Proficient \\
Listening & Fluent & Listening & Limited & Listening & Proficient \\
Reading & Fluent & Reading & Proficient & Reading & Limited \\
Writing & Fluent & Writing & Intermediate & Writing & Basic \\
\end{tabular*}
\end{center}

\end{document}

相關內容