
我希望将文本放置在表格列的顶部。我有以下代码:
\documentclass[a4paper,12pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{makecell} % sauter une ligne dans un tableau
\begin{document}
\begin{table}[H]
\centering
\begin{tabular}{m{2cm} m{13cm}}
Authors:& my name \\
Date:& \today \\
Lecture:& Essentials of advanced astrophysics \\
Lecturer:& my prof \\ \hline \hline
\makecell[l]{Declaration: \\ \\ \\ \\ \\ } & I hereby declare that this thesis is my own work and that I have not used any sources and aids other than those stated in the thesis. I [AGREE/DO NOT AGREE] with making this document available to other students of the course on a password protected website. [PLACE], [DATE][NAME][SIGNATURE]
\end{tabular}
\end{table}
\end{document}
但它向我展示了这一点:
正如您所看到的,声明和我在此并不在同一条线上...有人知道为什么以及如何解决它吗?
答案1
m
键入列将导致文本垂直居中。由于您似乎想使表格中的文本顶部对齐,请使用p
键入列并删除该\makecell
命令。
在以下 MWE 中,我还使用该包包含了表格的第二个版本tabularx
。使用此包,您可以自动将表格的宽度调整为文本宽度(或您选择的其他宽度)。
在以下屏幕截图中,红线表示文本宽度:
\documentclass[a4paper,12pt]{scrreprt}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{makecell} % sauter une ligne dans un tableau
\usepackage{tabularx}
\begin{document}
%\begin{table}[H]
% \centering
\noindent
\begin{tabular}{p{2cm} p{13cm}}
Authors:& my name \\
Date:& \today \\
Lecture:& Essentials of advanced astrophysics \\
Lecturer:& my prof \\ \hline \hline
Declaration: & I hereby declare that this thesis is my own work and that I have not used any sources and aids other than those stated in the thesis. I [AGREE/DO NOT AGREE] with making this document available to other students of the course on a password protected website. [PLACE], [DATE][NAME][SIGNATURE]
\end{tabular}
%\end{table}
\noindent
\begin{tabularx}{\textwidth}{@{} l X @{}}
Authors:& my name \\
Date:& \today \\
Lecture:& Essentials of advanced astrophysics \\
Lecturer:& my prof \\ \hline \hline
Declaration: & I hereby declare that this thesis is my own work and that I have not used any sources and aids other than those stated in the thesis. I [AGREE/DO NOT AGREE] with making this document available to other students of the course on a password protected website. [PLACE], [DATE][NAME][SIGNATURE]
\end{tabularx}
\end{document}