\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[parfill]{parskip}
\usepackage[none]{hyphenat}
\sloppy
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{framed}
\usepackage{tikz}
\usepackage{array,ragged2e}
\usepackage{enumitem}
\usepackage{lipsum}
% ------------------------------------------------------------------------------------
% Fonts
% ------------------------------------------------------------------------------------
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{txfonts}
% ------------------------------------------------------------------------------------
\definecolor{shadecolor}{RGB}{217,217,217} % Color used for highlighting
\definecolor{light-blue}{RGB}{0,175,236} % Color for the footer
% ------------------------------------------------------------------------------------
% Header and footer management.
% ------------------------------------------------------------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
% clear any old style settings
\fancyhf{}
\fancyheadoffset{0in}
\headheight = 53pt
\renewcommand{\headrulewidth}{0pt}
\setmainfont{Calibri}
% ------------------------------------------------------------------------------------
% Defining the section style
\newcommand{\mysectionstyle}[1]{\colorbox{shadecolor}{\begin{tabular}{>{}p{\rectanglelength}}{\fontsize{13}{6}\selectfont\textbf{#1}}\end{tabular}}\vspace{6pt}}
% ------------------------------------------------------------------------------------
\addtolength{\footskip}{0.6cm}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\footrule}{{\color{light-blue}%
\vskip-\footruleskip\vskip-\footrulewidth
\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
% ------------------------------------------------------------------------------------
\usepackage[left=0.75in,top=1.5in,right=0.75in,bottom=1in]{geometry} % Document margins
\usepackage{titlesec}
\newlength{\rectanglelength}
\setlength{\rectanglelength}{\textwidth}
\addtolength{\rectanglelength}{-6pt}
\titlespacing{\paragraph}{%
0pt}{% left margin
0pt}{% space before (vertical)
0pt}% space after (horizontal)
\begin{document}
\lipsum[1]
\begin{minipage}{\textwidth}\setlength{\parskip}{4pt}
%Gray header
\mysectionstyle{Experiences} % Header Section
%Header Content
\begin{tabular}{@{}>{\RaggedRight}p{11cm}>{\RaggedLeft}p{6.35cm}@{}}\fontsize{13}{6}\selectfont{LaTeX}&\textbf{2011 to 2012}\end{tabular}\\\begin{tabular}{@{}>{\RaggedRight}p{11cm}>{\RaggedLeft}p{6.35cm}@{}}\textbf{Lead Programmer}&\textbf{}\end{tabular}
%Content
\vspace{3pt}\begin{itemize}[parsep=0pt, topsep=0pt, itemsep=0pt, leftmargin=2ex]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\end{itemize}
%Footer content
\vspace{7pt}\textbf{End Title} \\\lipsum[1]
\vspace{10pt}
\end{minipage}
\end{document}
我知道我有很多包,这只是一个更大文件的一部分。我想避免的是页脚中的文本重叠。我希望重叠的内容在下一页上。我知道这samepage
可以完成工作,但它不适用于灰色标题,并且只适用于部分内容。例如,分页samepage
包含所有项目,并将表格和标题保留在上一页。此外,内容的页脚大部分时间都单独在下一页上,而不是在项目的同一页上。
答案1
正如 egreg 所说,使用 mdframed 解决了我的一部分问题。
这是我用来完成这个技巧的代码。mdframed 默认会放置线条,并且里面的文本会移到里面。因此,如果我删除线条,文本将无法与其余文本正确对齐。
另一个问题是 mdframed 总是将文本放在下一页,因此它不会进行任何分页。
我原来的问题是,我想要牢不可破的块,如果内容超过一页,它可以拆分到下一页。
\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage[parfill]{parskip}
\usepackage[none]{hyphenat}
\sloppy
\usepackage[usenames,dvipsnames]{xcolor}
\usepackage{framed}
\usepackage{tikz}
\usepackage{array,ragged2e}
\usepackage{enumitem}
\usepackage{lipsum}
\usepackage{mdframed}
% ------------------------------------------------------------------------------------
% Fonts
% ------------------------------------------------------------------------------------
\usepackage{xunicode}
\usepackage{fontspec}
\usepackage{xltxtra}
\usepackage{txfonts}
% ------------------------------------------------------------------------------------
\definecolor{shadecolor}{RGB}{217,217,217} % Color used for highlighting
\definecolor{light-blue}{RGB}{0,175,236} % Color for the footer
% ------------------------------------------------------------------------------------
% Header and footer management.
% ------------------------------------------------------------------------------------
\usepackage{fancyhdr}
\pagestyle{fancy}
% clear any old style settings
\fancyhf{}
\fancyheadoffset{0in}
\headheight = 53pt
\renewcommand{\headrulewidth}{0pt}
\setmainfont{Calibri}
% ------------------------------------------------------------------------------------
% Defining the section style
\newcommand{\mysectionstyle}[1]{\colorbox{shadecolor}{\begin{tabular}{>{}p{\rectanglelength}}{\fontsize{13}{6}\selectfont\textbf{#1}}\end{tabular}}\vspace{6pt}}
% ------------------------------------------------------------------------------------
\addtolength{\footskip}{0.6cm}
\renewcommand{\footrulewidth}{1pt}
\renewcommand{\footrule}{{\color{light-blue}%
\vskip-\footruleskip\vskip-\footrulewidth
\hrule width\headwidth height\footrulewidth\vskip\footruleskip}}
% ------------------------------------------------------------------------------------
\usepackage[left=0.75in,top=1.5in,right=0.75in,bottom=1in]{geometry} % Document margins
\usepackage{titlesec}
\newlength{\rectanglelength}
\setlength{\rectanglelength}{\textwidth}
\addtolength{\rectanglelength}{-6pt}
\global\mdfdefinestyle{myboxstyle}{%
topline=false,rightline=false,bottomline=false,leftline=false,%
leftmargin=-1em,rightmargin=-1em,%
}
\titlespacing{\paragraph}{%
0pt}{% left margin
0pt}{% space before (vertical)
0pt}% space after (horizontal)
\begin{document}
\lipsum[1]
\begin{mdframed}[style=myboxstyle]\setlength{\parskip}{4pt}
\mysectionstyle{Experiences}
\begin{tabular}{@{}>{\RaggedRight}p{11cm}>{\RaggedLeft}p{6.35cm}@{}}\fontsize{13}{6}\selectfont{LaTeX}&\textbf{2011 to 2012}\end{tabular}\\\begin{tabular}{@{}>{\RaggedRight}p{11cm}>{\RaggedLeft}p{6.35cm}@{}}\textbf{Lead Programmer}&\textbf{}\end{tabular}
\vspace{3pt}\begin{itemize}[parsep=0pt, topsep=0pt, itemsep=0pt, leftmargin=2ex]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\item \lipsum[1]\end{itemize}
\vspace{7pt}\textbf{End Title} \\\lipsum[1]
\vspace{10pt}
\end{mdframed}
\end{document}
答案2
在这个问题中:settototalheight 出现空行问题 我问过如何计算任何内容的高度。它解释了如何计算。此外,这与这个问题有关,因为如果你把答案结合起来,你就可以制作出不可分割的块。首先,你预渲染内容来计算高度,然后将该高度用于 needspace 命令。如果空间不够,needspace 命令将执行分页符,然后它将扩展到其他页面。