1

I am trying to align my bibliography, at the moment it is looking like this:

my bib

The red line indicates the problem: For multi-line bibliography entries, the first line is not aligned with all others. I would like to have all lines starting at the green line.

This picture has been created with the following code

\documentclass[a4paper,10pt,oneside]{scrbook}
\begin{document}

some random text with one citation to deepmind \cite{GoogleAtari} and one to some other \cite{ReinforcementReview} and another \cite{erven2014experimental}.

\bibliographystyle{xxxunsrt}
\bibliography{refs}

\end{document}

and the refs.bib looks as follows:

@article{GoogleAtari,
  title={Human-level control through deep reinforcement learning},
  author={Volodymyr Mnih and Koray Kavukcuoglu and David Silver and Andrei A. Rusu and Joel Veness and Marc G. Bellemare and Alex Graves and Martin Riedmiller and Andreas K. Fidjeland and Georg Ostrovski and Stig Petersen and Charles Beattie and Amir Sadik and Ioannis Antonoglou and Helen King and Dharshan Kumaran and Daan Wierstra and Shane Legg and Demis Hassabis},
  journal={Nature},
  volume={518},
  number={7540},
  pages={529--533},
  year={2015},
  publisher={Nature Publishing Group}
}


@article{ReinforcementReview,
  title={Reinforcement learning improves behaviour from evaluative feedback},
  author={Littman, Michael L},
  journal={Nature},
  volume={521},
  number={7553},
  pages={445--451},
  year={2015},
  publisher={Nature Publishing Group}
}

@article{erven2014experimental,
  title={Experimental three-photon quantum nonlocality under strict locality conditions},
  author={C. Erven and E. Meyer-Scott and K. Fisher and J. Lavoie and B. L. Higgins and Z. Yan and C. J. Pugh and J.-P. Bourgoin and R. Prevedel and L. K. Shalm and L. Richards and N. Gigov and R. Laflamme and G. Weihs and T. Jennewein and K. J. Resch},
  journal={Nature photonics},
  volume={8},
  number={4},
  pages={292--296},
  year={2014},
  publisher={Nature Publishing Group}
}

The question here sounded similar, however it didn't solve my problem (even if i add natbib. I'm using MikTeX 2.9, and xxxunsrt.bst is costumized (with bib-it).

I'm trying this for quite some time now, and would be very happy for every hint!


Edit:

And here is a shrinked, but still very large xxxunsrt.bst file

ENTRY
  { 
    author
    booktitle
    journal
    pages
    publisher
    title
    url
    volume
    year
  }
  {}
  { label }
INTEGERS { output.state before.all mid.sentence after.sentence after.block }
FUNCTION {init.state.consts}
{ #0 'before.all :=
  #1 'mid.sentence :=
  #2 'after.sentence :=
  #3 'after.block :=
}
STRINGS { s t}
FUNCTION {output.nonnull}
{ 's :=
  output.state mid.sentence =
    { ", " * write$ }
    { output.state after.block = 
        { add.period$ write$
          newline$
          "\newblock " write$
        }
        { output.state before.all =
            'write$
            { add.period$ " " * write$ }
          if$
        }
      if$
      mid.sentence 'output.state :=
    }
  if$
  s
}
FUNCTION {output.nonnull.nostate}
{ 's :=
  output.state after.block =
    { add.period$ write$
      newline$
      "\newblock " write$
    }
    'write$
  if$
  s
}
FUNCTION {output}
{ duplicate$ empty$
    'pop$
    'output.nonnull
  if$
}
FUNCTION {output.check}
{ 't :=
  duplicate$ empty$
    { pop$ "empty " t * " in " * cite$ * warning$ }
    'output.nonnull
  if$
}
INTEGERS { nameptr namesleft numnames posothers showetal}

