
我正在嘗試利用exam
課程來準備試卷。在第一頁的頂部,需要提供時間、日期和最大分數。為此,我創建了一個tabular
部分,並將其居中,如下面的 MWE 所示。
但是,我希望該線分佈在整個頁面上,並且列之間的間距均勻。我怎樣才能實現這個目標?
\documentclass[12pt,a4paper,addpoints,answers]{exam}
\begin{document}
\begin{center}
\Large \textbf{XXX}\\
\large \textbf{XXX}\\
\textbf{XXX}\\
\textbf{XXX}
\end{center}
\begin{center}
\begin{tabular}{ c c c }
\textbf{Time: 3 Hours} & \textbf{Date: 07.12.2019} & \textbf{Max. Marks: 100}
\end{tabular}
\end{center}
\end{document}
答案1
你想要這樣的東西嗎?
\documentclass[12pt,a4paper,addpoints,answers]{exam}
\begin{document}
\begin{center}
\Large \textbf{XXX}\\
\large \textbf{XXX}\\
\textbf{XXX}\\
\textbf{XXX}
\end{center}
\textbf{Time: 3 Hours} \hfill \textbf{Date: 07.12.2019} \hfill \textbf{Max. Marks: 100}\\
\hrule % or \hrulefill if necessary.
\end{document}
我認為使用表格對於您想要實現的目標來說不是必需的。
答案2
您也可以使用tabular*
and \extracolsep
(無包)。
\documentclass[12pt,a4paper,addpoints,answers]{exam}
\begin{document}
\begin{center}
\Large \textbf{XXX}\\
\large \textbf{XXX}\\
\textbf{XXX}\\
\textbf{XXX}
\end{center}
\begin{center}
\tabcolsep=0pt% visably affects spacing on far right edge
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} c c c }
\textbf{Time: 3 Hours} & \textbf{Date: 07.12.2019} & \textbf{Max. Marks: 100}
\end{tabular*}
\end{center}
\end{document}
答案3
使用 a tabularx
(這樣三列具有相同的寬度):
\documentclass[12pt,a4paper,addpoints,answers]{exam}
\usepackage{tabularx}
\begin{document}
\begin{center}
\Large \textbf{XXX}\\
\large \textbf{XXX}\\
\textbf{XXX}\\
\textbf{XXX}
\end{center}
\begin{tabularx}{\linewidth}{X>{\centering}X>{\raggedleft}X}
\textbf{Time: 3 Hours} & \textbf{Date: 07.12.2019} & \textbf{Max. Marks: 100}
\end{tabularx}
\end{document}
答案4
您希望中間部分位於主標題下方的中心:使左右部分的寬度為零就足夠了。
\documentclass[12pt,a4paper,addpoints,answers]{exam}
\usepackage{showframe} % just for the example
\begin{document}
\begin{center}\bfseries
\Large
XXX
\large
XXX\\
XXX\\
XXX
\normalsize
\bigskip
\makebox[0pt][l]{Time: 3 Hours}\hfill
Date: 07.12.2019\hfill
\makebox[0pt][r]{Max. Marks: 100}
\end{center}
\end{document}
此showframe
套件僅用於顯示文字區塊邊距。