mirror of
https://github.com/moderncv/moderncv.git
synced 2026-02-06 10:05:19 +01:00
Tweakable orphaned sections - revive old PR (#231)
* introduce different first and lastname styles. * fix orphaned section headers (needs testing). Closes #10. * introduce \cvsectionstretchability and \cvsubsectionstretchability * set default stretchability to 0.9\baselineskip * add fix orphaned section notice to changelog --------- Co-authored-by: David <forenkram@gmx.de>
This commit is contained in:
parent
56d1b65d9e
commit
272289901e
6 changed files with 79 additions and 0 deletions
30
moderncv.cls
30
moderncv.cls
|
|
@ -479,6 +479,36 @@
|
|||
\newcommand*{\@moderncvstrut}[2]{%
|
||||
\rule[-#1]{0pt}{#2}}
|
||||
|
||||
% custom needspace command to avoid orphaned sections
|
||||
% adapted from the explanations given on
|
||||
% https://tex.stackexchange.com/questions/348994/understanding-needspace
|
||||
% the stretchabilities are zero by default and are only there to be changed
|
||||
% by the user if needed.
|
||||
\@initializelength{\cvsectionstretchability}
|
||||
\@initializelength{\cvsubsectionstretchability}
|
||||
% set the default stretchability.
|
||||
\setlength{\cvsectionstretchability}{.9\baselineskip}
|
||||
\setlength{\cvsubsectionstretchability}{.9\baselineskip}
|
||||
% 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}
|
||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
||||
\NewDocumentCommand\poststretchpenalty{}{9999}
|
||||
% command intended to use with section definitions to avoid orphaned sections. (Pagebreak bewteen
|
||||
% \section{} and cv content e.g. \cvitem{}.
|
||||
% usage \@cvneedspace{<length>} preferably \cvneedspace{\cvstretchability} to allow the user
|
||||
% to adapt as needed.
|
||||
\NewDocumentCommand\@cvneedspace{m}{%
|
||||
\begingroup
|
||||
\setlength{\dimen@}{#1}%
|
||||
\vskip\z@\@plus\dimen@
|
||||
\penalty \withinstretchpenalty\vskip\z@\@plus -\dimen@
|
||||
\vskip\dimen@
|
||||
\penalty \poststretchpenalty%
|
||||
\vskip -\dimen@
|
||||
\vskip\z@skip % hide the previous |\vskip| from |\addvspace|
|
||||
\endgroup
|
||||
}
|
||||
|
||||
%-------------------------------------------------------------------------------
|
||||
% resume design commands definitions
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue