11

I'm using biblatex to print the bibliography for my document and I'm quite happy with the result. However, I also want to add a list of personal publications in another part of the document. It works very well with the refsection environment, but I would like to use for this part another style (e.g., biblatex-publist).

Q: Is it possible to use two different biblatex styles at different parts of a single document?


Example:

For the general bibliography:

Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to Algorithms, Third Edition. 3rd. The MIT Press, 2009

For the personal publication list:

1987 (with John Doe and Mary Hall). Are there new trends in gardening? In: Gardening Practice 24, pp. 10–15.


It seems that the style can only be specified when loading the package which makes the style a global option. Is there a way around this?

  • 1
    Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. Though it might not be crucial to your question a nice MWE is still greatly appreciated. – moewe Apr 8 '14 at 14:10
  • The following question seems to be related link – Tahtisilma Apr 8 '14 at 14:35
  • I'm afraid it does not look like this is currently possible with biblatex. While different sorting schemes for bibliographies have been implemented (as mentioned by lockstep in Tahtisilma's link above), different (bibliography/citation) styles is a different and much more complicated issue. – moewe Apr 8 '14 at 14:41
  • 1
    Another possibility would be to create a new \cite command for your personal publications lists and just use that. Something like \DeclareCiteCommand{\perscite}{...}, which provided output in the desired way, could be used to mimic the appearance of a second bibliographical style. – jon Apr 9 '14 at 13:50
  • 1
    Do you really need different citation styles? For different bibliography styles you may probably define appropriate bibliography environments with \defbibenvironment. – Oleg Domanov Apr 30 '14 at 15:31
2

You cannot do this automatically, but in some cases it is possible to break the bbx file into pieces to give you what you want. For the case of mixing the authoryear style and the publist style this is pretty straight forward. Working from the following MWE

\documentclass{article}
\usepackage[labelnumber=true, bibstyle=authoryear]{biblatex}
% \usepackage[bibstyle=publist]{biblatex}
\addbibresource{biblatex-examples.bib}
% \input{\jobname Pre}
\makeatletter
\def\bpl@osurname{Baez}
\def\bpl@ofirstname{John C.}
\makeatother

\begin{document}
\nocite{baez/article}
\printbibliography

\input{\jobname Post}
\begin{refsection}
\nocite{baez/article}
\printbibliography
\end{refsection}
\end{document}

The authoryear output is

enter image description here

and the publist output is

enter image description here

If we include the \jobname Pre and \jobname Post files with \usepackage[labelnumber=true, bibstyle=authoryear]{biblatex} we get

enter image description here

with the exception of a stray space at the beginning of the "publist" style entry, the output matches both styles.

The "magic" is occurring in the \jobname Pre and \jobname Post files. To create these files, I copied publist.bbx into \jobname Post and then moved things that caused errors, or seemed like it belonged in the preamble, into \jobname Pre. Anything that still caused errors when it was in \jobname Pre I deleted.

This gave me a \jobname Pre of

\makeatletter

