Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.
   \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}

I know that i have lots of packages, this is just a part of a bigger file. What i want to avoid is the overlapping of the text in the footer. I want the overlapping content on the next page. I know that samepage could do the job but it doesn't work with the gray header and it only works on parts of the content. For example, the samepage breaks page with all the itemize and keeps the tabular and the header on the previous page. Also, the footer of the content is most of the time alone on the next page and not in the same page of the itemize.

share|improve this question
3  
A minipage can never be split across pages. You probably need the mdframed package. –  egreg Jan 11 '13 at 20:52
    
The thing with mdframed is that the content is always split into the next page. What I want is a frame that if the space is not enough to be on the same page, a page break occurs, then the content can be split into the next page if the content is more than a page. –  Pete Jan 14 '13 at 16:11

2 Answers 2

As egreg said, using mdframed solved a part of my problem.

Here is the code i use to do the trick. The mdframed by default puts lines and the text inside is moved inside. So if I just remove the lines, the text is not aligned properly to the rest of the text.

Another problem is that mdframed always put the text on the next page, so it doesn't do any page breaks.

My original problem is that I want unbreakable blocs that can split into the next page if the content is longer than a page.

\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}
share|improve this answer
    
I have found an alternative : needspace. The only thing about that package is that i need to specify the number of lines that i need before it can do a pagebreak. It's not automatic. That is a problem because inside my bloc, i have paragraphs and i don't want to break them. –  Pete Jan 14 '13 at 22:24
    
I have put another anwser that really helped me do unbreakable blocs. Thanks egreg :) –  Pete Feb 13 '13 at 22:24
up vote 0 down vote accepted

In this question : settototalheight issue with empty lines I have asked a way to calculate the height of any content. It explains how to do it. Also, this is related to this question because if you combine the answers, you can make umbreakable blocs. At first, you prerender the content to calculate the height, then you use that height into the needspace command. The needspace command will do it's job to perform a page break if the space is not enough, then it'll spread across other pages.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.