# Allow line breaks but not page breaks

How can I avoid that a \parencite{key} will get broken over 2 pages?

Linebreaking is fine, but page breaking is not. The reason I do not want this is that I have TIKZ customization for citations, which goes wrong with page breaking. Also linking goes (sometimes not always) wrong causing (\pdfendlink ended up in different nesting level than \pdfstartlink)

I can solve this by \mbox{\parencite{key}} but then linebreaking is also not possible.

I can apply this \mbox{\parencite{key}} to only citations which breaks the compilation, however this can vary from time to time (depending on layout), so I am looking for a more generic solution which always work.

Thanks

MWE

\begin{filecontents}{\jobname.bib}
@book{Labov1972,
Author = {William Labov},
Year = {1972}}
}
\end{filecontents}
\documentclass[a4paper]{article}

\usepackage{needspace}
\usepackage[nopar]{lipsum}
\usepackage[backend=bibtex,url=false,backref=true,bibencoding=ascii,firstinits=true,uniquename=init,style=alphabetic,citestyle=authoryear]{biblatex}
\newbox\one
\newbox\two
\long\def\loremlines#1{%
\setbox\one=\vbox { \lipsum }
\setbox\two=\vsplit\one to #1\baselineskip
\unvbox\two}
\begin{document}
\loremlines{46}
\loremlines{1}
\printbibliography
\end{document}


Produces:

• Can you provide an MWE we can play round with? – moewe Dec 16 '15 at 10:31
• I have enhanced my post with MWE – robert Dec 16 '15 at 10:55

You can insert a penalty after the current line with \vadjust (the red example). But this is not fool proof (see the blue pages). E.g. in your example it wouldn't work as on the first and last line of a paragraph \clubpenalty and \windowpenalty can interfere (https://tex.stackexchange.com/a/179917/2388).

\documentclass[a4paper]{article}

\usepackage{needspace}
\usepackage{lipsum,xcolor}
\usepackage[style=authoryear]{biblatex}
\begin{document}
\lipsum[1]
\vspace{26\baselineskip}

\lipsum*[1]
Some famous linguists wrote a couple of books asdasdsad as \parencite{doody}.
\lipsum*[1]

\newpage\color{red}

\lipsum[1]
\vspace{26\baselineskip}

\lipsum*[1]