1

I downloaded a latex template for a CV here https://www.latextemplates.com/template/medium-length-professional-cv

in the cls file it defines a newenvironment rSection that is then used for each section within the CV document. My problem is that sometimes the heading of the section which is provided as input #1 will be followed by a pagebreak. How can I avoid a pagebreak within the newenvironment? I tried simply adding \nopagebreak as well as including a \begin{samepage} but nothing worked. Here is the code that leads to a pagebreak

   \newenvironment{rSection}[1]{ % 1 input argument - section name
      \sectionskip
      \MakeUppercase{\bf #1} % Section title
      \sectionlineskip
      \hrule % Horizontal line
      \begin{list}{}{ % List for each individual item in the section
        \setlength{\leftmargin}{1.5em}% Margin within the section
      }
      \item[]
    }{
      \end{list}
    }

Any help is very much appreciated

1
  • 1
    Welcome to TeX.SE! Well, an short compilable tex code resulting in your issue without personal informations would be very helpful. have you considered to use a more modern template, resume is very old and should not used any longer. Have a look to moderncv, style banking ...
    – Mensch
    Aug 31, 2019 at 13:53

1 Answer 1

1

One way of preventing pagebreaks is to put the rSection environment inside an mdframed box. Normally this is a box with a frame and some margins that breaks between pages, but you can switch off the frame (i.e., color it white), switch off (most of) the margins, and switch off the page breaking.

Partial code:

\documentclass{resume} % Use the custom resume.cls style
\usepackage[left=0.75in,top=0.6in,right=0.75in,bottom=0.6in]{geometry} % Document margins
\usepackage{mdframed}
% Defines the rSection environment for the large sections within the CV
\renewenvironment{rSection}[1]{ % 1 input argument - section name
  %\sectionskip
  \begin{mdframed}[nobreak,linecolor=white,leftmargin=0,rightmargin=0,innerleftmargin=0,innerrightmargin=0,innertopmargin=0,innerbottommargin=0,skipabove=5mm,skipbelow=5mm]
  \MakeUppercase{\bf #1} % Section title
  \sectionlineskip
  \hrule % Horizontal line
  \begin{list}{}{ % List for each individual item in the section
    \setlength{\leftmargin}{1.5em} % Margin within the section
  }
  \item[]
}{
  \end{list}
  \end{mdframed}
}

\name{John Smith} % Your name
\address{123 Broadway \\ City, State 12345} % Your address
\address{123 Pleasant Lane \\ City, State 12345} % Your secondary addess (optional)
\address{(000)~$\cdot$~111~$\cdot$~1111 \\ [email protected]} % Your phone number and email

\begin{document}

Without the mdframed lines:

enter image description here

With mdframed:

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .