la respuesta demoewea la preguntaBiblatex: Dos bibliografías con diferentes estilos y clasificacionesEs casi lo que quiero lograr. Debido a la gran cantidad de entradas en mi documento, preferiría usar el estilo numeric-comp
en lugar de solo numeric
. ¿Cómo puedo conseguir esto?
MWE extendido:
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{biblatextest1.bib}
@BOOK{BookA03,
author = {Author Aaa},
title = {Some Title},
publisher = {Some Publisher},
year = 2003,
}
@BOOK{BookB02,
author = {Author Bbb},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB09,
author = {Author Jjj},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB10,
author = {Author Kkk},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB11,
author = {Author Lll},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
\begin{filecontents}{biblatextest2.bib}
@MISC{LinkC04,
author = {Author Ccc},
title = {Some Title},
year = 2004,
url = {www.test1.com/bild.jpg},
}
@MISC{LinkD01,
author = {Author Ddd},
title = {Some Title},
year = 2001,
url = {www.test2.com/bild.jpg},
}
@MISC{LinkD05,
author = {Author Eee},
title = {Some Title},
year = 2004,
url = {www.test3.com/bild.jpg},
}
@MISC{LinkD06,
author = {Author Fff},
title = {Some Title},
year = 2001,
url = {www.test4.com/bild.jpg},
}
@MISC{LinkD07,
author = {Author Ggg},
title = {Some Title},
year = 2004,
url = {www.test5.com/bild.jpg},
}
@MISC{LinkD08,
author = {Author Hhh},
title = {Some Title},
year = 2001,
url = {www.test6.com/bild.jpg},
}
\end{filecontents}
\usepackage[style = alphabetic, labelnumber, defernumbers = true, backend = biber]{biblatex}
\addbibresource{biblatextest1.bib}
\addbibresource{biblatextest2.bib}
\usepackage{hyperref}
%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{biblatextest1.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary, append]
}
\map{
\perdatasource{biblatextest2.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary, append]
}
}
}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\renewbibmacro*{cite}{%
\printtext[bibhyperref]{%
\printfield{labelprefix}%
\ifkeyword{secondary}
{\printfield{labelnumber}}
{\printfield{labelalpha}%
\printfield{extraalpha}}}}
\defbibenvironment{bibliographyNUM}
{\list
{\printtext[labelnumberwidth]{%
\printfield{prefixnumber}%
\printfield{labelnumber}}}
{\setlength{\labelwidth}{\labelnumberwidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{\hss##1}}
{\endlist}
{\item}
\assignrefcontextkeyws[sorting=none]{secondary}
\begin{document}
The first two citations \cite{LinkD07,LinkC04} and \cite{BookB10,BookB11,BookB02,BookB09}.
The others are \cite{LinkD08,LinkD01,LinkD05,LinkD06} and \cite{BookA03}.
\printbibliography[title=Bibliography, keyword=primary]
\newrefcontext[sorting=none]
\printbibliography[env=bibliographyNUM,title=References, keyword=secondary, resetnumbers]
\end{document}
De forma anticipada, muchas gracias por su ayuda.
Respuesta1
Creo que logré llegar a algún lugar basándome en numeric-comp
y luego tratando de llevar labelalpha
información al shorthand
campo, que se maneja de forma nativa mediante numeric-comp
, por lo que no es necesario redefinir las cite
macros/comandos.
Inicialmente intenté hacer esto en el mapa fuente, pero de alguna manera no funcionó, así que terminé usándolo \AtEveryCitekey
para eso.
Probablemente todavía tendrás que ajustar la clasificación. Y también notará que la cita mixta de referencias primarias y secundarias no es ideal (no pude descubrir qué fue lo que determinó la clasificación en este caso). Pero el resultado general parece razonable.
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{biblatextest1.bib}
@BOOK{BookA03,
author = {Author Aaa},
title = {Some Title},
publisher = {Some Publisher},
year = 2003,
}
@BOOK{BookB02,
author = {Author Bbb},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB09,
author = {Author Jjj},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB10,
author = {Author Kkk},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
@BOOK{BookB11,
author = {Author Lll},
title = {Some Title},
publisher = {Some Publisher},
year = 2002,
}
\end{filecontents}
\begin{filecontents}{biblatextest2.bib}
@MISC{LinkC04,
author = {Author Ccc},
title = {Some Title},
year = 2004,
url = {www.test1.com/bild.jpg},
}
@MISC{LinkD01,
author = {Author Ddd},
title = {Some Title},
year = 2001,
url = {www.test2.com/bild.jpg},
}
@MISC{LinkD05,
author = {Author Eee},
title = {Some Title},
year = 2004,
url = {www.test3.com/bild.jpg},
}
@MISC{LinkD06,
author = {Author Fff},
title = {Some Title},
year = 2001,
url = {www.test4.com/bild.jpg},
}
@MISC{LinkD07,
author = {Author Ggg},
title = {Some Title},
year = 2004,
url = {www.test5.com/bild.jpg},
}
@MISC{LinkD08,
author = {Author Hhh},
title = {Some Title},
year = 2001,
url = {www.test6.com/bild.jpg},
}
\end{filecontents}
\usepackage[style = numeric-comp, labelalpha, defernumbers]{biblatex}
\addbibresource{biblatextest1.bib}
\addbibresource{biblatextest2.bib}
\usepackage{hyperref}
%Append keywords to identify different bibliography entries.
\DeclareSourcemap{
\maps[datatype=bibtex, overwrite]{
\map{
\perdatasource{biblatextest1.bib}
\step[fieldset=KEYWORDS, fieldvalue=primary]
}
\map{
\perdatasource{biblatextest2.bib}
\step[fieldset=KEYWORDS, fieldvalue=secondary]
}
}
}
\makeatletter
\newcommand*{\labelalphatoshorthand}{\csdef{abx@field@shorthand}{\strfield{labelprefix}\strfield{labelalpha}\strfield{extraalpha}}}
\makeatother
\AtEveryCitekey{\ifkeyword{primary}{\labelalphatoshorthand}{}}
\DeclareFieldFormat{labelalphawidth}{\mkbibbrackets{#1}}
\defbibenvironment{bibliographyALPHA}
{\list
{\printtext[labelalphawidth]{%
\printfield{labelprefix}%
\printfield{labelalpha}%
\printfield{extraalpha}}}
{\setlength{\labelwidth}{\labelalphawidth}%
\setlength{\leftmargin}{\labelwidth}%
\setlength{\labelsep}{\biblabelsep}%
\addtolength{\leftmargin}{\labelsep}%
\setlength{\itemsep}{\bibitemsep}%
\setlength{\parsep}{\bibparsep}}%
\renewcommand*{\makelabel}[1]{##1\hss}}
{\endlist}
{\item}
\begin{document}
The first two citations \cite{LinkD07,LinkC04} and
\cite{BookB10,BookB11,BookB02,BookB09}.
Mixing both primary and secondary
\cite{LinkD08,LinkD01,LinkD05,LinkD06,BookB10,BookB11,BookB02,BookB09}.
The others are \cite{LinkD08,LinkD01,LinkD05,LinkD06,LinkD07}
and \cite{BookA03}.
\printbibliography[env=bibliographyALPHA, title=Bibliography, keyword=primary]
\newrefcontext
\printbibliography[title=References, keyword=secondary, resetnumbers]
\end{document}
Fuera de tema: observe que eliminé sus append
instrucciones de sus DeclareSourcemap
pasos. La idea de agregar es buena. Pero supongamos que tiene un campo con una palabra clave mykeyword
y primary
lo agrega. Obtendrá mykeywordprimary
, que no es ni mykeyword
ni primary
, y su mecanismo basado en palabras clave para separar las bibliografías fallará (en realidad, le faltarán entradas de bibliografía). Entonces, para hacer eso, tendría que incluir una coma entre las palabras clave y manejar el caso de que el campo esté vacío o no, y así sucesivamente.