2

I have been having trouble getting BibTeX to work in Texmaker (on macOS High Sierra, just in case that's relevant). Even the most minimal document runs into issues - this is the document in question:

\documentclass[a4paper,11pt]{article}

\begin{document}
This is a citation embedded within the text - or at least it should be. \cite{VisSand1977}

\bibliographystyle{abbrv}
\bibliography{References}

\end{document}

The single reference I have used is in a file named 'References.bib', which is stored in the same directory as the main .tex file, and reads as follows:

@ARTICLE{VisSand1977,
   author = {{Visvanathan}, N. and {Sandage}, A.},
    title = "{The color-absolute magnitude relation for E and S0 galaxies. I - Calibration and tests for universality using Virgo and eight other nearby clusters}",
  journal = {\apj},
 keywords = {Astronomical Photometry, Elliptical Galaxies, Galactic Clusters, Spiral Galaxies, Virgo Galactic Cluster, Calibrating, Cassegrain Optics, Correlation, Galactic Structure, Hubble Diagram, Spectral Energy Distribution},
     year = 1977,
    month = aug,
   volume = 216,
    pages = {214-226},
      doi = {10.1086/155464},
   adsurl = {http://adsabs.harvard.edu/abs/1977ApJ...216..214V},
  adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}

This BibTeX entry was copied and pasted directly from the source of the article online, and the only change I've made is to the cite key (having changed it to VisSand1977).

I have the 'Quick Build' preferences set to 'PdfLaTex + Bib(la)tex + PdfLaTeX (x2) + View Pdf', but whenever I try to compile it I get given the error '! Undefined control sequence'. This error points me towards line 8, which is completely empty. I've tried playing around with the white space by deleting empty lines or adding new ones in, but the error points towards line 8 every single time, regardless of what's in it. If I try running PdfLaTeX on its own rather than using Quick Build, I get exactly the same error. Furthermore, if I then run BibTeX, I don't get any errors at all. Lastly, if I remove everything to do with the bibliography, PdfLaTeX has no issue (although BibTeX obviously does, as it tries to search for information that's no longer there).

If it helps, these are my 'Commands' preferences:

My current 'Commands' preferences in Texmaker.

Any help would be much appreciated! This issue has been driving me crazy all day. Thanks!

3
  • What happens if you remove the \apj from the bib file? Commented Sep 6, 2018 at 18:28
  • See also tex.stackexchange.com/a/439339/35864 and tex.stackexchange.com/q/366618/35864
    – moewe
    Commented Sep 6, 2018 at 19:52
  • Thank you both for your comments! @UlrikeFischer, if I remove \apj from the bib file, then the document compiles normally, but the name of the journal from which the article came (in this case the Astrophysical Journal) is omitted from the reference. The answer given by David Carlisle (which I have selected as the accepted answer), along with the links provided by moewe, have helped me get to the bottom of why this is. Turns out I should have done a little bit of research into the NASA ADS referencing system before simply copying and pasting their BibTeX entries!
    – T. Cornish
    Commented Sep 7, 2018 at 14:06

1 Answer 1

0

The error message as shown on the terminal and log file is

(./tesfile.bbl
! Undefined control sequence.
l.8 \newblock {\em \apj
                       }, 216:214--226, Aug. 1977.
? 

the (./... part shows the file that the error occurred in (the .bbl file generated by bibtex) the l.8 shows that it is on line 8 of that file, and the linebreak after \apj shows that is how far TeX got reading the file, so \apj is the undefined command.

Putting

\newcommand\apj{Journal of something}

in your document preamble will allow the document to run without error.

1
  • Thank you for this! Not only has it fixed the issue, but it's also helped me to understand the root of the problem. You're a life-saver.
    – T. Cornish
    Commented Sep 7, 2018 at 14:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .