0

My bibliography right now looks like this: enter image description here

I need to have proper alignment of text. I have been trying this on my own, as well the question here Aligning bibliography does not solve my problem.

I think the problem is because I am using customised intext citations like [Gaz14-ol] or [MQT21-ol].

However, I have no choice but to do this for online resources, unless someone can suggest there is another way to do this.

The code I used:

\documentclass[a4paper, 
    twoside, 
    12pt, 
    toc=bibliographynumbered, 
    numbers=noendperiod, 
    ngerman,
    openany, 
    fleqn]{scrbook}
\begin{document}

Example to cite \cite{Latex1} and also \cite{Latex4}.

\bibliographystyle{literature/myalphadin} \raggedright \nocite{*} \bibliography{literature/literature} \end{document}

my literature.bib looks like this:

@misc{Latex1,
    mylabel = {Uni21-ol},
    author = {Unity},
    title = {{Unity Technologies}},
    howpublished = "\url{https://unity.com/}",
    year = {Apr-2021}, 
    note = "[Online; accessed 04-Apr-2021]"
}

@misc{Latex2, mylabel = {ROS21-ol}, author = {ROS}, title = {{ROS Index}}, howpublished = "\url{https://index.ros.org/packages/}", year = {Apr-2021}, note = "[Online; accessed 04-Apr-2021]" }

@INPROCEEDINGS{Latex3, author={R. {Codd-Downey} and P. M. {Forooshani} and A. {Speers} and H. {Wang} and M. {Jenkin}}, booktitle={2014 IEEE International Conference on Information and Automation (ICIA)}, title={From ROS to unity: Leveraging robot and virtual environment middleware for immersive teleoperation}, year={2014}, volume={}, number={}, pages={932-936}, doi={10.1109/ICInfA.2014.6932785}} @misc{Latex4, mylabel = {GPP$^+$20-ol}, author = {Greene,Cameron and Platin,Jacob and Pinol,Michael and Trang,Amanda and Vij,Vidur and Gibson,Sarah}, title = {{Robotics simulation in Unity is as easy as 1,2,3}}, howpublished="\url{https://blogs.unity3d.com/2020/11/19/robotics-simulation-in-unity-is-as-easy-as-1-2-3/}", journal = {Unity Technologies Blog}, year = {19-Nov-2020}, note = "[Online; accessed 04-Apr-2021]" }

@misc{Latex5, mylabel = {Gaz14-ol}, author = {Gazebo}, title = {{Open Source Robotics Foundation}}, howpublished = "\url{http://gazebosim.org/}", year = {Mar-2014}, note = "[Online; accessed 04-Apr-2021]" }

@misc{Latex6, mylabel = {MQT21-ol}, author = {MQTT}, title = {{The Standard for IoT Messaging}}, howpublished = "\url{https://mqtt.org/}", year = {Jan-2021}, note = "[Online; accessed 04-Apr-2021]" }

@INPROCEEDINGS{Latex7, author={A. {Hussein} and F. {García} and C. {Olaverri-Monreal}}, booktitle={2018 IEEE International Conference on Vehicular Electronics and Safety (ICVES)}, title={ROS and Unity Based Framework for Intelligent Vehicles Control and Simulation}, year={2018}, volume={}, number={}, pages={1-6}, doi={10.1109/ICVES.2018.8519522}}

However, according to me, the problem is in the myalphadin.bst file.

I have only changed the following in the .bst file:

ENTRY
  { mylabel
...
}

FUNCTION {output.bibitem} { newline$ "\bibitem[" write$ mylabel empty$ 'label 'mylabel if$ write$ "]{" write$ cite$ write$ "}" write$ newline$ "" before.all 'output.state := }

Can someone please help me with this issue?

myalphadin.bst file is here

complete literature.bib file can be found here

I cannot use natbib or others.

Any suggestions or hints will be really appreciated.

moewe
  • 175,683

1 Answers1

1

I think bringing mylabel in in FUNCTION {output.bibitem} is too late. BibTeX needs to be able to figure out the longest label in order to make the indentation work properly.

I think a better place for this is calc.label. Make that function read

FUNCTION {calc.label}
{ 
  mylabel empty$
    {
      type$ "book" =
      type$ "booklet" =
      type$ "inbook" =
      or or
        'author.editor.key.label
        { type$ "proceedings" =
            'editor.key.organization.label
            { type$ "manual" =
                'author.key.organization.label
                'author.key.label
              if$
            }
          if$
        }
      if$
      duplicate$
      year field.or.null purify$ #-1 #2 substring$
      *
    }
    { mylabel duplicate$ }
  if$
  'label :=
  year field.or.null purify$ #-1 #4 substring$
  *
  sortify 'sort.label :=
}

and bring FUNCTION {output.bibitem} back to the default

FUNCTION {output.bibitem}
{ newline$
  "\bibitem[" write$
  label write$%
  "]{" write$
  cite$ write$
  "}" write$
  newline$
  ""
  before.all 'output.state :=
}

You can get the full file with a nicely formatted diff to alphadin.bst at https://gist.github.com/moewew/9697e9f14f6a5b15bf1dce6322c31d67.


It looks like your mylabel is generally just the label alphadin would assign anyway with an "-ol" appended. If I understand correctly the idea is to identify online sources like this (something I do not approve of, online sources should be first-class citizens and should not be discriminated against like this). If that is correct, then a nicer, more TeX-y solution would be to let the style add the -ol itself. For this you would need a stable way to identify "online sources". Currently the .bib file uses howpublished and note to add URL and access date, but the style supports a url field, which would make it easier to identify online sources.

moewe
  • 175,683
  • Thank you so very much!!! I am really really grateful for your help, it works for me. I really invested a lot of time in this ! And yes, you are right about declaring special labels for online resources as not a good practice, but I am not aware how to make the .bib automatically identify online sources and then put a [-ol] on its own. I am not an advanced latex user. Many thanks again! – curious_electron Apr 24 '21 at 14:16