fix orphaned section headers (needs testing). Closes #10.

This commit is contained in:
David 2021-01-27 15:33:21 +01:00
commit 2e06ec3718
7 changed files with 124 additions and 2 deletions

View file

@ -88,13 +88,13 @@
% frame=L,
emph={cvitem,cventry,cvdoubleentry,cvdoubleitem,moderncvstyle,moderncvcolor,%
cvskill,cvskilllegend,cvskillplainlegend,cvskillhead,cvskillentry,nopagenumbers,%
name,address,email,link,social,phone,homepage,extrainfo,photo,quote},%
name,address,email,link,social,phone,homepage,extrainfo,photo,quote,section,subsection,setlength,NewDocumentCommand},%
emphstyle={\color{cvblue}},%
emph={[2]familydefault,sfdefault,rmdefault,inputenc,moderncv,document,bibliographyitemlabel,%
addresssymbol,mobilephonesymbol,fixedphonesymbol,faxphonesymbol,emailsymbol,homepagesymbol,linkedinsocialsymbol,%
xingsocialsymbol,twittersocialsymbol,githubsocialsymbol,gitlabsocialsymbol,%
stackoverflowsocialsymbol,bitbucketsocialsymbol,skypesocialsymbol,orcidsocialsymbol,researchgatesocialsymbol,%
researcheridsocialsymbol,telegramsocialsymbol,googlescholarsocialsymbol},%
researcheridsocialsymbol,telegramsocialsymbol,googlescholarsocialsymbol,cvstretchability},%
emphstyle={[2]\color{cvblue!60!cvgrey}\bfseries},
}
@ -721,6 +721,52 @@ CV, add the following:%
\end{center}
\end{lstlisting}
\subsubsection{Orphaned sections}
If \latex~ breaks pages just after \code{\\section} or \code{\\subsection} commands, try adjusting
the the stretchability of the page
\begin{lstlisting}
\setlength{\cvstretchability}{<length>},
\end{lstlisting}
for example
\begin{lstlisting}
\setlength{\cvstretchability}{\baselineskip} % or
% \setlength{\cvstretchability}{100pt},
\end{lstlisting}
in the document. It tells \latex that it needs approximately \Code{<length>} extra length after
section and subsection commands.
\paragraph{Experts only:}
Internally a custom needspace command is being used:
\begin{lstlisting}
\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
}
\end{lstlisting}
This means that alternatively to setting \code{\\cvstretchability}, penalties for pagebreaks can be influenced by redefining the internal penalties:
\begin{lstlisting}
% 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
\renewcommand{\withinstretchpenalty}{<-100...9999>}
% must be between -100 and 9999. The higher the less likely a page break will occur.
\renewcommand{\poststretchpenalty}{<-100...9999>}.
\end{lstlisting}
The defaults are \Code{\\poststretchpenalty = 9999} and \Code{\\withinstretchpenalty = 0}.
The penalties must be between -100 and 9999. The higher the value the less likely a page break will occur. A good explanation of this can be found under
\begin{center}
\url{https://tex.stackexchange.com/questions/348994/understanding-needspace}
\end{center}
\section{Implementation details}
\label{section:implementationDetails}