多列宽度问题

多列宽度问题

所以我遇到了这个问题,我有一个多列设置,并且有两列。我指定第一列居中,第二列长 10.5 厘米。我不明白为什么所有三个部分的第二列都没有彼此对齐。

我不确定如何创建一个最小的工作示例 - 这是我的代码:

\documentclass[a4paper,11pt]{article} % Default font size and paper size

\usepackage{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[SmallCapsFont = Fontin SmallCaps]{Fontin} % Main document font

\usepackage{xunicode,xltxtra,url,parskip} % Formatting packages
\usepackage{graphicx,tabularx,lipsum}
\usepackage{fancyhdr}
\usepackage[usenames,dvipsnames]{xcolor} % Required for specifying custom colors
\usepackage[german]{babel}
\usepackage{setspace}

\usepackage[big]{layaureo} % Margin formatting of the A4 page, an alternative to layaureo can be \usepackage{fullpage}
% To reduce the height of the top margin uncomment: \addtolength{\voffset}{-1.3cm}

\usepackage{hyperref} % Required for adding links and customizing them
\definecolor{linkcolour}{rgb}{0,0.2,0.6} % Link color
\hypersetup{colorlinks,breaklinks,urlcolor=linkcolour,linkcolor=linkcolour} % Set link colors throughout the document

\usepackage{titlesec} % Used to customize the \section command
\titleformat{\section}{\Large\scshape\raggedright}{}{0em}{}[\titlerule] % Text formatting of sections
\titlespacing{\section}{0pt}{3pt}{3pt} % Spacing around sections

\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\fancyfoot[R]{{\footnotesize \textit{Stand: \today}}}
\fancyfoot[C]{\thepage}
\pagestyle{fancy}

\begin{document}

%----------------------------------------------------------------------------------------
%   NAME AND CONTACT INFORMATION
%----------------------------------------------------------------------------------------
%\includegraphics[scale=.3]{fd.jpg}
\newlength{\oldparindent} \setlength{\oldparindent}{\parindent}
\setbox0=\hbox{}
\noindent \begin{tabularx}{\textwidth}{@{}Xc@{}}
  \hskip\oldparindent \par{{\Huge My \textsc{Name}}\bigskip\par} {\large Curriculum Vitae} & \raisebox{-\ht0}{\usebox0}% \\
\end{tabularx}
\vskip 40pt

\section{Personal Data}

\begin{tabular}{lp{10.5cm}}
\textsc{born:} & \hspace{0.6cm} Birthday \\
\textsc{Nationality:} & \hspace{0.6cm} Deutsch, US-Amerikanisch\\
\textsc{Family:} & \hspace{0.6cm} Ledig\\
\textsc{Adress:} & \hspace{0.6cm} my street, my postcode, my town\\
\textsc{Telefon:} & \hspace{0.6cm} my phone number\\
\textsc{Mail:} & \hspace{0.6cm} my mail adress\\
\end{tabular}
%----------------------------------------------------------------------------------------
%   EDUCATION
%----------------------------------------------------------------------------------------
\section{Education}
\begin{tabular}{lp{10.5cm}}
\textsc{Okt 2012 - Sep 2015} & Master of Arts\\
& University\\
& \footnotesize{Thesis: "`Title of Thesis"'}\\
\multicolumn{2}{c}{}\\
%------------------------------------------------
\textsc{Okt 2007 - Sep 2011} & Bachelor of Science\\
& University\\
& \footnotesize{Thesis: "`Title of Thesis"'}\\
\multicolumn{2}{c}{}\\
%------------------------------------------------
\textsc{Okt 1995 - Aug 2005} & Highschool\\
& Town of Highscool, City\\
& \footnotesize{Highschool diploma}\\
\multicolumn{2}{c}{}\\
\end{tabular}

%----------------------------------------------------------------------------------------
%   ACADEMIC WORK EXPERIENCE
%----------------------------------------------------------------------------------------
\section{Work Experience}
\begin{tabular}{lp{10.5cm}} 
\textsc{Since Apr 2016} & Research Associate\\
& Institut for Research\\
& \footnotesize{Projekt 1 (LALA): Here I did a lot of things. Like lalala and some more lalala. Here I did a lot of things. Like lalala and some more lalalaHere I did a lot of things. Like lalala and some more lalalaHere I did a lot of things. Like lalala and some more lalalaHere I did a lot of things. Like lalala and some more lalalaHere I did a lot of things. Like lalala and some more lalala}\\
& \footnotesize{Specific tasks: Here I did a lot of things. Like lalala and some more lalalaHere I did a lot of things.}\\[0.5 cm]
& \footnotesize{Projekt 2 (LULU): Here I did a lot of things. Like LULU and some more lululu. Here I did a lot of things. Like LULU and some more lululu.Here I did a lot of things. Like LULU and some more lululu.Here I did a lot of things. Like LULU and some more lululu.Here I did a lot of things. Like LULU and some more lululu.Here I did a lot of things. Like LULU and some more lululu}\\
& \footnotesize{Specific tasks: Here I did a lot of things. Like LULU and some more lululu.Here I did a lot of things.}\\
\multicolumn{2}{c}{}\\
\end{tabular}
\end{document}

答案1

你的问题的答案相当简单。

您定义了一个表

\begin{tabular}{lp{10.5cm}}

这样表格就有两列了。第一列将左对齐,而第二列将两边对齐。

另一个重要的区别是,第二列的宽度固定为 10.5 厘米,但第一列的宽度取决于该表的最长条目。也就是说:在第一个“个人资料”部分中,“国籍”一词显然是第一列中最长的条目。在“教育”部分的第二个表中,每个条目的宽度大致相同。但它们比“国籍”的长度更宽……

您应该为每个部分定义一个类似的表格,使用两个p{width}-columns,以避免出现该问题。我v为您定义了一个 -column。当然,我/您必须关心第一列的宽度。我认为,我猜测的 3cm 有点太窄了。幸运的是,您可以在序言中更改它,它会影响所有这些表格。

您必须加载array-package 才能使用此技巧。

您还应该以这种方式定义表格,即\textsc始终为完整的第一列定义,而不是逐行重复。您可以通过将其定义>{\scshape\selectfont}l为第一列来实现这一点。我在新v列中也这样做了。

最后但并非最不重要的一点是,您可能希望使用\raggedright和之类的命令\raggedleft来操作p-columns。通常这些p-columns 在左侧和右侧对齐,这(尤其是在窄列中)不是一个好主意。您要求第一列的右侧边距齐平,第二列的左侧边距齐平。通过加载 -packageragged2e并使用其\RaggedLeft\RaggedRight-命令,您现在不仅可以在单词之间换行,还可以在单​​词本身中进行换行。

表格单元格内换行时使用一个单词。通常双反斜杠 ( \\) 将开始新的表格行。因此您不能使用它在表格单元格中开始换行。\newline在单元格中使用常规,而不是开始一个完整的新行并将第一列留空。

您不必\\在表格最后一行的末尾指定换行命令 ( )。

如果您想在表格中分隔两行,最好使用\\[height of gap],我删除了您的\multicolumn并将其替换为\\[1.5ex]

另一个印刷提示:德语 Duden 说,您必须使用结尾符号 (--在输入中) 作为“Von-Bis-Strich”。因此,您的条目应输入为October 2016--December 2016(至少对于德语文档而言)。

你的 MWE 可能看起来像这样

\documentclass[a4paper,11pt]{article} % Default font size and paper size
\usepackage[german]{babel}
\usepackage{array}
\usepackage{ragged2e}


%% Define a new columntype, in this case having two columns.
\newcolumntype{v}{@{}
  >{\RaggedLeft\arraybackslash\scshape\selectfont}p{3cm} 
  >{\RaggedRight\arraybackslash}p{10.5cm} @{}}

\begin{document}
\section{Personal Data}

\begin{tabular}{v}
born: &  Birthday \\
Nationality: &  Deutsch, US-Amerikanisch\\
Family: &  Ledig\\
Adress: &  my street, my postcode, my town\\
Telefon: &  my phone number\\
Mail: &  my mail adress
\end{tabular}

\section{Education}
\begin{tabular}{v}
Okt 2012--Sep 2015 & Master of Arts\newline 
                     University\newline 
                     Thesis: "`Title of Thesis"'\\[1.5ex]
Okt 2007--Sep 2011 & Bachelor of Science\newline 
                     University\newline 
                     Thesis: "`Title of Thesis"'\\[1.5ex]
  Okt 1995--Aug 2005 & Highschool\newline
                       Town of Highscool, City\newline
                       Highschool diploma
\end{tabular}
\end{document}

结果将是: enter image description here

相关内容