我正在写简历,在合并表格单元格时遇到了问题。该表是在新的 latex 环境“experience”中定义的,写在 modelcv_dbg.cls 文件中,如下所示
\LoadClass{article}
\RequirePackage[T1]{fontenc}
\pagestyle{empty}
\setlength{\tabcolsep}{10pt}
\newenvironment{experience}{%
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}|l|l|}
}{%
\end{tabular*}
}
\newcommand{\experienceitem}[4]{%
#1&\parbox[t]{0.88\textwidth}{%
\textbf{#2}%
\hfill%
{\footnotesize#3}\\%
#4\vspace{\parsep}%
}\\
\midrule
% \multicolumn{2}{|l|}{#4}
}
以下是调用环境体验的示例。
\documentclass[letterpaper]{modelcv_dbg} % a4paper for A4
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*}
\usepackage{array}
\usepackage{booktabs}
\begin{document}
\section{ Professional Experiences}
\begin{experience} % Environment for a list with descriptions
%\experienceitem{<dates>}{<title>}{<location>}{<description>}
\experienceitem{2018-2019}
{phd student.}
{University}
{\emph{tasks} :
\begin{itemize}
\item task 1.
\item task 2.
\end{itemize}
\emph{Publication} : \\
name1, name2, name2;
article title; book.
}
\end{experience}
\end{document}
我将段落“{\emph{task}....}”写入“\experienceitem”命令中定义的表格中的 2 个单元格。我注释和取消注释了一些行(见下文),但出现了运行时错误。
\newcommand{\experienceitem}[4]{%
#1&\parbox[t]{0.88\textwidth}{%
\textbf{#2}%
\hfill%
{\footnotesize#3}\\
% #4\vspace{\parsep}%
}\\
\midrule
\multicolumn{2}{|l|}{#4}
}
我如何合并 \newcommand{\experienceitem} 最后一行的单元格?
答案1
也许你对以下布局更满意:
\documentclass[letterpaper]{article} % a4paper for A4
\usepackage{enumitem}
\setlist[itemize]{leftmargin=*}
\usepackage{array}
\usepackage{booktabs}
\usepackage{calc}
\setlength{\tabcolsep}{10pt}
\newenvironment{experience}{%
\begin{tabular}{|l|l|r|}}
{%
\end{tabular}
}
\newcommand{\experienceitem}[4]{%
#1& \textbf{#2} & {\footnotesize#3}\\%
\multicolumn{3}{|>{\raggedright\arraybackslash}p{\textwidth-2\tabcolsep-2\arrayrulewidth}|}{#4}\\
}
\begin{document}
\section{ Professional Experiences}
\begin{experience} % Environment for a list with descriptions
%\experienceitem{<dates>}{<title>}{<location>}{<description>}
\experienceitem{2018-2019}
{phd student.}
{University}
{\emph{tasks} :
\begin{itemize}
\item task 1.
\item task 2.
\end{itemize}
\emph{Publication} : \newline
name1, name2, name2;
article title; book.}
\end{experience}
\end{document}
旁注:booktabs
包装上的水平线与垂直线不兼容(请参见交叉点处垂直线中的小间隙)。
要删除第三条垂直线,请使用\begin{tabular}{|l|lr|}}
。