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.

I'm editing my CV and I wanted to use the bibunits package to make separate mini-bibliographies for different sections. Here is some code:

\documentclass{article}

\usepackage[ManyBibs]{currvita}
\usepackage{bibunits}
\usepackage[pdfborder={0 0 0},breaklinks]{hyperref}
\usepackage{filecontents}

\defaultbibliography{test}
\defaultbibliographystyle{acm}

\newenvironment{cvseclist}[1]
{\phantomsection
\addcontentsline{toc}{section}{\sc #1}%
\begin{cvlist}{\sc #1}}
{\end{cvlist}}

\newcommand\multilinelabel[1]{%
\smash{\parbox[t]{\cvlabelwidth}{\raggedright #1}}%
}

\makeatletter
\newcommand*\pubs[2]{%
\item[\sc \multilinelabel{#1}]
\begin{bibunit}%
    \nocite{#2}%
    \putbib
\end{bibunit}%
\IfFileExists{\@bibunitname.bbl}{}{Run \texttt{bibtex
\@bibunitname}}%
}
\makeatother

\begin{document}

\begin{cv}{Anand D. Sarwate \hfill Curriculum Vit\ae}


\begin{cvseclist}{Publications}
\pubs{Journal Papers}{test1,test2,test3}
\end{cvseclist}

\end{cv}
\end{document}

I couldn't figure out how to use filecontents so it is faster to provide test.bib here:

@article{test3,
Author = {A. D. Sarwate},
Journal = {Baz : Theory and Applications},
Number = {1},
Title = {Baz is meh},
Volume = {1},
Year = {2011}}

@article{test2,
Author = {A. D. Sarwate},
Journal = {IEEE Transactions on Bar},
Number = {2},
Title = {Bar is better},
Volume = {8},
Year = {2010}}

@article{test1,
Author = {A. D. Sarwate},
Journal = {Journal of Foo Studies},
Number = {3},
Title = {Foo is awesome},
Volume = {12},
Year = {2009}}

But when I put in \pubs{Journal Papers}{test1,test2,test3}, I get an unnumbered list of bibitems. What I want is a numbered bibliography, so that it looks something like:

Journal Papers

[1] A.D. Sarwate, "Foo is awesome", Journal of Foo Studies 12(3), 2009.

[2] A.D. Sarwate, "Bar is better", IEEE Transactions on Bar 8(2), 2010.

[3] A.D. Sarwate, "Baz is meh", Baz : Theory and Applications, Los Angeles, CA, June 2011.

and each bibunit is independently numbered. The lack of numbering I see now seems to not change with the bibliography style I use. Is there a way to force BibTeX to number each bibunit?

Is this a problem with \nocite? If I change the command to use \cite then the \cite command produces numbers like [1-3] but the bibliography remains unnumbered.

share|improve this question
1  
Please change your given code to an complete minimal working example (MWE) and include the bib file with the package filecontents in your MWE. I tried your snippet and had no problems ... –  Kurt Oct 18 '12 at 2:37
    
I tried the snippet as well, an it works. –  Guido Oct 18 '12 at 7:14
    
I am not sure how to use filecontents but I will edit the above with a minimal (to me) example -- the problem may be with the interaction of commands. –  Anand Sarwate Oct 22 '12 at 20:20
add comment

2 Answers 2

up vote 2 down vote accepted

A solution based on etoolbox is the following

\usepackage{etoolbox}
\newcounter{mybibitem}
\AtBeginEnvironment{bibunit}{\setcounter{mybibitem}{0}}
\makeatletter
\AtBeginDocument{
\apptocmd{\@bibitem}{\stepcounter{mybibitem}[\themybibitem] }{}{}}
\makeatother
share|improve this answer
    
Sorry to delay, but this worked like a charm! –  Anand Sarwate Nov 3 '12 at 0:12
    
@AnandSarwate glad it helped. –  Guido Nov 3 '12 at 9:50
add comment

Save this as currvita1.sty and put it in the same directory as your cv.tex (say) file.

%%
%% This is file `currvita1.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% currvita.dtx  (with options: `package')
%%
%% LaTeX package for a curriculum vitae
%%
%% Copyright (C) 1999 Axel Reichert
%% See the files README and COPYING.
%%
%% \CharacterTable
%%   {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}[1996/12/01]%
\ProvidesPackage{currvita1}[%
  1999/09/13 v0.9i Typesetting a Curriculum Vitae%
]%
\RequirePackage{ifthen}%
\newcommand*{\@cvplace}{\@empty}%
\newsavebox{\@cvlistheading}%
\newlength{\cvlabelsep}%
\newlength{\cvlabelskip}%
\newlength{\cvlabelwidth}%
\newboolean{cv@many@bibs}%
\newboolean{cv@no@date}%
\newboolean{cv@open@bib}%
\DeclareOption{LabelsAligned}{%
  \setlength{\cvlabelskip}{0ex}%
}%
\DeclareOption{TextAligned}{%
  \setlength{\cvlabelskip}{%
    1.5\baselineskip plus 3pt minus 3pt%
  }%
}%
\DeclareOption{openbib}{%
  \@ifundefined{bibindent}{%
    \newlength{\bibindent}%
  }{}%
  \setlength{\bibindent}{1.5em}%
  \setboolean{cv@open@bib}{true}%
}%
\DeclareOption{ManyBibs}{%
  \setboolean{cv@many@bibs}{true}%
}%
\DeclareOption{NoDate}{%
  \setboolean{cv@no@date}{true}%
}%
\ExecuteOptions{TextAligned}%
\ProcessOptions*%
\AtBeginDocument{%
  \setlength{\cvlabelsep}{1em}%
  \settowidth{\cvlabelwidth}{%
    \cvlabelfont 88/8888--88/8888%
  }%
}%
\DeclareRobustCommand*{\cvheadingfont}{\bfseries\Large}%
\DeclareRobustCommand*{\cvbibname}{Publications}%
\DeclareRobustCommand*{\cvplace}[1]{%
  \gdef\@cvplace{#1}%
}%
\providecommand*{\date}[1]{\gdef\@date{#1}}%
\newenvironment{cv}[1]{%
  \ifthenelse{\equal{#1}{\@empty}}{%
  }{%
    {%
      \noindent\cvheadingfont#1\par\nopagebreak
    }%
  }%
  \ifthenelse{\boolean{cv@many@bibs}}{%
    \DeclareRobustCommand*{\@biblabel}[1]{[##1]}%
  }{}%
  \providecommand{\newblock}{%
    \hspace{0.11em plus 0.33em minus 0.07em}%
  }%
  \long\def\thebibliography##1{%
    \ifthenelse{\boolean{cv@many@bibs}}{%
    }{%
      {%
        \noindent\cvlistheadingfont\cvbibname
        \par\nopagebreak
      }%
    }%
    \ifthenelse{\boolean{cv@open@bib}}{%
      \renewcommand{\newblock}{\par}%
    }{}%
    \begin{list}{\@biblabel{\@arabic\c@enumiv}}{%
      \setlength{\parsep}{0ex}%
      \setlength{\itemsep}{%
        0.5\baselineskip plus 1pt minus 1pt%
      }%
      \setlength{\topsep}{0ex}%
      \setlength{\partopsep}{0ex}%
      \ifthenelse{\boolean{cv@many@bibs}}{%
        \setlength{\labelsep}{.8em}%
      }{}%
      \settowidth{\labelwidth}{\@biblabel{##1}}%
      \setlength{\leftmargin}{\labelwidth}%
      \addtolength{\leftmargin}{\labelsep}%
      \ifthenelse{\boolean{cv@open@bib}}{%
        \addtolength{\leftmargin}{\bibindent}%
        \setlength{\itemindent}{-\bibindent}%
        \setlength{\listparindent}{\itemindent}%
      }{}%
      \usecounter{enumiv}%
      \let\p@enumiv\@empty
      \renewcommand*{\theenumiv}{\@arabic\c@enumiv}%
    }%
    \sloppy
    \clubpenalty4000%
    \@clubpenalty\clubpenalty
    \widowpenalty4000%
    \sfcode`\.=\@m
  }%
  \long\def\endthebibliography{%
    \renewcommand*{\@noitemerr}{%
      \@latex@warning{Empty `thebibliography' environment}%
    }%
    \end{list}%
  }%
}{%
  \vspace{1.333\baselineskip plus 3pt minus 3pt}%
  \ifthenelse{\equal{\@cvplace}{\@empty}}{%
  }{%
    \noindent
    \@cvplace
    \ifthenelse{\boolean{cv@no@date}}{}{%
      ,~%
    }%
  }%
  \ifthenelse{\boolean{cv@no@date}}{}{%
    \@date
  }%
  \par\noindent\ignorespacesafterend
}%
\DeclareRobustCommand*{\cvlistheadingfont}{%
  \bfseries\large
}%
\DeclareRobustCommand*{\cvlabelfont}{%
  \normalsize
}%
\newenvironment{cvlist}[1]{%
  \sbox{\@cvlistheading}{\cvlistheadingfont#1}%
  \begin{list}{}{%
      \renewcommand*{\makelabel}[1]{%
        \settowidth{\@tempdima}{\usebox{\@cvlistheading}}%
        \ifthenelse{\lengthtest{\@tempdima > 0pt}}{%
          \settowidth{\@tempdimb}{\cvlabelfont##1}%
          \ifthenelse{%
            \lengthtest{\@tempdima < \cvlabelwidth} \and
            \lengthtest{\@tempdimb = 0pt}}{%
            \parbox[b]{\cvlabelwidth}{%
              \vspace{\cvlabelskip}%
              \makebox[\cvlabelwidth][l]{%
                \box\@cvlistheading
              }%
            }%
          }{%
            \parbox[b]{0pt}{%
              \makebox[0pt][l]{\box\@cvlistheading}%
              \\*[0.5\baselineskip plus 1pt minus 1pt]%
            }%
          }%
        }{}%
        \cvlabelfont##1\hfill
      }%
      \setlength{\itemsep}{0ex}%
      \setlength{\parsep}{%
        0.5\baselineskip plus 1pt minus 1pt%
      }%
      \setlength{\topsep}{%
        1\baselineskip plus 2pt minus 2pt%
      }%
      \setlength{\partopsep}{0ex}%
      \setlength{\labelsep}{\cvlabelsep}%
      \setlength{\labelwidth}{\cvlabelwidth}%
      \setlength{\leftmargin}{\cvlabelwidth}%
      \addtolength{\leftmargin}{\cvlabelsep}%
    }%
}{%
  \end{list}%
}%
\endinput
%%
%% End of file `currvita1.sty'.

And your cv.tex file becomes:

\documentclass{article}    
\usepackage[ManyBibs]{currvita1} %% note the change from currvita
\usepackage{bibunits}
\usepackage[pdfborder={0 0 0},breaklinks]{hyperref}
\usepackage{filecontents}
\begin{filecontents*}{test.bib}
 @article{test3,
Author = {A. D. Sarwate},
Journal = {Baz : Theory and Applications},
Number = {1},
Title = {Baz is meh},
Volume = {1},
Year = {2011}}

@article{test2,
Author = {A. D. Sarwate},
Journal = {IEEE Transactions on Bar},
Number = {2},
Title = {Bar is better},
Volume = {8},
Year = {2010}}

@article{test1,
Author = {A. D. Sarwate},
Journal = {Journal of Foo Studies},
Number = {3},
Title = {Foo is awesome},
Volume = {12},
Year = {2009}}
\end{filecontents*}

\makeatletter

\makeatother
\defaultbibliography{test}
\defaultbibliographystyle{acm}

\newenvironment{cvseclist}[1]
{\phantomsection
\addcontentsline{toc}{section}{\sc #1}%
\begin{cvlist}{\sc #1}}
{\end{cvlist}}

\newcommand\multilinelabel[1]{%
\smash{\parbox[t]{\cvlabelwidth}{\raggedright #1}}%
}

\makeatletter
\newcommand*\pubs[2]{%
\item[\sc \multilinelabel{#1}]
\begin{bibunit}%%[plain]%
    \nocite{#2}%
    \putbib%%[test]
\end{bibunit}%
\IfFileExists{\@bibunitname.bbl}{}{\immediate\write18 {bibtex    %%% changed here
\@bibunitname}}%
}%
\makeatother

\begin{document}

\begin{cv}{Anand D. Sarwate \hfill Curriculum Vit\ae}
\begin{cvseclist}{Publications}
\pubs{Journal Papers}{test1,test2}
\pubs{Conference Papers}{test3}
\end{cvseclist}
\end{cv}
\end{document}

enter image description here

share|improve this answer
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.