%
% The omitted name of the publication list author
\def\bpl@osurname{}
\def\bpl@ofirstname{}
\def\bpl@ovonpart{}
%
% Manual way to specify omitted name
\def\omitname{%
   \@ifnextchar[%
     {\omitname@i}
     {\omitname@i[]}%
}
\def\omitname@i[#1]{%
   \@ifnextchar[%
     {\omitname@ii{#1}}
     {\omitname@ii{#1}[]}%
}
\def\omitname@ii#1[#2]#3{%
  % Do stuff
  \def\bpl@osurname{#3}
  \ifx\@empty#1\else\def\bpl@ofirstname{#1}\fi
  \ifx\@empty#2\else\def\bpl@ovonpart{#2}\fi
}

%
% Formatting of year in margin par (if requested)
\providecommand*\plmarginyear[1]{%
  \raggedleft\small\textbf{#1}%
}

%
% Options
%

\DeclareBibliographyOption{omitname}{\def\bpl@osurname{#1}}

\DeclareBibliographyOption{omitfirstname}{\def\bpl@ofirstname{#1}}

\DeclareBibliographyOption{omitnameprefix}{\def\bpl@ovonpart{#1}}

\newif\if@marginyear\@marginyearfalse
\DeclareBibliographyOption{marginyear}[true]{%
    \ifstrequal{#1}{true}{\@marginyeartrue\reversemarginpar}{\@marginyearfalse}
}

\newif\if@unboldyear\@unboldyearfalse
\DeclareBibliographyOption{boldyear}[true]{%
    \ifstrequal{#1}{false}{\@unboldyeartrue}{\@unboldyearfalse}
}

%
% Bibliography filter
%
% Inspired by http://tex.stackexchange.com/a/28555/19291
\DeclareBibliographyCategory{filtered}

\DeclareIndexNameFormat{authorfiltered}{%
   \bpl@normalize{#1}{\bpl@tsurname}%
   \bpl@normalize{#3}{\bpl@tfirstname}%
   \bpl@normalize{#5}{\bpl@tvonpart}%
   \bpl@normalize{\bpl@osurname}{\bpl@esurname}%
   \bpl@normalize{\bpl@ofirstname}{\bpl@efirstname}%
   \bpl@normalize{\bpl@ovonpart}{\bpl@evonpart}%
   \ifboolexpr{
      test { \ifdefstrequal{\bpl@esurname}{\bpl@tsurname} }
      and
      ( test { \ifdefstrequal{\bpl@efirstname}{\bpl@tfirstname} } or test { \ifdefstring{\bpl@ofirstname}{} }) 
      and
      ( test { \ifdefstrequal{\bpl@evonpart}{\bpl@tvonpart} } or test { \ifdefstring{\bpl@ovonpart}{} }) }
    {\addtocategory{filtered}{\thefield{entrykey}}}
    {}}

\DeclareIndexNameFormat{editorfiltered}{%
   \edef\bpl@tsurname{#1}%
   \edef\bpl@tfirstname{#3}%
   \edef\bpl@tvonpart{#5}%
   \bpl@normalize{\bpl@osurname}{\bpl@esurname}%
   \bpl@normalize{\bpl@ofirstname}{\bpl@efirstname}%
   \bpl@normalize{\bpl@ovonpart}{\bpl@evonpart}%
   \ifboolexpr{
      test { \ifdefstrequal{\bpl@esurname}{\bpl@tsurname} }
      and
      ( test { \ifdefstrequal{\bpl@efirstname}{\bpl@tfirstname} } or test { \ifdefstring{\bpl@ofirstname}{} }) 
      and
      ( test { \ifdefstrequal{\bpl@evonpart}{\bpl@tvonpart} } or test { \ifdefstring{\bpl@ovonpart}{} }) }
    {\addtocategory{filtered}{\thefield{entrykey}}}
    {}}

\DeclareIndexNameFormat[inbook,inproceedings,incollection]{editorfiltered}{}%

% \AtDataInput{%
%   \indexnames[authorfiltered]{author}%
%   \indexnames[editorfiltered]{editor}%
% }

\defbibfilter{mine}{category=filtered}






\AtBeginDocument{%
\if@unboldyear
\renewbibmacro*{date:labelyear+extrayear}{%
   \usebibmacro{date:makedate}%
}
\fi
}


%
% l7n
%
\NewBibliographyString{with}
\NewBibliographyString{parttranslationof}
\DefineBibliographyStrings{english}{%
  parttranslationof   = {partial translation of},
  with                = {with}
}
\DefineBibliographyStrings{french}{%
  parttranslationof   = {traduction partielle de},
  with                = {avec}
}
\DefineBibliographyStrings{german}{%
  parttranslationof   = {Teil\"ubersetzung von},
  with                = {mit}
}


%
% New driver for reviews
%

\DeclareBibliographyDriver{review}{%
  \usebibmacro{rauthor/label}%
  \setunit*{\addcolon\space}%
  \usebibmacro{title}%
  \newunit\newblock
  \usebibmacro{in:}%
  \usebibmacro{journal+issuetitle}%
  \newunit\newblock
  \printfield{note}%
  \setunit{\addcomma\space}%
  \printfield{pages}
  \newunit\newblock
  \printfield{issn}%
  \newunit\newblock
  \printfield{doi}%
  \setunit{\addspace}
  \usebibmacro{addendum+pubstate}%
  \newunit\newblock
  \usebibmacro{url+urldate}%
  \newunit\newblock
  \usebibmacro{pageref}%
  \newunit\newblock
  \usebibmacro{related}%
  \usebibmacro{finentry}}

%
% Sorting schemes
%

% Consider the whole date (year-month-day)
% Sorting date (descending), name, title
\DeclareSortingScheme{ddnt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort[direction=descending]{
    \field[strside=left,strwidth=4]{sortyear}
    \field[strside=left,strwidth=4]{year}
    \literal{9999}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=2,padchar=0]{month}
    \literal{00}
  }
  \sort[direction=descending]{
    \field[padside=left,padwidth=2,padchar=0]{day}
    \literal{00}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

% Sorting year (descending), month, day, name, title
\DeclareSortingScheme{ydmdnt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort[direction=descending]{
    \field[strside=left,strwidth=4]{sortyear}
    \field[strside=left,strwidth=4]{year}
    \literal{9999}
  }
  \sort{
    \field[padside=left,padwidth=2,padchar=0]{month}
    \literal{00}
  }
  \sort{
    \field[padside=left,padwidth=2,padchar=0]{day}
    \literal{00}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

% Sorting date (ascending), name, title
\DeclareSortingScheme{dnt}{
  \sort{
    \field{presort}
  }
  \sort[final]{
    \field{sortkey}
  }
  \sort{
    \field[strside=left,strwidth=4]{sortyear}
    \field[strside=left,strwidth=4]{year}
    \literal{9999}
  }
  \sort{
    \field[padside=left,padwidth=2,padchar=0]{month}
    \literal{00}
  }
  \sort{
    \field[padside=left,padwidth=2,padchar=0]{day}
    \literal{00}
  }
  \sort{
    \field{sortname}
    \field{author}
    \field{editor}
    \field{translator}
    \field{sorttitle}
    \field{title}
  }
  \sort{
    \field{sorttitle}
    \field{title}
  }
}

\makeatother

and a \jobname Post of

\makeatletter

%
% Field format definitions
%
\DeclareFieldFormat{bibentrysetcount}{\mkbibparens{\mknumalph{#1}}}
\DeclareFieldFormat{labelnumberwidth}{\mkbibbrackets{#1}}
\DeclareFieldFormat{shorthandwidth}{\mkbibbrackets{#1}}
\DeclareFieldFormat{related:parttranslationof}{\mkbibbrackets{#1}}


%
% Deal with numbering (resume numbers in refsections)
%
\csnumgdef{bbx@itemtotal}{0}
\csnumgdef{bbx@currentitem}{0}
\csnumgdef{bbx@saverefsection}{0}
\newbool{newsection}

\preto\blx@refsection{\global\setbool{newsection}{true}}

\defbibenvironment{bibliography}
  {\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
   \ifnumgreater{\c@refsection}{\bbx@saverefsection}%
    {\csnumgdef{bbx@itemtotal}{\csuse{bbx@itemtotal}+\csuse{bbx@currentitem}}}{}%
   \csnumgdef{bbx@saverefsection}{\c@refsection}%
  }
  {\item}

\DeclareFieldFormat{labelnumber}{%
    \ifbool{newsection}{%
       % Fix start counter value
       \csnumgdef{bbx@itemtotal}{\csuse{bbx@itemtotal}-#1+1}%
       \global\setbool{newsection}{false}%
    }{}%
    \mkbibdesc{#1}%
    \csnumgdef{bbx@currentitem}{#1}%
}

% Print labelnumber as actual number, plus item total
\newrobustcmd{\mkbibdesc}[1]{%
  \number\numexpr\csuse{bbx@itemtotal}+#1\relax}

\newcommand*\decreasebbxnumbering[1]{\csnumgdef{bbx@itemtotal}{\csuse{bbx@itemtotal}-#1}}


%
% New environment for (foreign) reviews
%
\defbibenvironment{reviews}
  {\begin{enumerate}%
   \small\setlength\itemsep{0pt}}
  {\end{enumerate}}
  {\item}


%
% Helper function:
% Removing braces from names (courtesy of egreg at
% http://tex.stackexchange.com/a/79583/19291)
% and normalize spaces
\def\bpl@normalize#1#2{%
  \begingroup
  \def\bibnamedelima{ }%
  \def\bibnamedelimb{ }%
  \def\IeC##1{##1}%
  \protected@edef\@tempa{#1}%
  \gdef\@gtempa{}%
  \expandafter\bpl@@normalize\@tempa\@nil
  \endgroup
  \let#2\@gtempa
}
\def\bpl@@normalize#1{%
  \ifx#1\@nil\else
    \expandafter\gdef\expandafter\@gtempa\expandafter{\@gtempa#1}%
    \expandafter\bpl@@normalize
  \fi
}


%
% Remove omitted name from author and editor lists
%
\newtoggle{myselfprec}
\newtoggle{hadmyself}

\DeclareNameFormat{author}{%
   \ifthenelse{\value{listcount}=1}{\ifthenelse{\value{author}>1}{\bibopenparen\bibstring{with}\addspace}{}}{}%
   % Exclude omitted author
   \bpl@normalize{#1}{\bpl@tsurname}%
   \bpl@normalize{#3}{\bpl@tfirstname}%
   \bpl@normalize{#5}{\bpl@tvonpart}%
   \bpl@normalize{\bpl@osurname}{\bpl@esurname}%
   \bpl@normalize{\bpl@ofirstname}{\bpl@efirstname}%
   \bpl@normalize{\bpl@ovonpart}{\bpl@evonpart}%
   \ifboolexpr{
      test { \ifdefstrequal{\bpl@esurname}{\bpl@tsurname} }
      and
      ( test { \ifdefstrequal{\bpl@efirstname}{\bpl@tfirstname} } or test { \ifdefstring{\bpl@ofirstname}{} }) 
      and
      ( test { \ifdefstrequal{\bpl@evonpart}{\bpl@tvonpart} } or test { \ifdefstring{\bpl@ovonpart}{} }) }
          {\toggletrue{myselfprec}\toggletrue{hadmyself}%
           \ifthenelse{\value{listcount}=1\AND\value{liststop}=1}
                   {\stepcounter{liststop}}{}}
          {\ifthenelse{\value{listcount}=1}{\togglefalse{hadmyself}}{%
          \ifboolexpr{
              test { \iftoggle{myselfprec} }
              and
              test { \ifnumless{\value{listcount}}{3} } }
              {}{%
                 \ifnumless{\value{listcount}}{\value{liststop}-1}%
                    {\addcomma\addspace}%
                    {\iftoggle{hadmyself}{%
                        \ifnumless{\value{listcount}}{\value{liststop}}%
                           {\addcomma\addspace}%
                           {\addspace\bibstring{and}\addspace}}
                       {\addspace\bibstring{and}\addspace}}%
                }%
          }%
          \iffirstinits
             {\ifblank{#4}{}{#4\addspace}}%
             {\ifblank{#3}{}{#3\addspace}}%
          \ifblank{#5}{}{#5\addspace}%
          \togglefalse{myselfprec}%
          #1}%
          \usebibmacro{name:andothers}%
   \ifthenelse{\value{listcount}=\value{liststop}\AND\value{author}>1}{\unspace\bibcloseparen}{}%
}

\DeclareNameFormat{editor}{%
   \ifthenelse{\value{listcount}=1}{\ifthenelse{\value{editor}>1}{\bibopenparen\bibstring{with}\addspace}{}}{}%
   % Exclude omitted author
   \bpl@normalize{#1}{\bpl@tsurname}%
   \bpl@normalize{#3}{\bpl@tfirstname}%
   \bpl@normalize{\bpl@osurname}{\bpl@esurname}%
   \bpl@normalize{\bpl@ofirstname}{\bpl@efirstname}%
   \ifboolexpr{
      test { \ifdefstrequal{\bpl@esurname}{\bpl@tsurname} }
      and
      ( test { \ifdefstrequal{\bpl@efirstname}{\bpl@tfirstname} } or test { \ifdefstring{\bpl@ofirstname}{} }) 
      and
      ( test { \ifdefstrequal{\bpl@evonpart}{\bpl@tvonpart} } or test { \ifdefstring{\bpl@ovonpart}{} }) }
          {\toggletrue{myselfprec}\toggletrue{hadmyself}%
           \ifthenelse{\value{listcount}=1\AND\value{liststop}=1}
                   {\stepcounter{liststop}}{}}
          {\ifthenelse{\value{listcount}=1}{\togglefalse{hadmyself}}{%
            \ifboolexpr{
              test { \iftoggle{myselfprec} }
              and
              test { \ifnumless{\value{listcount}}{3} } }
              {}{%
                 \ifnumless{\value{listcount}}{\value{liststop}-1}%
                     {\addcomma\addspace}%
                     {\iftoggle{hadmyself}{%
                         \ifnumless{\value{listcount}}{\value{liststop}}%
                             {\addcomma\addspace}%
                             {\addspace\bibstring{and}\addspace}}
                        {\addspace\bibstring{and}\addspace}}%
                }%
          }%
          \iffirstinits
             {\ifblank{#4}{}{#4\addspace}}%
             {\ifblank{#3}{}{#3\addspace}}%
          \ifblank{#5}{}{#5\addspace}%
          \togglefalse{myselfprec}%
          #1}%
          \usebibmacro{name:andothers}%
   \ifthenelse{\value{listcount}=\value{liststop}\AND\value{editor}>1}{\unspace\bibcloseparen}{}%
}

\DeclareNameFormat{bookauthor}{%
  \ifblank{#5}{}{#5\addspace}%
  #1%
  \iffirstinits
      {\ifblank{#4}{}{\addcomma\space #4}}%
      {\ifblank{#3}{}{\addcomma\space #3}}%
  \ifthenelse{\value{listcount}<\value{liststop}}
    {\addslash}
    {}%
  \usebibmacro{name:andothers}}

\renewbibmacro*{name:andothers}{%
  \ifthenelse{\value{listcount}=\value{liststop}\AND
              \ifmorenames}
    {\ifnum\value{liststop}>1 \finalandcomma\fi
     \andothersdelim\biblcstring{andothers}}
    {}}

%
% Macros
%

\renewbibmacro*{author}{%
  \ifnameundef{author}
    {}
    {\usebibmacro{year+labelyear}\addspace%
     \printnames{author}%
     \setunit{\addspace}%
      \iffieldundef{nameaddon}
      {}
      {\mkbibbrackets{\bibstring{alias}%
       \addspace\printfield{nameaddon}}}}}

\renewbibmacro*{editor}{%
  \ifnameundef{editor}
    {}
    {\usebibmacro{year+labelyear}%
      \addspace%
      \printnames{editor}%
     \setunit{\addspace}%
     \usebibmacro{editorstrg}}}

\renewbibmacro*{editor+others}{%
  \ifboolexpr{
    test \ifuseeditor
    and
    not test {\ifnameundef{editor}}
  }
    {\usebibmacro{year+labelyear}%
     \addspace%
     \printnames{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{editor+othersstrg}%
     \clearname{editor}}
    {}}

\newbibmacro*{date:makedate}{%
  \printtext{%
     \iffieldundef{year}{%
       \iffieldundef{pubstate}{}{%
          \printfield{pubstate}%
        }%
      }{%
       \iffieldundef{month}{%
         \printdateextra}%
        {\printdate}%
      }%
     }%
}

\newbibmacro*{date:labelyear+extrayear}{%
   \mkbibbold{\usebibmacro{date:makedate}}%
}


\newbibmacro*{year+labelyear}{%
  \iffieldundef{year}{%
    \iffieldundef{pubstate}{\let\bbx@lasthash\undefined}{%
     \usebibmacro{date:labelyear+extrayear}%
     \if@marginyear%
     \iffieldequals{pubstate}{\bbx@lasthash}{}{%
      \printtext{\marginpar{\small\plmarginyear{\bibsentence\printfield{pubstate}}}}%
     }%
     \fi
      \savefield{pubstate}{\bbx@lasthash}%
      \clearfield{pubstate}%
     }
    }{%
     \usebibmacro{date:labelyear+extrayear}%
     \if@marginyear%
     \iffieldequals{labelyear}{\bbx@lasthash}{}{%
      \printtext{\marginpar{\small\plmarginyear{\printfield{labelyear}}}}%
     }%
     \fi
     \savefield{labelyear}{\bbx@lasthash}%
    }}

\newbibmacro*{rauthor/label}{%
  \ifnameundef{author}
    {\usebibmacro{label}}
    {\usebibmacro{rauthor}}
}

\newbibmacro*{rauthor}{%
  \ifnameundef{author}
    {\let\bbx@lasthash\undefined}
    {\ifthenelse{\iffieldequals{namehash}{\bbx@lasthash}\AND\NOT
                 \iffirstonpage}
       {\bibnamedash}
       {\savefield{namehash}{\bbx@lasthash}%
        \printnames{author}%
        \setunit{\addspace}}}%
    \iffieldundef{nameaddon}
    {}
    {\mkbibbrackets{\bibstring[\unspace]{alias}\addspace\printfield{nameaddon}}%
     \addspace}%
  \usebibmacro{ryear+labelyear}}

\newbibmacro*{ryear+labelyear}{%
  \iffieldundef{year}
    {}
    {\printtext[parens]{%
      \printfield{labelyear}%
      \printfield{extrayear}}}}
\makeatother

My guess is the sorting is all screwed up, but biblatex supports multiple sorting schemes. Again, there are likely style combinations that will result in major clashes so this is not a general solution. I think it, however, hints at a general solution if people wrote the bbx and cbx styles to be modular.

  • I'm just looking into the feasibility of doing something similar for a combination of biblatex-chicago's notes and authordate styles, for primary and secondary literature references respectively, but I'm getting the impression it's not reasonably possible: For example, these two styles differ in their set of \DeclareBibliographyDriver sequences, which can only be loaded in the preamble, so I would have to decide for one of the two drivers, but don't I break a style by using the drivers of another one? – muk.li Apr 20 '15 at 19:52
0

Does combining styles work?

Answer: No, if randomly using existing biblatex styles and trying to merge them (I tried authordate and chicago-notes): the tricky part is where they use the same names for bibmacros and booleans, but do different things with and to them; or where they import base code (like standard.bbx) and add/modify in different ways. It's like getting a car to run by merging two different-model engines - there is some overlap, but some things just don't fit. (And at the style-level, merging won't help: does the date go before, or after? It can't do both.)

Answer: Yes, if you build the style (or meta-style) from the ground up so that the processing logic is internally consistent and coherent. The sequencing of blocks then becomes trivial because the bibliography driver then becomes a despatcher: "if this bibentry/type/key, then that bibmacro, else the other bibmacro". (Visually, mixed styles within the same text block won't help the reader, though.)

Alternatively, split the bibliography, by keyword or category, or custom entry type(s): let the structure follow the information. And, if style is thought of as separate from biblatex style, then a different "yes" is possible because, in the spirit of keeping form and content separate, Latex code is allowed inside the bib field formats and elsewhere. It doesn't all have to be {#1}.

sub bibs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.