[Tex/LaTex] Prevent page and column breaks mid bibliography entries in Biblatex/biber

biberbiblatexbibliographiescolumnbreakpage-breaking

Using biblatex and biber is there any way to prevent a page/column break from occurring mid item? The image below shows bibliography items being split both at the end of a column and at the end of the page. I have found that setting block=npar solves the issue, but also reformats the bibliography by inserting line breaks in the individual entries.

How can I protect bibliography entries from page and column breaks within the bibliography?

As you can see entries are split across columns and pages both, neither of which looks particularly good. Moreover, as the image illustrates some issues are also visible after a page break: LaTeX splits a large entry in two across both columns. I would like LaTeX to enter both entries in the same column below one another.

I have included a MWE and an image from my actual work.

\RequirePackage{filecontents} 
 \begin{filecontents}{jobname.bib}
  @article{DoeA,
  title={The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog},
  author={Doe, John and Bar, Foo and Bob, Joe and Kid, Billy The and Lucky, Luke and Kong, King},
  journal={Journal A of supposed excellence and uncomfortably long titles to make this example work. },
  year={2001}
  }
    @article{DoeB,
  title={The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog},
  author={Doe, John and Bar, Foo and Bob, Joe and Kid, Billy The and Lucky, Luke and Kong, King},
  journal={Journal B of supposed excellence and uncomfortably long titles to make this example work. },
  year={2001}
  }
    @article{DoeC,
  title={The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog},
  author={Doe, John and Bar, Foo and Bob, Joe and Kid, Billy The and Lucky, Luke and Kong, King},
  journal={Journal C of supposed excellence and uncomfortably long titles to make this example work. },
  year={2001}
  }

  @article{Genius02,
  title={Title B},
  author={Genius, Evil and Vader, Darth},
  journal={Journal B},
  year={2002}

}
\end{filecontents}
\documentclass[10pt]{article}

\usepackage{multicol}
  \usepackage[left=2.1cm,right=1.4cm,top=23.5cm,bottom=2cm]{geometry}%Etter mal fra npprj


  \usepackage[backend=bibtex]{biblatex}
    \addbibresource{jobname.bib}

\begin{document}
\begin{multicols}{2}
  \nocite{DoeA,DoeB,DoeC,Genius02}

\printbibliography
\end{multicols}
\end{document}

enter image description here

Best Answer

Your problem is that you need to change the values of different penaltys to 10000 (not allowed).

The easierst way to do that is to patch the relevant commands with package etoolbox and the command \patchcmd{\command-to-be-patched}{search-code}{replace-code}{sucess}{failure} (please see the comments!):

\usepackage{etoolbox}  % <============================ to patch penaltys
\patchcmd{\thebibliography}{\clubpenalty4000}{\clubpenalty10000}{}{}     % no orphans
\patchcmd{\thebibliography}{\widowpenalty4000}{\widowpenalty10000}{}{}   % no widows
\patchcmd{\bibsetup}{\interlinepenalty=5000}{\interlinepenalty=10000}{}{} % no break of entry

So with this complete MWE

\RequirePackage{filecontents} 
\begin{filecontents}{\jobname.bib}
@article{DoeA,
  title={The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog},
  author={Doe, John and Bar, Foo and Bob, Joe and Kid, Billy The and Lucky, Luke and Kong, King},
  journal={Journal A of supposed excellence and uncomfortably long titles to make this example work. },
  year={2001},
}
@article{DoeB,
  title={The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog},
  author={Doe, John and Bar, Foo and Bob, Joe and Kid, Billy The and Lucky, Luke and Kong, King},
  journal={Journal B of supposed excellence and uncomfortably long titles to make this example work. },
  year={2001}
}
@article{DoeC,
  title={The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog},
  author={Doe, John and Bar, Foo and Bob, Joe and Kid, Billy The and Lucky, Luke and Kong, King},
  journal={Journal C of supposed excellence and uncomfortably long titles to make this example work. },
  year={2001},
}
@article{Genius02,
  title={Title B},
  author={Genius, Evil and Vader, Darth},
  journal={Journal B},
  year={2002},
}
\end{filecontents}


\documentclass[10pt]{article}

\usepackage{multicol}
\usepackage[left=2.1cm,right=1.4cm,top=23.5cm,bottom=2cm]{geometry}

\usepackage[backend=bibtex]{biblatex}
\addbibresource{\jobname.bib}

\usepackage{showframe} % <========================= to show typing area!
\usepackage{etoolbox}  % <============================ to patch penaltys
\patchcmd{\thebibliography}{\clubpenalty4000}{\clubpenalty10000}{}{}     % no orphans
\patchcmd{\thebibliography}{\widowpenalty4000}{\widowpenalty10000}{}{}   % no widows
\patchcmd{\bibsetup}{\interlinepenalty=5000}{\interlinepenalty=10000}{}{} % no break of entry


\begin{document}
\begin{multicols}{2}
\nocite{DoeA,DoeB,DoeC,Genius02}

\printbibliography
\end{multicols}
\end{document}

you get the following result (I used package showframe to visualise the resulting typing area):

first page of shown pdf

Related Question