我正在尝试排版类似于 friggeri-cv 的简历,但不需要 XeLaTeX。但是,多列环境(第二行)不会将文本拉伸到合并单元格上,而只会拉伸到一个单元格上。我怎样才能让文本拉伸到两个单元格上(即拉伸到整个合并单元格上)?除此之外,虽然单元格宽度指定为 p{1.8cm},但下面的列开始得太早,我需要进行哪些更改才能使其遵守固定的单元格宽度?
% !TEX TS-program = pdflatex
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{parskip}
\usepackage{listliketab}
\pagestyle{empty}
\newcommand{\entry}[4]{%
\begin{listliketab}
\begin{tabularx}{\linewidth}{p{1.8cm}Xr}%
\multirow{2}{*}{\footnotesize #1} & \textbf{#2} & {\footnotesize #3}\\%
& \multicolumn{2}{X}{#4}%
\end{tabularx}
\end{listliketab}
\vspace{\parsep}}
\begin{document}
\section{education}
\entry{Sep 2016 -- present}{Master studies in Witchcraft}{Hogwarts University}{Magical Potions: Theory, Practise and Future Applications}
\entry
{Oct 2013 -- Aug 2016}{Bachelor studies in Wizardry and Magical Phenomena}
{University of Magic South Azkaban}
{Effects of Valerian Root Extract and Dried Dragon Heart Fiber on Soft Tissue of Unsuspecting Muggles}
\end{document}
答案1
尝试:
\documentclass[11pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{parskip}
\usepackage{listliketab}
\usepackage{calc}
\pagestyle{empty}
\newcommand{\entry}[4]{%
\begin{listliketab}
\begin{tabularx}{\linewidth}{p{1.8cm}Xr}%
\multirow{2}{=}{\footnotesize #1} & \textbf{#2} & {\footnotesize #3}\\%
& \multicolumn{2}{p{\linewidth-1.8cm-2\tabcolsep}}{#4}%
\end{tabularx}
\end{listliketab}
\vspace{\parsep}}
\begin{document}
\section{education}
\entry{Sep 2016 -- present}{Master studies in Witchcraft}{Hogwarts University}{Magical Potions: Theory, Practise and Future Applications}
\entry
{Oct 2013 -- Aug 2016}{Bachelor studies in Wizardry and Magical Phenomena}
{University of Magic South Azkaban}
{Effects of Valerian Root Extract and Dried Dragon Heart Fiber on Soft Tissue of Unsuspecting Muggles}
\end{document}
它给:
问题在于在 multicolumn
命令中定义列类型\entry
。您应该使用列类型而不是 X(正如 David Carlisle 在其评论中提到的)。p{<width>}
其宽度可以借助包计算出来calc
。\linewidth-1.8cm-2\tabcolsep
我multirow
建议使用此包最新版本的新功能:选项=
,它将列宽视为multirow
宽度。现在它们的内容显示在两行中。
附录:
考虑到下面的 Bernard 评论,您可以在上面的 MWE 中删除\usepackage{calc}
并将多列单元格更改为
\multirow{2}{=}{\footnotesize #1} & \textbf{#2} & {\footnotesize #3}\\%
& \multicolumn{2}{p{\dimexpr\linewidth-1.8cm-2\tabcolsep}}{#4}%