mirror of
https://github.com/moderncv/moderncv.git
synced 2026-02-06 10:05:19 +01:00
introduce \cvsectionstretchability and \cvsubsectionstretchability
This commit is contained in:
parent
6a466c547d
commit
3f2cc686dc
6 changed files with 49 additions and 51 deletions
|
|
@ -675,28 +675,18 @@ The labels used in \Code{itemize} environments or the \Moderncv macros \code{cvl
|
||||||
This will leave the definitions of \Code{itemize} environments untouched.
|
This will leave the definitions of \Code{itemize} environments untouched.
|
||||||
\end{itemize}
|
\end{itemize}
|
||||||
|
|
||||||
\subsection{Tips and Tricks}
|
\subsection{Pagebreaks and orphaned section headers}
|
||||||
\subsubsection{Legal disclaimer at the end of CV}
|
\todox{explain things properly}
|
||||||
Some countries (e.g. Italy) require to add the permission to treat the personal data contained in the CV. This can be achieved by the command \code{\\vfill}. At the end of the last entry to your
|
|
||||||
CV, add the following:%
|
|
||||||
\footnote{Example provided by Cristina Sambo} %
|
|
||||||
\begin{lstlisting}
|
|
||||||
\vfill
|
|
||||||
\begin{center}
|
|
||||||
\textit{\small Ai sensi del D. Lgs. 196/2003 ...}
|
|
||||||
\end{center}
|
|
||||||
\end{lstlisting}
|
|
||||||
|
|
||||||
\subsubsection{Orphaned sections}
|
|
||||||
If \latex~ breaks pages just after \code{\\section} or \code{\\subsection} commands, try adjusting
|
If \latex~ breaks pages just after \code{\\section} or \code{\\subsection} commands, try adjusting
|
||||||
the the stretchability of the page
|
the the stretchability of the page
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
\setlength{\cvstretchability}{<length>},
|
\setlength{\cvsectionstretchability}{<length>} %
|
||||||
|
\setlength{\cvsubsectionstretchability}{<length>},
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
for example
|
for example
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
\setlength{\cvstretchability}{\baselineskip} % or
|
\setlength{\cvsectionstretchability}{\baselineskip} % or
|
||||||
% \setlength{\cvstretchability}{100pt},
|
% \setlength{\cvsubsectionstretchability}{100pt},
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
in the document. It tells \latex that it needs approximately \Code{<length>} extra length after
|
in the document. It tells \latex that it needs approximately \Code{<length>} extra length after
|
||||||
section and subsection commands.
|
section and subsection commands.
|
||||||
|
|
@ -717,7 +707,7 @@ Internally a custom needspace command is being used:
|
||||||
\endgroup
|
\endgroup
|
||||||
}
|
}
|
||||||
\end{lstlisting}
|
\end{lstlisting}
|
||||||
This means that alternatively to setting \code{\\cvstretchability}, penalties for pagebreaks can be influenced by redefining the internal penalties:
|
This means that alternatively to setting \Code{\\cvsectionstretchability} and/or \code{\\cvsubsectionstretchability} , penalties for pagebreaks can be influenced by redefining the internal penalties:
|
||||||
\begin{lstlisting}
|
\begin{lstlisting}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% 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
|
% This is where the page break should occur, so this number should not bee too high
|
||||||
|
|
@ -733,6 +723,20 @@ The penalties must be between -100 and 9999. The higher the value the less likel
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
\subsection{Tips and Tricks}
|
||||||
|
\subsubsection{Legal disclaimer at the end of CV}
|
||||||
|
Some countries (e.g. Italy) require to add the permission to treat the personal data contained in the CV. This can be achieved by the command \code{\\vfill}. At the end of the last entry to your
|
||||||
|
CV, add the following:%
|
||||||
|
\footnote{Example provided by Cristina Sambo} %
|
||||||
|
\begin{lstlisting}
|
||||||
|
\vfill
|
||||||
|
\begin{center}
|
||||||
|
\textit{\small Ai sensi del D. Lgs. 196/2003 ...}
|
||||||
|
\end{center}
|
||||||
|
\end{lstlisting}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\section{Implementation details}
|
\section{Implementation details}
|
||||||
\label{section:implementationDetails}
|
\label{section:implementationDetails}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -443,7 +443,10 @@
|
||||||
% custom needspace command to avoid orphaned sections
|
% custom needspace command to avoid orphaned sections
|
||||||
% adapted from the explanations given on
|
% adapted from the explanations given on
|
||||||
% https://tex.stackexchange.com/questions/348994/understanding-needspace
|
% https://tex.stackexchange.com/questions/348994/understanding-needspace
|
||||||
\@initializelength{\cvstretchability}
|
% the stretchabilities are zero by default and are only there to be changed
|
||||||
|
% by the user if needed.
|
||||||
|
\@initializelength{\cvsectionstretchability}
|
||||||
|
\@initializelength{\cvsubsectionstretchability}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% 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
|
% This is where the page break should occur, so this number should not bee too high
|
||||||
\NewDocumentCommand\withinstretchpenalty{}{0}
|
\NewDocumentCommand\withinstretchpenalty{}{0}
|
||||||
|
|
|
||||||
|
|
@ -70,16 +70,16 @@
|
||||||
\settoheight{\baseletterheight}{\sectionstyle{o}}
|
\settoheight{\baseletterheight}{\sectionstyle{o}}
|
||||||
\setlength{\baseletterheight}{\baseletterheight-0.95ex}
|
\setlength{\baseletterheight}{\baseletterheight-0.95ex}
|
||||||
|
|
||||||
% Set \cvstretchability to the height of E for Experience
|
% leave the stretchability zero by default
|
||||||
% \settoheight{\cvstretchability}{\sectionstyle{IT}+10ex}
|
% \setlength{\cvsectionstretchability}{0.0pt}
|
||||||
\setlength{\cvstretchability}{.9\baselineskip}%3\baselineskip
|
% \setlength{\cvsubsectionstretchability}{0.0pt}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% 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
|
% This is where the page break should occur, so this number should not bee too high
|
||||||
\RenewDocumentCommand\withinstretchpenalty{}{0}
|
% \RenewDocumentCommand\withinstretchpenalty{}{0}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
||||||
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
||||||
\RenewDocumentCommand{\section}{sm}{%
|
\RenewDocumentCommand{\section}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsectionstretchability}% avoid orphaned sections
|
||||||
\par\addvspace{2.5ex}%
|
\par\addvspace{2.5ex}%
|
||||||
\phantomsection{}% reset the anchor for hyperrefs
|
\phantomsection{}% reset the anchor for hyperrefs
|
||||||
\addcontentsline{toc}{section}{#2}%
|
\addcontentsline{toc}{section}{#2}%
|
||||||
|
|
@ -87,7 +87,7 @@
|
||||||
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
|
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
|
||||||
|
|
||||||
\RenewDocumentCommand{\subsection}{sm}{%
|
\RenewDocumentCommand{\subsection}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsubsectionstretchability}% avoid orphaned sections
|
||||||
\par\addvspace{1ex}%
|
\par\addvspace{1ex}%
|
||||||
\phantomsection{}% reset the anchor for hyperrefs
|
\phantomsection{}% reset the anchor for hyperrefs
|
||||||
\addcontentsline{toc}{subsection}{#2}%
|
\addcontentsline{toc}{subsection}{#2}%
|
||||||
|
|
|
||||||
|
|
@ -102,19 +102,16 @@
|
||||||
% regular lengths
|
% regular lengths
|
||||||
\setlength{\parskip}{0\p@}}
|
\setlength{\parskip}{0\p@}}
|
||||||
|
|
||||||
\@initializelength{\baseletterheight}
|
% leave the stretchability zero by default
|
||||||
\settoheight{\baseletterheight}{\sectionstyle{o}}
|
% \setlength{\cvsectionstretchability}{0.0pt}
|
||||||
\setlength{\baseletterheight}{\baseletterheight-0.95ex}
|
% \setlength{\cvsubsectionstretchability}{0.0pt}
|
||||||
% Set \cvstretchability to the height of E for Experience
|
|
||||||
% \settoheight{\cvstretchability}{\sectionstyle{E}}
|
|
||||||
\setlength{\cvstretchability}{\baseletterheight}%3\baselineskip
|
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% 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
|
% This is where the page break should occur, so this number should not bee too high
|
||||||
\RenewDocumentCommand\withinstretchpenalty{}{40}
|
% \RenewDocumentCommand\withinstretchpenalty{}{0}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
||||||
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
||||||
\RenewDocumentCommand{\section}{sm}{%
|
\RenewDocumentCommand{\section}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsectionstretchability}% avoid orphaned sections
|
||||||
\par\addvspace{2.5ex}%
|
\par\addvspace{2.5ex}%
|
||||||
\phantomsection{}% reset the anchor for hyperrefs
|
\phantomsection{}% reset the anchor for hyperrefs
|
||||||
\addcontentsline{toc}{section}{#2}%
|
\addcontentsline{toc}{section}{#2}%
|
||||||
|
|
@ -130,7 +127,7 @@
|
||||||
\par\nobreak\addvspace{1ex}\@afterheading}
|
\par\nobreak\addvspace{1ex}\@afterheading}
|
||||||
|
|
||||||
\RenewDocumentCommand{\subsection}{sm}{%
|
\RenewDocumentCommand{\subsection}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsubsectionstretchability}% avoid orphaned sections
|
||||||
\par\addvspace{1ex}%
|
\par\addvspace{1ex}%
|
||||||
\phantomsection{}%
|
\phantomsection{}%
|
||||||
\addcontentsline{toc}{subsection}{#2}%
|
\addcontentsline{toc}{subsection}{#2}%
|
||||||
|
|
|
||||||
|
|
@ -63,19 +63,16 @@
|
||||||
% regular lengths
|
% regular lengths
|
||||||
\setlength{\parskip}{0\p@}}
|
\setlength{\parskip}{0\p@}}
|
||||||
|
|
||||||
\@initializelength{\baseletterheight}
|
% leave the stretchability zero by default
|
||||||
\settoheight{\baseletterheight}{\sectionstyle{o}}
|
% \setlength{\cvsectionstretchability}{0.0pt}
|
||||||
\setlength{\baseletterheight}{\baseletterheight-0.95ex}
|
% \setlength{\cvsubsectionstretchability}{0.0pt}
|
||||||
% Set \cvstretchability to the height of E for Experience
|
|
||||||
% \settoheight{\cvstretchability}{\sectionstyle{E}}
|
|
||||||
\setlength{\cvstretchability}{\baseletterheight}%3\baselineskip
|
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% 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
|
% This is where the page break should occur, so this number should not bee too high
|
||||||
\RenewDocumentCommand\withinstretchpenalty{}{40}
|
% \RenewDocumentCommand\withinstretchpenalty{}{0}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
||||||
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
||||||
\RenewDocumentCommand{\section}{sm}{%
|
\RenewDocumentCommand{\section}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsectionstretchability}% avoid orphaned sections
|
||||||
\par\addvspace{2.5ex}%
|
\par\addvspace{2.5ex}%
|
||||||
\phantomsection{}% reset the anchor for hyperrefs
|
\phantomsection{}% reset the anchor for hyperrefs
|
||||||
\addcontentsline{toc}{section}{#2}%
|
\addcontentsline{toc}{section}{#2}%
|
||||||
|
|
@ -83,7 +80,7 @@
|
||||||
\par\nobreak\addvspace{1ex}\@afterheading}
|
\par\nobreak\addvspace{1ex}\@afterheading}
|
||||||
|
|
||||||
\RenewDocumentCommand{\subsection}{sm}{%
|
\RenewDocumentCommand{\subsection}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsubsectionstretchability}% avoid orphaned sections
|
||||||
\par\addvspace{1ex}%
|
\par\addvspace{1ex}%
|
||||||
\phantomsection{}%
|
\phantomsection{}%
|
||||||
\addcontentsline{toc}{subsection}{#2}%
|
\addcontentsline{toc}{subsection}{#2}%
|
||||||
|
|
|
||||||
|
|
@ -67,21 +67,18 @@
|
||||||
% regular lengths
|
% regular lengths
|
||||||
\setlength{\parskip}{0\p@}}
|
\setlength{\parskip}{0\p@}}
|
||||||
|
|
||||||
\@initializelength{\baseletterheight}
|
% leave the stretchability zero by default
|
||||||
\settoheight{\baseletterheight}{\sectionstyle{o}}
|
% \setlength{\cvsectionstretchability}{0.0pt}
|
||||||
\setlength{\baseletterheight}{\baseletterheight-0.95ex}
|
% \setlength{\cvsubsectionstretchability}{0.0pt}
|
||||||
% Set \cvstretchability to the height of E for Experience
|
|
||||||
% \settoheight{\cvstretchability}{\sectionstyle{E}}
|
|
||||||
\setlength{\cvstretchability}{\baseletterheight}%3\baselineskip
|
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% 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
|
% This is where the page break should occur, so this number should not bee too high
|
||||||
\RenewDocumentCommand\withinstretchpenalty{}{40}
|
% \RenewDocumentCommand\withinstretchpenalty{}{0}
|
||||||
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
% must be between -100 and 9999. The higher the less likely a page break will occur.
|
||||||
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
% \RenewDocumentCommand\poststretchpenalty{}{9999}
|
||||||
|
|
||||||
\@initializeif{\if@aftersection}\@aftersectionfalse%
|
\@initializeif{\if@aftersection}\@aftersectionfalse%
|
||||||
\RenewDocumentCommand{\section}{sm}{%
|
\RenewDocumentCommand{\section}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsectionstretchability}% avoid orphaned sections
|
||||||
\addvspace{2.5ex}%
|
\addvspace{2.5ex}%
|
||||||
\phantomsection{}% reset the anchor for hyperrefs
|
\phantomsection{}% reset the anchor for hyperrefs
|
||||||
\addcontentsline{toc}{section}{#2}%
|
\addcontentsline{toc}{section}{#2}%
|
||||||
|
|
@ -90,7 +87,7 @@
|
||||||
|
|
||||||
%\@initializeif{\if@aftersubsection}\@aftersubsectionfalse%
|
%\@initializeif{\if@aftersubsection}\@aftersubsectionfalse%
|
||||||
\RenewDocumentCommand{\subsection}{sm}{%
|
\RenewDocumentCommand{\subsection}{sm}{%
|
||||||
\@cvneedspace{\cvstretchability}% avoit orphaned sections
|
\@cvneedspace{\cvsubsectionstretchability}% avoid orphaned sections
|
||||||
%\addvspace{1ex}%
|
%\addvspace{1ex}%
|
||||||
\vspace*{-\arrayrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
|
\vspace*{-\arrayrulewidth}% HACK; I don't understand where the space is coming from, nor what it's exact value is :(
|
||||||
\if@aftersection%
|
\if@aftersection%
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue