Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using Bibtex and Natbib, does anyone know how to prevent a pagebreak from occurring mid-item?

I would like the bibliography to either:

  • Put an entire record on a given page, or
  • Carry the record over to the following page.

I DONT want the bibliography to:

  • Break a record halfway through the actual record so that part is on one page, and part on the next.

My bibliography has 6+ pages of records, so I am talking about breaks midway through an INDIVIDUAL record, not through the actual bibliography, which is inevitable and perfectly fine.

My bibliography is in a multicol environment, sample to follow:

Output

In the above, you can see that item 186 and 212 are not complete, therefore, would like them to start on the next column and next page respectively.

MWE for the bibliography as follows:

\bibliographystyle{BSTFILE} %my style file.
\newcommand*{\doi}[1]{\href{http://dx.doi.org/\detokenize{#1}}{\raggedright\mybibdoicolor{DOI: \detokenize{#1}}}} %format DOI's
\setlength{\bibsep}{0.0pt} %separation
\def\mybibfontsize{\small} %fontsize
\def\mybibnumbercolor{gray} %define number color
\renewcommand{\bibnumfmt}[1]{\color{\mybibnumbercolor}[\textbf{#1}]}  %change color of number
\addcontentsline{toc}{chapter}{References} %add to toc

\begin{multicols}{2}{
    \mybibfontsize\bibliography{BIBLIOGRAPHY}
}
\end{multicols}
share|improve this question
    
Please provide a complete MWE. –  Harish Kumar Jan 14 '13 at 1:56
    
Ok but not sure if it will help. I am sure what will solve this has to do with the bst file. –  Nicholas Hamilton Jan 14 '13 at 2:14
add comment

2 Answers

up vote 3 down vote accepted

Typically bst files provides definition for the various entry type where the first call is to the function output.bibitem and the last on to the function fin.entry. Thus to wrap whole \bibitems in minipage we can add hooks to such functions. The code below illustrates the changes.

FUNCTION {output.bibitem}
{ newline$
  "\begin{minipage}{\textwidth}" write$
  newline$
  "\bibitem[{" write$
  label write$
  ")" make.full.names duplicate$ short.list =
     { pop$ }
     { * }
   if$
  "}]{" * write$
  cite$ write$
  "}" write$
  newline$
  ""
  before.all 'output.state :=
}

FUNCTION {fin.entry}
{ add.period$
  write$
  newline$
  "\end{minipage}" write$
  newline$
}

We introduced

newline$
"\begin{minipage}{\textwidth}" write$

at the begin of the function output.bibitem and

"\end{minipage}" write$
 newline$

at the end of the function fin.entry.

share|improve this answer
    
This works perfectly. Cheers. –  Nicholas Hamilton Jan 14 '13 at 9:57
    
Thought I might add that in my .bst file, the write.url command came after the fin.entry command a few times in the functions relating to article, book, booklet, inbook etc.... , I just swapped these without issue to ensure the URL's were also included in the minipages. –  Nicholas Hamilton Jan 14 '13 at 10:37
    
Also, because I am working in multicol, needed to change \textwidth with \linewidth. No biggie. –  Nicholas Hamilton Jan 17 '13 at 2:48
add comment

One way to achieve (most of) your objective is to modify the thebibliography environment to disallow typographic widows and orphans. By default, the "widow" and "orphan" (TeX's term: "club") penalty parameters are set to a value of 4000 in bibliography environments. By setting the corresponding parameters to 10000 (the maximum meaningful value for a TeX penalty parameter), you can essentially forbid "widows" and "orphans" from occurring. Incidentally, if you take this approach, I recommend also using the \raggedbottom directive, as otherwise the whitespace between consecutive bib entries may become excessively large.

Note that this approach will prevent page breaks from occurring within bibliography items that span three or fewer lines. It will still permit an entry of four or more lines to be broken across pages -- as long as the first and second part each have at least two lines. This approach seems like a reasonable compromise between (i) wanting to keep the information of each bibliographic contained on one page and (ii) wanting to keep the heights of the text block reasonably uniform across columns and pages. Hopefully, most of your bib entries span three or fewer lines -- and will thus not be broken up anymore across pages and/or columns.

\documentclass{article}
\usepackage{etoolbox}
\patchcmd{\thebibliography}{\clubpenalty4000}{\clubpenalty10000}{}{}
\patchcmd{\thebibliography}{\widowpenalty4000}{\clubpenalty10000}{}{}

% rest of preamble
\begin{document}
% the document itself
\clearpage 
\raggedbottom
\bibliography{<mybibfile(s)>}
\end{document}
share|improve this answer
    
Is this something that would only work with the article class? I am using book class, it doesn't seem to be having any effect –  Nicholas Hamilton Jan 14 '13 at 3:21
    
@ADP - My apologies: there were a couple of typos in the MWE. It should work now. :-) Incidentally, the code should also work with the book and report document classes. –  Mico Jan 14 '13 at 13:05
1  
too bad the \samepage command is obsolete; this seems to me the perfect place to use it. –  barbara beeton Jan 14 '13 at 13:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.