diff --git a/manual/moderncv_userguide.tex b/manual/moderncv_userguide.tex index feb6f31..ab0d8c0 100644 --- a/manual/moderncv_userguide.tex +++ b/manual/moderncv_userguide.tex @@ -937,7 +937,7 @@ If \Latex breaks pages just after \code{\\section} or \code{\\subsection} comman \setlength{\cvsubsectionstretchability}{100pt} \end{lstlisting} These two lengths tell \Latex how much extra length it needs after \code{\\section} and \code{\\subsection} commands. -By default, \Moderncv sets both lengths to \code{0.9\\baselineskip}. +By default, \Moderncv sets both lengths to \code{0pt} by default. This should solve orphaned \code{\\section} and \code{\\subsection} commands that are used alone for most users. However, \Latex does not check for content. diff --git a/moderncv.cls b/moderncv.cls index 01bdea7..810e7c6 100644 --- a/moderncv.cls +++ b/moderncv.cls @@ -487,8 +487,8 @@ \@initializelength{\cvsectionstretchability} \@initializelength{\cvsubsectionstretchability} % set the default stretchability. -\setlength{\cvsectionstretchability}{.9\baselineskip} -\setlength{\cvsubsectionstretchability}{.9\baselineskip} +\setlength{\cvsectionstretchability}{0pt} +\setlength{\cvsubsectionstretchability}{0pt} % must be between -100 and 9999. The higher the less likely a page break will occur. % This is where the page break should occur, so this number should not bee too high \NewDocumentCommand\withinstretchpenalty{}{0} diff --git a/moderncvbodyvi.sty b/moderncvbodyvi.sty index 76e1a15..74a5ce9 100644 --- a/moderncvbodyvi.sty +++ b/moderncvbodyvi.sty @@ -79,7 +79,18 @@ \setlength{\baseletterheight}{\baseletterheight-0.95ex} % The optional argument can be used to place a small icon near the section name. % E.g. `\section[\faBookmark]{Education}` +% +% +% leave the stretchability zero by default +% \setlength{\cvsectionstretchability}{0.0pt} +% \setlength{\cvsubsectionstretchability}{0.0pt} +% must be between -100 and 9999. The higher the less likely a page break will occur. +% This is where the page break should occur, so this number should not bee too high +% \RenewDocumentCommand\withinstretchpenalty{}{0} +% must be between -100 and 9999. The higher the less likely a page break will occur. +% \RenewDocumentCommand\poststretchpenalty{}{9999} \RenewDocumentCommand{\section}{sO{}m}{% + \@cvneedspace{\cvsectionstretchability}% avoid orphaned sections \tl@resetchain% \par\addvspace{2.5ex}% \phantomsection{}% reset the anchor for hyperrefs @@ -89,6 +100,7 @@ \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading \RenewDocumentCommand{\subsection}{sm}{% + \@cvneedspace{\cvsubsectionstretchability}% avoid orphaned sections \par\addvspace{1ex}% \phantomsection{}% reset the anchor for hyperrefs \addcontentsline{toc}{subsection}{#2}%