Natbib-Multibib problem with prefix labels
Here is a way to achieve your result. (I had duplicated your references to check whether the sorting and compression works.)
You have to keep in mind that the natbib
package should be commented till you generate O.bbl
and <filename>.bbl
. That is to load the natbib
package once you generate the bbl
files using bibtex
. Otherwise, the \citation
entries will only write to <filename>.aux
and the O.bbl
will generate with no \bibitem{...}
. This will be kept in your mind in later stage when you edit your main.bib
file.
\documentclass{scrbook}
\usepackage{filecontents}
\begin{filecontents}{main.bib}
@ARTICLE{travis,
author = {Brehm, M. and Kirchner, B.},
title = {TRAVIS - A free Analyzer and Visualizer for Monte Carlo and Molecular
Dynamics Trajectories},
journal = {J. Chem. Inf. Model.},
year = {2011},
volume = {51 (8)},
pages = {2007-2023},
owner = {Brehministrator},
timestamp = {2011.11.27}
},
@ARTICLE{travis1,
author = {Brehm, M. and Kirchner, B.},
title = {TRAVIS - A free Analyzer and Visualizer for Monte Carlo and Molecular
Dynamics Trajectories},
journal = {J. Chem. Inf. Model.},
year = {2011},
volume = {51 (8)},
pages = {2007-2023},
owner = {Brehministrator},
timestamp = {2011.11.27}
},
@ARTICLE{travis2,
author = {Brehm, M. and Kirchner, B.},
title = {TRAVIS - A free Analyzer and Visualizer for Monte Carlo and Molecular
Dynamics Trajectories},
journal = {J. Chem. Inf. Model.},
year = {2011},
volume = {51 (8)},
pages = {2007-2023},
owner = {Brehministrator},
timestamp = {2011.11.27}
},
@ARTICLE{travis3,
author = {Brehm, M. and Kirchner, B.},
title = {TRAVIS - A free Analyzer and Visualizer for Monte Carlo and Molecular
Dynamics Trajectories},
journal = {J. Chem. Inf. Model.},
year = {2011},
volume = {51 (8)},
pages = {2007-2023},
owner = {Brehministrator},
timestamp = {2011.11.27}
},
@ARTICLE{welton2001,
author = {L. Cammarata and S. G. Kazarian and P. A. Salter and T. Welton},
title = {Molecular states of water in room temperature ionic liquids},
journal = {Phys. Chem. Chem. Phys.},
year = {2001},
volume = {3},
pages = {5192-5200},
owner = {Brehministrator},
timestamp = {2011.12.11}
}
@ARTICLE{welton20011,
author = {L. Cammarata and S. G. Kazarian and P. A. Salter and T. Welton},
title = {Molecular states of water in room temperature ionic liquids},
journal = {Phys. Chem. Chem. Phys.},
year = {2001},
volume = {3},
pages = {5192-5200},
owner = {Brehministrator},
timestamp = {2011.12.11}
}
@ARTICLE{welton20012,
author = {L. Cammarata and S. G. Kazarian and P. A. Salter and T. Welton},
title = {Molecular states of water in room temperature ionic liquids},
journal = {Phys. Chem. Chem. Phys.},
year = {2001},
volume = {3},
pages = {5192-5200},
owner = {Brehministrator},
timestamp = {2011.12.11}
}
@ARTICLE{welton20013,
author = {L. Cammarata and S. G. Kazarian and P. A. Salter and T. Welton},
title = {Molecular states of water in room temperature ionic liquids},
journal = {Phys. Chem. Chem. Phys.},
year = {2001},
volume = {3},
pages = {5192-5200},
owner = {Brehministrator},
timestamp = {2011.12.11}
}
}
\end{filecontents}
\usepackage[square,sort&compress,super,comma]{natbib} %%Comment on first run
\usepackage[labeled,resetlabels]{multibib}
\newcites{O}{Own Publications}
\makeatletter
\AtBeginDocument{\@ifpackageloaded{natbib}{%
\expandafter\DeclareRobustCommand\csname cite\@suffix\endcsname
{\begingroup\let\NAT@ctype\z@\NAT@partrue\NAT@swatrue
\@ifstar{\NAT@fulltrue\NAT@cites}{\NAT@fullfalse\csname NAT@cites\@suffix\endcsname}}
\expandafter\newcommand\csname NAT@cites\@suffix\endcsname{\@ifnextchar [{\csname NAT@@citetp\@suffix\endcsname}{%
\ifNAT@numbers\else
\NAT@swafalse
\fi
\csname NAT@@citetp\@suffix\endcsname[]}}
\expandafter\newcommand\csname NAT@citetp\@suffix\endcsname{\@ifnextchar[{\csname NAT@@citetp\@suffix\endcsname}{\csname NAT@@citetp\@suffix\endcsname[]}}
\expandafter\newcommand\csname NAT@@citetp\@suffix\endcsname{}
\expandafter\def\csname NAT@@citetp\@suffix\endcsname[#1]{\@ifnextchar[{\csname @citex\@suffix\endcsname[#1]}{\csname @citex\@suffix\endcsname[][#1]}}
\expandafter\newcommand\csname NAT@set@cites\@suffix\endcsname{%
\ifNAT@numbers
\ifNAT@super \let\@cite\NAT@citesuper
\def\NAT@mbox##1{\unskip\nobreak\textsuperscript{##1}}%
\let\citeyearpar=\citeyear
\let\NAT@space\relax
\def\NAT@super@kern{\kern\p@}%
\else
\let\NAT@mbox=\mbox
\let\@cite\NAT@citenum
\let\NAT@space\NAT@spacechar
\let\NAT@super@kern\relax
\fi
\expandafter\let\csname @citex\@suffix\expandafter\endcsname\csname NAT@citexnum\@suffix\endcsname
\let\@biblabel\NAT@biblabelnum
\let\@bibsetup\NAT@bibsetnum
\renewcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@num\NAT@close}%
\def\natexlab##1{}%
\def\NAT@penalty{\penalty\@m}%
\else
\let\@cite\NAT@cite
\let\@citex\NAT@citex
\let\@biblabel\NAT@biblabel
\let\@bibsetup\NAT@bibsetup
\let\NAT@space\NAT@spacechar
\let\NAT@penalty\@empty
\renewcommand\NAT@idxtxt{\NAT@name\NAT@spacechar\NAT@open\NAT@date\NAT@close}%
\def\natexlab##1{##1}%
\fi}
\expandafter\newcommand\csname NAT@sep\@suffix\endcsname{,\@suffix}
\expandafter\def\csname NAT@separator\@suffix\endcsname{\csname NAT@sep\@suffix\endcsname\NAT@penalty}%
\expandafter\def\csname NAT@def@citea\@suffix\endcsname{\def\@citea{\csname NAT@separator\@suffix\endcsname\NAT@space}}%
\expandafter\def\csname NAT@def@citea@space\@suffix\endcsname{\def\@citea{\csname NAT@separator\@suffix\endcsname\NAT@spacechar}}%
\expandafter\def\csname NAT@def@citea@close\@suffix\endcsname{\def\@citea{\NAT@@close\csname NAT@separator\@suffix\endcsname\NAT@space}}%
\expandafter\def\csname NAT@def@citea@box\@suffix\endcsname{\def\@citea{\NAT@mbox{\NAT@@close}\csname NAT@separator\@suffix\endcsname\NAT@spacechar}}%
\expandafter\def\csname NAT@citexnum\@suffix\endcsname[#1][#2]#3{%
\NAT@reset@parser
\NAT@sort@cites{#3}%
\NAT@reset@citea
\@cite{\def\NAT@num{-1}\let\NAT@last@yr\relax\let\NAT@nm\@empty
\@for\@citeb:=\NAT@cite@list\do
{\@safe@activestrue
\edef\@citeb{\expandafter\@firstofone\@citeb\@empty}%
\@safe@activesfalse
\@ifundefined{b@\@citeb\@extra@b@citeb}{%
{\reset@font\bfseries?}
\NAT@citeundefined\PackageWarning{natbib}%
{Citation `\@citeb' on page \thepage \space undefined}}%
{\let\NAT@last@num\NAT@num\let\NAT@last@nm\NAT@nm
\NAT@parse{\@citeb}%
\ifNAT@longnames\@ifundefined{bv@\@citeb\@extra@b@citeb}{%
\let\NAT@name=\NAT@all@names
\global\@namedef{bv@\@citeb\@extra@b@citeb}{}}{}%
\fi
\ifNAT@full\let\NAT@nm\NAT@all@names\else
\let\NAT@nm\NAT@name\fi
\ifNAT@swa
\@ifnum{\NAT@ctype>\@ne}{%
\@citea
\NAT@hyper@{\@ifnum{\NAT@ctype=\tw@}{\NAT@test{\NAT@ctype}}{\NAT@alias}}%
}{%
\@ifnum{\NAT@cmprs>\z@}{%
\NAT@ifcat@num\NAT@num
{\let\NAT@nm=\NAT@num}%
{\def\NAT@nm{-2}}%
\NAT@ifcat@num\NAT@last@num
{\@tempcnta=\NAT@last@num\relax}%
{\@suffix\@tempcnta\m@ne}%
\@ifnum{\NAT@nm=\@tempcnta}{%
\@ifnum{\NAT@merge>\@ne}{}{\NAT@last@yr@mbox}%
}{%
\advance\@tempcnta by\@ne
\@ifnum{\NAT@nm=\@tempcnta}{%
\ifx\NAT@last@yr\relax
\def@NAT@last@yr{\@citea}%
\else
\def@NAT@last@yr{--\NAT@penalty\@suffix}%
\fi
}{%
\NAT@last@yr@mbox
}%
}%
}{%
\@tempswatrue
\@ifnum{\NAT@merge>\@ne}{\@ifnum{\NAT@last@num=\NAT@num\relax}{\@tempswafalse}{}}{}%
\if@tempswa\NAT@citea@mbox\fi
}%
}%
\csname NAT@def@citea\@suffix\endcsname
\else
\ifcase\NAT@ctype
\ifx\NAT@last@nm\NAT@nm \NAT@yrsep\NAT@penalty\NAT@space\else
\@citea \NAT@test{\@ne}\NAT@spacechar\NAT@mbox{\NAT@super@kern\NAT@@open}%
\fi
\if*#1*\else#1\NAT@spacechar\fi
\NAT@mbox{\NAT@hyper@{{\citenumfont{\NAT@num}}}}%
\csname NAT@def@citea@box\@suffix\endcsname
\or
\csname NAT@hyper@citea@space\@suffix\endcsname{\NAT@test{\NAT@ctype}}%
\or
\csname NAT@hyper@citea@space\@suffix\endcsname{\NAT@test{\NAT@ctype}}%
\or
\csname NAT@hyper@citea@space\@suffix\endcsname\NAT@alias
\fi
\fi
}%
}%
\@ifnum{\NAT@cmprs>\z@}{\NAT@last@yr}{}%
\ifNAT@swa\else
\@ifnum{\NAT@ctype=\z@}{%
\if*#2*\else\NAT@cmt#2\fi
}{}%
\NAT@mbox{\NAT@@close}%
\fi
}{#1}{#2}%
}%
\csname NAT@set@cites\@suffix\endcsname
}{}
\def\mycite{\csname cite\@suffix\endcsname}
}%
\makeatother
\begin{document}
\chapter{Introduction}
Citing my own literature\mycite{travis} and\mycite{travis,travis3} and\mycite[p.~1]{travis,travis3,travis2,travis1} and\mycite{travis,travis3,travis1}
Citing other people's literature\cite{welton2001} and\cite{welton2001,welton20013} and\cite[p.~1]{welton2001,welton20013,welton20012,welton20011} and\cite{welton2001,welton20013,welton20011}.
\appendix
\bibliographystyle{plain}
\bibliographystyleO{plain}
\bibliography{main}
\bibliographyO{main}
\end{document}
The macros which are defined between \makeatletter
and \makeatother
are taken from natbib
package.
The output will look like: