incorporate comments from the code review on the original PR #57

This commit is contained in:
LLdaniel 2025-02-02 11:51:07 +01:00
commit a4445849d2
3 changed files with 15 additions and 3 deletions

View file

@ -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.

View file

@ -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}

View file

@ -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}%