Skip to content

"Citation Based on Current Word / Selection…" with bibitems written on several lines #184

@odapg

Description

@odapg

When your bibliography relies on the "thebibliography" environment and you write the entries on several lines such as

\begin{thebibliograhy}{2}

\bibitem{AE1905}
\newblock Albert Einstein,
\newblock \"Uber die von der molekularkinetischen Theorie der W\"arme geforderte Bewegung von in ruhenden Fl\"ussigkeiten suspendierten Teilchen,
\newblock Annalen der Physik, vol. 17, no 8,‎ 1905, p. 549–560.

\bibitem{AE1945} 
\newblock Alfred Einstein,
\newblock Mozart, His Character, His Work,
\newblock Oxford University Press, 1945.

\end{thebibliograhy}

then when you trigger the "Citation Based on Current Word / Selection…" command, the menu only displays the citation keys ("AE1905", "AE1945"), and not the contents (author/title).

I believe that the reason is that the "recursive_scan" method in "/lib/Ruby/latex.rb" scans the file line by line. I think that a workaround would be to change

  text = File.read(@root)

into

  text = File.read(@root)
  text2 = text.gsub(/^\s*\\bibitem\{([^\}]*)\}\s*/, '\n\\bibitem{\1} ')
  text = text2.gsub(/\s*\\newblock\s*/, ' -- ')

I have tested it, and it works so far. But I am far from being an expert in Ruby and I do not understand the bundle's code in details, so this comes without guarantee...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions