![使用 bib 单位强制枚举 \bibitems](https://linux22.com/image/257106/%E4%BD%BF%E7%94%A8%20bib%20%E5%8D%95%E4%BD%8D%E5%BC%BA%E5%88%B6%E6%9E%9A%E4%B8%BE%20%5Cbibitems.png)
我正在编辑我的简历,我想使用该bibunits
包为不同的部分制作单独的迷你书目。以下是一些代码:
\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}
我不知道如何使用,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}}
但是当我输入时\pubs{Journal Papers}{test1,test2,test3}
,我得到的是一个未编号的列表bibitems
。我想要的是编号的参考书目,因此它看起来像:
期刊论文
[1] AD Sarwate,“Foo 棒极了”,食品研究杂志12(3), 2009。
[2] AD Sarwate,“酒吧更好”,IEEE律师学报8(2), 2010。
[3] AD Sarwate,“Baz is meh”,Baz:理论与应用,加利福尼亚州洛杉矶,2011 年 6 月。
并且每个bibunit
都单独编号。我现在看到的编号缺失似乎并没有随着我使用的参考书目样式而改变。有没有办法强制 BibTeX 对每个进行编号bibunit
?
这是个问题吗\nocite
?如果我将命令更改为使用,\cite
则\cite
命令会产生类似的数字,[1-3]
但参考书目仍未编号。
答案1
基于etoolbox
以下的解决方案
\usepackage{etoolbox}
\newcounter{mybibitem}
\AtBeginEnvironment{bibunit}{\setcounter{mybibitem}{0}}
\makeatletter
\AtBeginDocument{
\apptocmd{\@bibitem}{\stepcounter{mybibitem}[\themybibitem] }{}{}}
\makeatother
答案2
将其保存为currvita1.sty
并将其放在与您的cv.tex
(比如说)文件相同的目录中。
%%
%% 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'.
你的cv.tex
文件变成:
\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}