FUNCTION {output.bibitem}
{ newline$
  "\bibitem{" write$
  cite$ write$
  "}" write$
  newline$
  ""
  before.all 'output.state :=
}
FUNCTION {bibinfo.check}
{ swap$
  duplicate$ missing$
    {
      pop$ pop$
      ""
    }
    { duplicate$ empty$
        {
           swap$ pop$
        }
        { swap$
          pop$
        }
      if$
    }
  if$
}
FUNCTION {fin.entry}
{ add.period$
  write$
  newline$
}
FUNCTION {new.block}
{ output.state before.all =
    'skip$
    { after.block 'output.state := }
  if$
}
FUNCTION {new.sentence}
{ output.state after.block =
    'skip$
    { output.state before.all =
        'skip$
        { after.sentence 'output.state := }
      if$
    }
  if$
}
FUNCTION {add.blank}
{  " " * before.all 'output.state :=
}
FUNCTION {add.colon}
{ duplicate$ empty$
    'skip$
    { ":" * add.blank }
  if$
}
FUNCTION {not}
{   { #0 }
    { #1 }
  if$
}
FUNCTION {and}
{   'skip$
    { pop$ #0 }
  if$
}
FUNCTION {or}
{   { pop$ #1 }
    'skip$
  if$
}
FUNCTION {field.or.null}
{ duplicate$ empty$
    { pop$ "" }
    'skip$
  if$
}
FUNCTION {bolden}
{ duplicate$ empty$
    { pop$ "" }
    { "\textbf{" swap$ * "}" * }
  if$
}
FUNCTION {italize}
{ duplicate$ empty$
    { pop$ "" }
    { "\textit{" swap$ * "}" * }
  if$
}
FUNCTION {scaps}
{ duplicate$ empty$
    { pop$ "" }
    { "\textsc{" swap$ * "}" * }
  if$
}
FUNCTION {anglequote}
{ duplicate$ empty$
    { pop$ "" }
    { "<<" swap$ * ">>" * }
  if$
}
FUNCTION {singlequote}
{ duplicate$ empty$
    { pop$ "" }
    { "'{}" swap$ * "'{}" * }
  if$
}
FUNCTION {doublequote}
{ duplicate$ empty$
    { pop$ "" }
    { "``{}" swap$ * "''{}" * }
  if$
}
FUNCTION {format.names.author}
{
  's :=

  #1 'nameptr :=
  s num.names$ 'numnames :=

  numnames 'namesleft :=
  #0 'posothers :=
    { namesleft #0 > }
    { s nameptr "{f{.}.}{ ll}" format.name$ 't :=
      t "others" =
         { nameptr 'posothers := }
         'skip$
       if$
       nameptr #1 + 'nameptr :=
       namesleft #1 - 'namesleft :=
    }
  while$

  #0 'showetal :=

  numnames #50 >
    { #50 'numnames :=
      #1 'showetal :=
    }
    { numnames #50 =
        { posothers #0 >
          { #1 'showetal :=
            #50 'numnames :=
          }
          'skip$
         if$
         }
         { posothers #0 >
             { #1 'showetal :=
               #1 'numnames -
             }
             'skip$
           if$
         }
       if$
    }
  if$

  #1 'nameptr :=
  numnames 'namesleft :=
    { namesleft #0 > }
    { s nameptr "{f{.}.}{ ll}" format.name$ 't :=
      nameptr #1 >
        { namesleft #1 >
            { ", " * t * }
            { showetal #0 >
                { ", " * t * }
                { " and " * t * }
              if$
            }
          if$
        }
        't
      if$
      nameptr #1 + 'nameptr :=
      namesleft #1 - 'namesleft :=
    }
  while$

  showetal #0 >
    { " et~al." * }
    'skip$
  if$
}


FUNCTION {sortify}
{ purify$
  "l" change.case$
}

INTEGERS { len }


FUNCTION {chop.word}
{ 's :=
  'len :=
  s #1 len substring$ =
    { s len #1 + global.max$ substring$ }
    's
  if$
}

FUNCTION {format.title.short}
{ 't :=
  "A " #2
    "An " #3
      "The " #4 t chop.word
    chop.word
  chop.word
  #1 #3 substring$
}
FUNCTION {format.article.author}
{ author
  duplicate$ empty$ 'skip$
    { format.names.author }
  if$
  "author" bibinfo.check
  duplicate$ empty$ 'skip$
   {
   }
  if$
}
FUNCTION {format.article.title}
{ title
  "title" bibinfo.check
  duplicate$ empty$ 'skip$
   {
   }
  if$
}
FUNCTION {format.article.journal}
{ journal
  "journal" bibinfo.check
  duplicate$ empty$ 'skip$
   {
     italize
   }
  if$
}
FUNCTION {format.article.volume}
{ volume
  "volume" bibinfo.check
  duplicate$ empty$ 'skip$
   {
     bolden
   }
  if$
}
FUNCTION {format.article.pages}
{ pages
  "pages" bibinfo.check
  duplicate$ empty$ 'skip$
   {
   }
  if$
}
FUNCTION {format.article.year}
{ year
  "year" bibinfo.check
  duplicate$ empty$ 'skip$
   {
   }
  if$
}
FUNCTION {article}
{ output.bibitem
  author empty$
  'skip$
    {         format.article.author
       output.nonnull.nostate
       ", "
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate    }
  if$
  new.block
  title empty$
  'skip$
    {         format.article.title
       output.nonnull.nostate
       ". "
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate    }
  if$
  new.block
  journal empty$
  'skip$
    {         format.article.journal
       output.nonnull.nostate
       " "
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate    }
  if$
  new.block
  volume empty$
  'skip$
    {         format.article.volume
       output.nonnull.nostate
       ", "
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate    }
  if$
  new.block
  pages empty$
  'skip$
    {         format.article.pages
       output.nonnull.nostate
       " "
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate    }
  if$
  new.block
  year empty$
  'skip$
    {  "("
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate       format.article.year
       output.nonnull.nostate
       ")"
  duplicate$ empty$ 'skip$
   {
   }
  if$
output.nonnull.nostate    }
  if$
  new.block
  fin.entry
}

READ
STRINGS { longest.label }

INTEGERS { longest.label.width }

FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #0 'longest.label.width :=
}

FUNCTION {longest.label.pass}
{ label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}

EXECUTE {initialize.longest.label}

ITERATE {longest.label.pass}

FUNCTION {begin.bib}
{ preamble$ empty$
    'skip$
    { preamble$ write$ newline$ }
  if$
  "\begin{thebibliography}{"  longest.label  * "}" * write$ newline$
}
EXECUTE {begin.bib}
EXECUTE {init.state.consts}
ITERATE {call.type$}
FUNCTION {end.bib}
{ newline$
  "\end{thebibliography}" write$ newline$
}EXECUTE {end.bib}

and here is a direct download link to all three files.

9
  • 3
    I cannot reproduce that with an uncostomized unsrt.bst.
    – Johannes_B
    May 8, 2017 at 15:55
  • 3
    By the way, there must not be a customized unsrt.bst.
    – Johannes_B
    May 8, 2017 at 15:55
  • 2
    With the legally existing version of unsrt.bst: i.stack.imgur.com/Dm9XH.png May 8, 2017 at 15:58
  • 2
    Given that the OP does not state the necessity of strict adherence to bibtex and was actually initially labeled biblatex, wouldn't it be a good idea to suggest him to use biblatex's numeric style instead?
    – gusbrs
    May 8, 2017 at 16:06
  • 1
    A bibliographystyle, even if it is just a plain text file, is a work of art. You don't change the latest song of Rihanna (or somebody else) and republish it on youtube. What you do: Rename the file, get a funky beat in the backround, some synths and republish it as the NicoDean Remix. You would have the unsrtNicoDean.bst
    – Johannes_B
    May 8, 2017 at 16:06

1 Answer 1

4

You've broken the longest-label-mechanism while customization of unsrt.bst. This results in the generated bbl-file in:

\begin{thebibliography}{}

with empty label pattern argument. The argument is used for the indent of the items.

You can change the lines

INTEGERS { longest.label.width }

FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #0 'longest.label.width :=
}

FUNCTION {longest.label.pass}
{ label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}

in your xxxunsrt.bst into the original lines from unsrt.bst:

INTEGERS { number.label longest.label.width }

FUNCTION {initialize.longest.label}
{ "" 'longest.label :=
  #1 'number.label :=
  #0 'longest.label.width :=
}

FUNCTION {longest.label.pass}
{ number.label int.to.str$ 'label :=
  number.label #1 + 'number.label :=
  label width$ longest.label.width >
    { label 'longest.label :=
      label width$ 'longest.label.width :=
    }
    'skip$
  if$
}

After running bibtex again, this would result in:

\begin{thebibliography}{1}

and the alignment would be correct.

Nevertheless, I would recommend to use biblatex for customization of bibliographies.

1
  • Holy cow, you are a genious! :-o How did you figure this out within 11 minutes, including writing a perfect answer? It works for me, thank you so much!! May 8, 2017 at 16:27

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.