Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
odapg opened this issue May 17, 2020 · 0 comments

Comments

@odapg
Copy link

odapg commented May 17, 2020

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants