Multiple Reference Citation in order of appearance without Bibtex
up vote
0
down vote
favorite
This question is related to a question I asked earlier here. I wanted to cite references in order of appearance without Bibtex and the answer did exactly that. However, consider I have the following bibliography:
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
The code cite{ref2} and cite{ref3, ref4, ref5}
will give [1] and [2,3,4]
and what I want is [1] and [2-4]
instead. How can I alter the code given in the previous answer? Note that using usepackage{cite}
will output [1] and [4-6]
which is not in the order of appearance.
bibliographies
add a comment |
up vote
0
down vote
favorite
This question is related to a question I asked earlier here. I wanted to cite references in order of appearance without Bibtex and the answer did exactly that. However, consider I have the following bibliography:
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
The code cite{ref2} and cite{ref3, ref4, ref5}
will give [1] and [2,3,4]
and what I want is [1] and [2-4]
instead. How can I alter the code given in the previous answer? Note that using usepackage{cite}
will output [1] and [4-6]
which is not in the order of appearance.
bibliographies
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question is related to a question I asked earlier here. I wanted to cite references in order of appearance without Bibtex and the answer did exactly that. However, consider I have the following bibliography:
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
The code cite{ref2} and cite{ref3, ref4, ref5}
will give [1] and [2,3,4]
and what I want is [1] and [2-4]
instead. How can I alter the code given in the previous answer? Note that using usepackage{cite}
will output [1] and [4-6]
which is not in the order of appearance.
bibliographies
This question is related to a question I asked earlier here. I wanted to cite references in order of appearance without Bibtex and the answer did exactly that. However, consider I have the following bibliography:
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
The code cite{ref2} and cite{ref3, ref4, ref5}
will give [1] and [2,3,4]
and what I want is [1] and [2-4]
instead. How can I alter the code given in the previous answer? Note that using usepackage{cite}
will output [1] and [4-6]
which is not in the order of appearance.
bibliographies
bibliographies
asked 12 hours ago


