I couldn't open database file .bib : \bibdata{ : } - latex

So we changed our LaTeX file from a regular style to an Elsevier style, but the bibliography does not get added to the file. Judging from the error statement I used as the title, I believe it has to do with this error message. I have made multiple attempts by e.g. changing the name of the bibliography, forcing it in etc. and yet it does not show.
Can anyone help me out?
This what I have used:
% Loading bibliography style file
%\bibliographystyle{model1-num-names}
\bibliographystyle{cas-model2-names}
% Loading bibliography database
\bibliography{cas-refs}
where cas-refs.bib is the bibliography file.

Related

Sphinx cross-reference in LaTeX

I have the following reference identified in file A:
.. _my-label:
and I reference it in file B :
this is a reference to file A :ref:`my-label`
This generates a cross-reference as expected when outputting HTML. However, when outputting LaTeX, it does not and I have the classical warning:
LaTeX Warning: Hyper reference `my-label:my-label' on page XX undefined on input line YY.
Is there a LaTeX trick like double compilation or something similar that I am not doing correctly?
I encountered the same issue. HTML compiled without errors for me, but LaTeX compilation did throw the hyperref errors you described. It seems to me that, for some obscure reason, Sphinx does not create the labels that hyperref tries to reference.
I came up with the following solution: since I do not know how to include the missing labels, I will just make it so that LaTeX does not look for them anymore. In detail, I am doing this by overwriting the \hyperref command.
I included the following code in my conf.py file:
latex_elements = {
'preamble': r'''
\renewcommand{\hyperref}[2][]{#2}
'''
}
This includes the \renewcommand{... in the preamble of the LaTeX document created by Sphinx. It will overwrite the \hyperref command so that it won't try to insert a link, but just print the link text.
Obviously, with this solution, the reference that caused the errors will not appear as hyperlinks in your PDF document, but at least it is compiling without errors.
Note
What I described worked perfectly fine for my use case, however, it is described in the Hyperref manual that the \hyperref command can be invoked in two different ways (\hyperref{URL}{category}{name}{text} and \hyperref[label]{text}). I am only overwriting the second one, as that seems to be the one that Sphinx is using for cross references. However, not accounting for the first one when overwriting the command might lead to issues in some cases.

use scholar.google.com reference in latex file

When I use scholar.google.com to get the full reference code (BibTeX) such as
#article{li2018design,
title={Design and implementation of building structure monitoring system based on radio frequency identification (RFID)},
author={Li, Hongwei and Ren, Yilei},
journal={International Journal of RF Technologies},
volume={9},
number={1-2},
pages={37--49},
year={2018},
publisher={IOS Press}
}
Then go to the journal template file, I want to copy the reference from scholar.google.com and paste it into the LaTex journal template file without doing any modification.
The template file looks like this:
Unfortunately, the paste in the template file does NOT work.
Here is the error message:
Can you assist of how to do it and make the file work correctly?
The format given by Google scholar has to be used when you compile, in order, with
Latex (or PDFLatex)
Bibtex
Latex (or PDFLatex)
Latex (or PDFLatex)
where you store the entries of your bibliography in a separate file named <mydoc>.bib.
You are simply using \thebibliography environment, which allows you to write \bibitems, which is a simpler approach (even if I suggest to use it when you have a small number of bibliography entries). If you have to use this latter approach, you have to rewrite the reference retrieved in Google scholar in the format needed by your document.
Have a look here: it explains very well the differences.

How to set title of TOC in Latex hyperref package

The latex hyperref package makes a really nice, linked table of contents, named according to section name. However, the top level category is by default, the file name. It seems I should be able to change this to the actual title, but I'm not finding any information on how.
Are you sure this is not a 'feature' of your PDF reader? It might try to use the PDFs title (unset by default), which you can set like this:
\hypersetup{
pdftitle = {The title},
pdfauthor = {You}
}
You might also want to check out the TeX StackExchange.

Why is my references section of my LaTeX document empty, and how can I change its name?

In my document I have to specify the references I'm using. I used this code in the preamble:
\bibliographystyle{abbrv}
\bibliography{main}
Where main is the .bib file from the same folder, and contains, for example:
#string{jgr = "J.~Geophys.~Res."}
#MISC{primes,
author = "Charles Louis Xavier Joseph de la Vall{\'e}e Poussin",
note = "A strong form of the prime number theorem, 19th century",
year = 1879
}
#INBOOK{chicago,
title = "The Chicago Manual of Style",
publisher = "University of Chicago Press",
edition = "Thirteenth",
year = 1982,
pages = "400--401",
key = "Chicago"
}
But at the References section nothing is displayed, when generating the .pdf. I have rebuild the .bib and the .tex file, without any changes.
And how can I change that default text, from References to Bibliografie or something else?
I think that you need to put \nocite{*} somewhere within your document -- putting it inside the preamble should cause LaTeX to throw a "cannot be used in preamble" error. If they're still not appearing within your document, is LaTeX giving you any errors and, if so, can you tell us what they are?
To change the default text from "References" to whatever you would like, use the following command:
\renewcommand{\bibsection}{\section*{insert_title_here}}
Note that the asterisk after \section means that it won't be associated with a number. If you want it to be associated with a number, just remove the asterisk.
You have to actually \cite references for them to be included in the bibliography. If instead you want everything in the bib file in the bibliography put \nocite{*} somewhere in the preamble. Read here what this actually does.
You have to either \cite or \nocite a reference for it to appear in your References section. I'm not sure how to change the name of the bibliography. I would start by looking at the LaTeX WikiBook. It looks like there is a tool make makebst that produces a custom bibliography style - take a look at the custom-bib package and this document for more details.

Odd Bibtex behaviour in a Latex document

I added a line "\cite{test}" as a test to my working Latex document. When I compiled the bibtex "!bibtex name_of_my_file, I got the expected error:
Warning--I didn't find a database entry for "test"
Then, I removed the line and compiled the bibtex again, hoping to have a working Latex file again. However, the same error occurs, even with a fresh shell. I cannot understand the behaviour. What is the logic? How can I get my Latex document working again?
[Updated Info]
The problem dissapeared as unexpectedly as it emerged. I have no idea why but it works now. Do you know the reason for the odd behaviour?
I think you are tripping over the multi-pass nature of LaTex plus Bibtex. If you look at Step 3 in this discussion, you'll see the following:
The first run (through latex)
generates an auxiliary file,
paper.aux, containing information
about citations (and other types of
references), the bibliography style
used, and the name of the bibtex
database. The second run (through
bibtex) uses the information in the
auxiliary file, along with the data
contained in the bibtex database, to
create a file paper.bbl. This file
contains a thebibliography environment
with \bibitem entries formatted
according to the bibliography style
specified.
So, what I think is happening is that your name_of_my_file.aux file still contains your placeholder \cite{test}. If you remove the auxiliary file, you should be able to start over with:
latex name_of_my_file
bibtex name_of_my_file
latex name_of_my_file
latex name_of_my_file
[Update based on additional info]: The problem was that you had a .aux file with your \cite{} still embedded. The second time that you ran latex, you overrode the old file with the new. That's why the complete set of steps includes an initial latex call, a bibtex call and two follow-up latex calls. Think of it as a multi-pass compiler and it might be more intuitive.
You could have a look at latexmk, which will take care of the fix point compilation for you.
Anyway, you should be able to build the document (pdflatex blah.tex), even if you're missing a bibliography item. The corresponding references will just appear as question marks in the PDF.
Rerun latex to regenerate the aux file.
Have a look at this discussion for pointers to a bit more information. Basically, you may have taken your citation out of the .tex file, but it still exists in one of the derived files (aux, bbl, whatever...)
Check if your bib file has the extension .bib and not .tex.
If it is .tex, just change it to .bib and that should do it.
Once I changed it accidentally to tex, by adding some references, and saving it with the "save as" option, without specifying the bib extension. That's how it can happen all of a sudden.
delete all your .aux and temporal files, re run with latex and then bibtex and then latex twice.

Resources