我需要在硕士申请中提交一份我之前课程的自我评估。我使用了我喜欢的模板,但我无法将其优化为适合 A4 页面的模板。此外,我添加了一列,但是文本不会像其他列一样居中在左侧,也不会居中在右侧。
非常感激任何帮助。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[textwidth=25cm]{geometry}
\usepackage{array, booktabs, multirow}
\begin{document}
\begin{table}
\begin{tabular}{lllrrr} \toprule \toprule
\parbox[t]{5cm}{\textbf{Admission requirements \\ for Economics (MSc)}} & \parbox[t]{4cm}{\textbf{Courses completed}} & \parbox[t]{2cm}{\textbf{Date of \\ completion}} & \textbf{Credits} & \textbf{ECTS} & \parbox[t]{3.8 cm}{\textbf{Degree \\ program}} \\ \midrule
Microeconomics (30 ECTS) & Microeconomics 1 & 22.11.2019 & 6.67& 10 & B.A. Economics, UiO \\
~ & Welfare Economics & 15.02.2013 & 8 & 12 & B.A Economics, SDU \\
~ & Strategy and Markets & 01.07.2015 & 10 & 15 & B.A. Economics, SDU \\
~ & Behavioral Economics & 01.07.2015 & 10 & 15 & B.A. Economics, SDU \\ \midrule
Macroeconomics (30 ECTS) & Macroeconomics 1 & 22.04.2014& 5& 7.5 & B.A. Economics, UiO \\
~ & Macroeconomics 2 & 15.02.2013 & 8 & 12 & B.A. Economics, SDU \\ \midrule
Mathematics (30 ECTS) & Mathematics I & 22.04.2014& 5& 7.5 & B.A. Economics, UiO \\ \midrule
Statistics (30 ECTS) & Statistics 1 & 22.04.2014& 5& 7.5 & B.A. Economics, UiO \\
~ & Regression Analysis & 15.02.2013 & 8 & 12 & B.A. Economics, SDU \\ \midrule \bottomrule
\end{tabular}
\end{table}
\end{document}
答案1
通过对标题进行一些重新排列,可以使表格更加适合。
而不是\parbox
,使用了包\Block
中的命令,它不仅允许在内部使用,还可以将其内容垂直居中跨多行。(对于第一列很有用)。nicematrix
\\
它是仅有的您需要学习的新命令。
\Block{4-1}{Microeconomics \\ (30 ECTS)}
使 4 行 x 1 列的垂直居中单元格与下一列的四行完美对齐。
\Block{}<\bfseries>{Admission \\requirements \\ for Economics \\(MSc)}
注入\bfseries
四线细胞。
如您所见,标题行的所有单元格都垂直居中。
\documentclass[a4paper]{article}
\usepackage[left=2.50cm, right=2.50cm, top=4.00cm, bottom=3.00cm]{geometry}
\usepackage{array, booktabs, multirow}
\usepackage{nicematrix}% added <<<<<<<<<<<<<<<
\usepackage{showframe} % only to show the margins
\begin{document}
\begin{table}
\centering
\begin{NiceTabular}{@{}llcccc@{}}
\toprule \toprule
\Block{}<\bfseries>{Admission \\requirements \\ for Economics \\(MSc)} &
\Block{}<\bfseries>{Courses \\ completed} &
\Block{}<\bfseries>{Date of \\ completion} &
\textbf{Credits} & \textbf{ECTS} &
\Block{}<\bfseries>{Degree program \\ (B.A. Economics) } \\ \midrule
\Block{4-1}{Microeconomics \\ (30 ECTS)}& Microeconomics 1 & 22.11.2019 & 6.67 & 10 & UiO \\
& Welfare Economics & 15.02.2013 & 8 & 12 & SDU \\
& Strategy and Markets & 01.07.2015 & 10 & 15 & SDU \\
& Behavioral Economics & 01.07.2015 & 10 & 15 & SDU \\ \midrule
\Block{2-1}{Macroeconomics \\(30 ECTS)} & Macroeconomics 1 & 22.04.2014 & 5 & 7.5& UiO \\
& Macroeconomics 2 & 15.02.2013 & 8 & 12 & SDU \\ \midrule
\Block{}{Mathematics \\(30 ECTS)} & Mathematics I & 22.04.2014 & 5 & 7.5& UiO \\ \midrule
\Block{2-1}{Statistics \\ (30 ECTS)} & Statistics 1 & 22.04.2014 & 5 & 7.5& UiO \\
& Regression Analysis & 15.02.2013 & 8 & 12 & SDU \\
\midrule \bottomrule
\end{NiceTabular}
\end{table}
\end{document}
答案2
使用该tabularray
包:
\documentclass{article}
\usepackage[margin=25mm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx, varwidth}
\begin{document}
\begin{table}
\begin{tblr}{colspec = {@{} X[1, l, m]
X[l, m]
X[0.6, c]
*{2}{Q[c, si={table-format=2.1}]}
X[c]
@{}},
row{1} = {font=\bfseries, f},
measure = vbox
}
\toprule[2pt]
Admission requirements for Economics (MSc)
& {Courses\\ completed}
& Date of completion
& {{{Credits}}}
& {{{ECTS}}}
& {Degree program\\ (B.A. Economics)} \\
\midrule
\SetCell[r=4]{m} {Microeconomics\\(30 ECTS)}
& Microeconomics 1 & 22.11.2019 & 6.67 & 10 & UiO \\
& Welfare Economics & 15.02.2013 & 8 & 12 & SDU \\
& Strategy and Markets & 01.07.2015 & 10 & 15 & SDU \\
& Behavioral Economics & 01.07.2015 & 10 & 15 & SDU \\ \midrule
\SetCell[r=2]{m} {Macroeconomics\\ (30 ECTS)}
& Macroeconomics 1 & 22.04.2014 & 5 & 7.5 & UiO \\
& Macroeconomics 2 & 15.02.2013 & 8 & 12 & SDU \\
\midrule
{Mathematics\\ (30 ECTS)}
& Mathematics I & 22.04.2014 & 5 & 7.5 & UiO \\
\midrule
\SetCell[r=2]{m} {Statistics\\ (30 ECTS)}
& Statistics 1 & 22.04.2014 & 5 & 7.5 & UiO \\
& Regression Analysis & 15.02.2013 & 8 & 12 & SDU \\
\bottomrule[2pt]
\end{tblr}
\end{table}
\end{document}