Lod
222
222
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
The implementation in Sorting bibliography in order of appearance without Bibtex naively assumed that the argument of citation
is always only a single key. That is a valid assumption for the standard implementation of cite
, but not for the implementation of cite
's cite
.
The following simple extension should also deal with comma-separated lists. The only difference is the introduction of a CSV loop in citation
and the resulting move of the core of the macro to citation@i
.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{cite}
usepackage{etoolbox}
usepackage{hyperref}
makeatletter
newcommand*{lodbib@citeorder}{}
newcommand*{lodbib@notcited}{}% catch entries that were not cited
% macro in aux file
defcitation{%
forcsvlist{citation@i}}
defcitation@i#1{%
ifinlist{#1}{lodbib@citeorder}
{}
{listxadd{lodbib@citeorder}{#1}}}
letltxorig@lbibitem@lbibitem
letltxorig@bibitem@bibitem
% save bibitems
def@lbibitem[#1]#2#3{%
csdef{lodbib@savedlabel@#2}{#1}%
@bibitem{#2}{#3}}
def@bibitem#1#2{%
xifinlist{#1}{lodbib@citeorder}
{}
{listadd{lodbib@notcited}{#1}}%
csdef{lodbib@savedentry@#1}{#2}}
renewenvironment{thebibliography}[1]
{settowidthlabelwidth{@biblabel{#1}}}
{def@noitemerr
{@latex@warning{Empty `thebibliography' environment}}%
section*{refname}%
@mkboth{MakeUppercaserefname}{MakeUppercaserefname}%
list{@biblabel{@arabicc@enumiv}}%
{leftmarginlabelwidth
advanceleftmarginlabelsep
@openbib@code
usecounter{enumiv}%
letp@enumiv@empty
renewcommandtheenumiv{@arabicc@enumiv}}%
sloppy
clubpenalty4000
@clubpenalty clubpenalty
widowpenalty4000%
sfcode`.@m
lodbib@biblistloop
endlist}
deflodbib@biblistloop{%
forlistloop{lodbib@bibitem}{lodbib@citeorder}%
ifdefvoid{lodbib@notcited}
{}
{forlistloop{lodbib@bibitem}{lodbib@notcited}}}
deflodbib@bibitem#1{%
ifcsundef{lodbib@savedlabel@#1}
{ltxorig@bibitem{#1}}
{ltxorig@lbibitem[csuse{lodbib@savedlabel@#1}]{#1}}%
csuse{lodbib@savedentry@#1}}
makeatother
begin{document}
cite{ref2} and cite{ref3, ref4, ref5}
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
cite{ref2}
end{document}
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
The implementation in Sorting bibliography in order of appearance without Bibtex naively assumed that the argument of citation
is always only a single key. That is a valid assumption for the standard implementation of cite
, but not for the implementation of cite
's cite
.
The following simple extension should also deal with comma-separated lists. The only difference is the introduction of a CSV loop in citation
and the resulting move of the core of the macro to citation@i
.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{cite}
usepackage{etoolbox}
usepackage{hyperref}
makeatletter
newcommand*{lodbib@citeorder}{}
newcommand*{lodbib@notcited}{}% catch entries that were not cited
% macro in aux file
defcitation{%
forcsvlist{citation@i}}
defcitation@i#1{%
ifinlist{#1}{lodbib@citeorder}
{}
{listxadd{lodbib@citeorder}{#1}}}
letltxorig@lbibitem@lbibitem
letltxorig@bibitem@bibitem
% save bibitems
def@lbibitem[#1]#2#3{%
csdef{lodbib@savedlabel@#2}{#1}%
@bibitem{#2}{#3}}
def@bibitem#1#2{%
xifinlist{#1}{lodbib@citeorder}
{}
{listadd{lodbib@notcited}{#1}}%
csdef{lodbib@savedentry@#1}{#2}}
renewenvironment{thebibliography}[1]
{settowidthlabelwidth{@biblabel{#1}}}
{def@noitemerr
{@latex@warning{Empty `thebibliography' environment}}%
section*{refname}%
@mkboth{MakeUppercaserefname}{MakeUppercaserefname}%
list{@biblabel{@arabicc@enumiv}}%
{leftmarginlabelwidth
advanceleftmarginlabelsep
@openbib@code
usecounter{enumiv}%
letp@enumiv@empty
renewcommandtheenumiv{@arabicc@enumiv}}%
sloppy
clubpenalty4000
@clubpenalty clubpenalty
widowpenalty4000%
sfcode`.@m
lodbib@biblistloop
endlist}
deflodbib@biblistloop{%
forlistloop{lodbib@bibitem}{lodbib@citeorder}%
ifdefvoid{lodbib@notcited}
{}
{forlistloop{lodbib@bibitem}{lodbib@notcited}}}
deflodbib@bibitem#1{%
ifcsundef{lodbib@savedlabel@#1}
{ltxorig@bibitem{#1}}
{ltxorig@lbibitem[csuse{lodbib@savedlabel@#1}]{#1}}%
csuse{lodbib@savedentry@#1}}
makeatother
begin{document}
cite{ref2} and cite{ref3, ref4, ref5}
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
cite{ref2}
end{document}
add a comment |
up vote
1
down vote
accepted
The implementation in Sorting bibliography in order of appearance without Bibtex naively assumed that the argument of citation
is always only a single key. That is a valid assumption for the standard implementation of cite
, but not for the implementation of cite
's cite
.
The following simple extension should also deal with comma-separated lists. The only difference is the introduction of a CSV loop in citation
and the resulting move of the core of the macro to citation@i
.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{cite}
usepackage{etoolbox}
usepackage{hyperref}
makeatletter
newcommand*{lodbib@citeorder}{}
newcommand*{lodbib@notcited}{}% catch entries that were not cited
% macro in aux file
defcitation{%
forcsvlist{citation@i}}
defcitation@i#1{%
ifinlist{#1}{lodbib@citeorder}
{}
{listxadd{lodbib@citeorder}{#1}}}
letltxorig@lbibitem@lbibitem
letltxorig@bibitem@bibitem
% save bibitems
def@lbibitem[#1]#2#3{%
csdef{lodbib@savedlabel@#2}{#1}%
@bibitem{#2}{#3}}
def@bibitem#1#2{%
xifinlist{#1}{lodbib@citeorder}
{}
{listadd{lodbib@notcited}{#1}}%
csdef{lodbib@savedentry@#1}{#2}}
renewenvironment{thebibliography}[1]
{settowidthlabelwidth{@biblabel{#1}}}
{def@noitemerr
{@latex@warning{Empty `thebibliography' environment}}%
section*{refname}%
@mkboth{MakeUppercaserefname}{MakeUppercaserefname}%
list{@biblabel{@arabicc@enumiv}}%
{leftmarginlabelwidth
advanceleftmarginlabelsep
@openbib@code
usecounter{enumiv}%
letp@enumiv@empty
renewcommandtheenumiv{@arabicc@enumiv}}%
sloppy
clubpenalty4000
@clubpenalty clubpenalty
widowpenalty4000%
sfcode`.@m
lodbib@biblistloop
endlist}
deflodbib@biblistloop{%
forlistloop{lodbib@bibitem}{lodbib@citeorder}%
ifdefvoid{lodbib@notcited}
{}
{forlistloop{lodbib@bibitem}{lodbib@notcited}}}
deflodbib@bibitem#1{%
ifcsundef{lodbib@savedlabel@#1}
{ltxorig@bibitem{#1}}
{ltxorig@lbibitem[csuse{lodbib@savedlabel@#1}]{#1}}%
csuse{lodbib@savedentry@#1}}
makeatother
begin{document}
cite{ref2} and cite{ref3, ref4, ref5}
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
cite{ref2}
end{document}
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
The implementation in Sorting bibliography in order of appearance without Bibtex naively assumed that the argument of citation
is always only a single key. That is a valid assumption for the standard implementation of cite
, but not for the implementation of cite
's cite
.
The following simple extension should also deal with comma-separated lists. The only difference is the introduction of a CSV loop in citation
and the resulting move of the core of the macro to citation@i
.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{cite}
usepackage{etoolbox}
usepackage{hyperref}
makeatletter
newcommand*{lodbib@citeorder}{}
newcommand*{lodbib@notcited}{}% catch entries that were not cited
% macro in aux file
defcitation{%
forcsvlist{citation@i}}
defcitation@i#1{%
ifinlist{#1}{lodbib@citeorder}
{}
{listxadd{lodbib@citeorder}{#1}}}
letltxorig@lbibitem@lbibitem
letltxorig@bibitem@bibitem
% save bibitems
def@lbibitem[#1]#2#3{%
csdef{lodbib@savedlabel@#2}{#1}%
@bibitem{#2}{#3}}
def@bibitem#1#2{%
xifinlist{#1}{lodbib@citeorder}
{}
{listadd{lodbib@notcited}{#1}}%
csdef{lodbib@savedentry@#1}{#2}}
renewenvironment{thebibliography}[1]
{settowidthlabelwidth{@biblabel{#1}}}
{def@noitemerr
{@latex@warning{Empty `thebibliography' environment}}%
section*{refname}%
@mkboth{MakeUppercaserefname}{MakeUppercaserefname}%
list{@biblabel{@arabicc@enumiv}}%
{leftmarginlabelwidth
advanceleftmarginlabelsep
@openbib@code
usecounter{enumiv}%
letp@enumiv@empty
renewcommandtheenumiv{@arabicc@enumiv}}%
sloppy
clubpenalty4000
@clubpenalty clubpenalty
widowpenalty4000%
sfcode`.@m
lodbib@biblistloop
endlist}
deflodbib@biblistloop{%
forlistloop{lodbib@bibitem}{lodbib@citeorder}%
ifdefvoid{lodbib@notcited}
{}
{forlistloop{lodbib@bibitem}{lodbib@notcited}}}
deflodbib@bibitem#1{%
ifcsundef{lodbib@savedlabel@#1}
{ltxorig@bibitem{#1}}
{ltxorig@lbibitem[csuse{lodbib@savedlabel@#1}]{#1}}%
csuse{lodbib@savedentry@#1}}
makeatother
begin{document}
cite{ref2} and cite{ref3, ref4, ref5}
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
cite{ref2}
end{document}
The implementation in Sorting bibliography in order of appearance without Bibtex naively assumed that the argument of citation
is always only a single key. That is a valid assumption for the standard implementation of cite
, but not for the implementation of cite
's cite
.
The following simple extension should also deal with comma-separated lists. The only difference is the introduction of a CSV loop in citation
and the resulting move of the core of the macro to citation@i
.
documentclass[british]{article}
usepackage[T1]{fontenc}
usepackage[utf8]{inputenc}
usepackage{babel}
usepackage{cite}
usepackage{etoolbox}
usepackage{hyperref}
makeatletter
newcommand*{lodbib@citeorder}{}
newcommand*{lodbib@notcited}{}% catch entries that were not cited
% macro in aux file
defcitation{%
forcsvlist{citation@i}}
defcitation@i#1{%
ifinlist{#1}{lodbib@citeorder}
{}
{listxadd{lodbib@citeorder}{#1}}}
letltxorig@lbibitem@lbibitem
letltxorig@bibitem@bibitem
% save bibitems
def@lbibitem[#1]#2#3{%
csdef{lodbib@savedlabel@#2}{#1}%
@bibitem{#2}{#3}}
def@bibitem#1#2{%
xifinlist{#1}{lodbib@citeorder}
{}
{listadd{lodbib@notcited}{#1}}%
csdef{lodbib@savedentry@#1}{#2}}
renewenvironment{thebibliography}[1]
{settowidthlabelwidth{@biblabel{#1}}}
{def@noitemerr
{@latex@warning{Empty `thebibliography' environment}}%
section*{refname}%
@mkboth{MakeUppercaserefname}{MakeUppercaserefname}%
list{@biblabel{@arabicc@enumiv}}%
{leftmarginlabelwidth
advanceleftmarginlabelsep
@openbib@code
usecounter{enumiv}%
letp@enumiv@empty
renewcommandtheenumiv{@arabicc@enumiv}}%
sloppy
clubpenalty4000
@clubpenalty clubpenalty
widowpenalty4000%
sfcode`.@m
lodbib@biblistloop
endlist}
deflodbib@biblistloop{%
forlistloop{lodbib@bibitem}{lodbib@citeorder}%
ifdefvoid{lodbib@notcited}
{}
{forlistloop{lodbib@bibitem}{lodbib@notcited}}}
deflodbib@bibitem#1{%
ifcsundef{lodbib@savedlabel@#1}
{ltxorig@bibitem{#1}}
{ltxorig@lbibitem[csuse{lodbib@savedlabel@#1}]{#1}}%
csuse{lodbib@savedentry@#1}}
makeatother
begin{document}
cite{ref2} and cite{ref3, ref4, ref5}
begin{thebibliography}{C}
bibitem{ref1}{AAAA}
bibitem{ref2}{BBBB}
bibitem{ref3}{CCCC}
bibitem{ref4}{DDDD}
bibitem{ref5}{EEEE}
end{thebibliography}
cite{ref2}
end{document}
edited 12 hours ago
answered 12 hours ago
moewe
83.2k8107320
83.2k8107320
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461829%2fmultiple-reference-citation-in-order-of-appearance-without-bibtex%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown