LyXCitations not displayed correctly

Information and discussion about LyX, a WYSIWYM editor, available for Linux, Windows and Mac OS X systems.
Post Reply
tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am

Citations not displayed correctly

Post by tafi »

I am trying to write an article with the elsarticle class.
The journal I'm writing for uses numbered citations listed in order of citation.

I am using elsart-mum.bst, and an external bib database.

When compiled the citations are displayed but rather than simply "[1]" or "[1,2]" I get "(author?) [1]" and "(author?) [1,2]" in the pdf.

I have tried changing the bibliography options (both the settings of the bibliography and in the document settings) but these have had no effect and the poorly displayed citations also occur for other bst files selected.

Others have had the same problem:
http://www.latex-community.org/forum/vi ... 3F+#p48786 (there are other examples too),
but no-one to my searching has actually found a satisfactory solution and clearly stated what it is.

Is there anyone out there who has recovered from this problem, and knows how they did it?

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Citations not displayed correctly

Post by meho_r »

tafi wrote:...

Others have had the same problem:
http://www.latex-community.org/forum/vi ... 3F+#p48786 (there are other examples too),
but no-one to my searching has actually found a satisfactory solution and clearly stated what it is.
...
And still noone bothered to provide an example file (together with all necessary files for compilation and inspection)...
tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am

Re: Citations not displayed correctly

Post by tafi »

Well I'm not shy.

Attached is all I need to make it happen.

In fact only one citation is all I need to make this problem occur.
Attachments
LyXCitationTest.zip
zip archive of LyX file minimum bib source and resulting pdf output.
(18.39 KiB) Downloaded 305 times
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Re: Citations not displayed correctly

Post by meho_r »

It seems that elsarticle-num.bst is no go. Try elsarticle-names-num.bst instead.
Attachments
test-I.pdf
(50.2 KiB) Downloaded 359 times
LyXCitationTest-I.zip
LyX 2.0 or greater required.
(19.05 KiB) Downloaded 321 times
tafi
Posts: 42
Joined: Sat May 07, 2011 12:01 am

Re: Citations not displayed correctly

Post by tafi »

To me it also sounds a bit funny to submit a source file to a journal with deliberately the wrong citation style. Doesn't sound like a way to make friends with the publisher. As I said above, the citation style doesn't appear to matter anyway.

I have now found the solution and it is down to a problem in LyX.

It relates to the (silly) default in LyX for specifying citations in the source as "Author [ID#]" rather than just [ID#], where "ID#" refers to the bibtex key.

In order to compile correctly the citation has to be present as just "[ID#]", but there appears to be no way to set this as the default citation insert. So instead all the citation inserts have to be reset.

It is not a big issue when you're just writing a paper, but I'm trying to get a thesis done as well; and for such a large document (much of which already has citations) this is a problem.

Thanks for your help
meho_r
Posts: 823
Joined: Tue Aug 07, 2007 5:28 pm

Citations not displayed correctly

Post by meho_r »

For things like this one, where it is expected for changes to occur, it is wise to define custom commands and use them instead of those provided by LyX (or LaTeX). So, e.g., you can define \mycite as

Code: Select all

\newcommand{\mycite}[1]{\citep{#1}}
or something like that, and use it in ERT boxes to insert citations. So, if later something have to be changed, just change that command instead of all occurrences throughout the document.

However, in this case of yours, I wouldn't blame LyX: it does what it is expected to do, and do that pretty well, but it can't think. The user is the one who should pay attention if correct formatting is chosen :P

And the last but not least, if you want advanced features and greater flexibility, then you'll probably have to come down to LaTeX as well as to more powerful editors and sacrifice convenience which LyX provides.
zeitgeist
Posts: 1
Joined: Wed Apr 03, 2013 2:42 am

Re: Citations not displayed correctly

Post by zeitgeist »

I had this exact problem and was able to fix it by going to Document -> Setting... -> Bibliography and changing the NatBib citation style to Numerical. My other documents seemed to default to numerical, but the elsevier template seemed to default to the Author-year style.
Post Reply