4

I use the splitbib package to create two categories: primary literature and secondary literature. But I want to add in the table of contents an entry for each category, as if they are subsections or something like that. Moreover, I want also to split each category but the first in a new page.

MWE:

\documentclass{article}

\usepackage[nottoc]{tocbibind}
\usepackage[export]{splitbib}

\begin{category}{Primary Literature}
  \SBentries{samplea}
\end{category}

\begin{category}{Secondary Literature}
  \SBentries{sampleb}
\end{category}

\begin{document}
\pagestyle{empty}

\tableofcontents

\begin{thebibliography}{99}

  \bibitem[Sample, A]{samplea} Sample A.

  \bibitem[Sample, B]{sampleb} Sample B.

\end{thebibliography}

\end{document}

Output:

enter image description here

and I want to add in the table of contents, like a subsection, an entry for the category Primary Literature and Secondary Literature, and to split the second category (and third, fourth and so on) in a separated page.

How can be this achieved?

1 Answer 1

3

I suggest a solution similar to that in Forcing new categories in splitbib to start on new pages: Define a new style that resembles the default style bar but adds the appropriate \addcontentsline macro. (Simply adding \addcontentsline immediately before the thebibliography environment is likely to produce wrong page references in the ToC.) Note that splitbib doesn't seem to forbid page breaks between a subbibliography heading and the first entry.

EDIT: Added automatic page break before any but the first subbibliography.

\documentclass{article}

\usepackage[nottoc]{tocbibind}
\usepackage[export]{splitbib}

\newif\ifafterfirstsubbib
\afterfirstsubbibfalse

\makeatletter
\def\NMSB@styletocentrybar#1#2{%
  \ifafterfirstsubbib% NEW
    \clearpage% NEW
  \else% NEW
    \afterfirstsubbibtrue% NEW
  \fi% NEW
  \hskip-\leftmargin%
  \vbox{%
    \medskip\par
    \addcontentsline{toc}{subsection}{#2}% NEW
    \vrule height \SBabovesepwidth depth 0pt width \textwidth
    \vskip.3\baselineskip\par\noindent
    {\null\hfill
      \csname SB\NMSB@level font\endcsname{#1#2}%
      \hfill\null}%
    \vskip-.4\baselineskip\par\noindent
    \vrule height \SBbelowsepwidth depth 0pt width \textwidth}}
\makeatother

\SBtitlestyle{tocentrybar}

\begin{category}{Primary Literature}
  \SBentries{samplea}
\end{category}

\begin{category}{Secondary Literature}
  \SBentries{sampleb}
\end{category}

\begin{document}
\pagestyle{empty}

\tableofcontents

\begin{thebibliography}{99}

  \bibitem[Sample, A]{samplea} Sample A.

  \bibitem[Sample, B]{sampleb} Sample B.

\end{thebibliography}

\end{document}
4
  • The problem in tex.stackexchange.com/questions/70118/… is that a new page for each category is created, included the first category (and thus, the "References" title keeps alone in a separate page).
    – ABu
    Dec 18, 2012 at 11:39
  • @Peregring-lk Just try out my present answer -- first as-is, then remove the line starting with \textheight=200pt.
    – lockstep
    Dec 18, 2012 at 11:40
  • Perhaps, to improve efficiency, you could add an else statement to step the counter only one time, because thereafter isn't important the value of the counter.
    – ABu
    Dec 18, 2012 at 12:15
  • I don't know the command \newif :) I tried with counters and a classical if/else but the yours is far better elegant.
    – ABu
    Dec 18, 2012 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .