# Undefined control sequence while trying to use BibTeX

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},
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:

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

• What happens if you remove the \apj from the bib file? – Ulrike Fischer Sep 6 '18 at 18:28
• – moewe Sep 6 '18 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 Sep 7 '18 at 14:06

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.

• 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 Sep 7 '18 at 14:07
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.7813228964805603, "perplexity": 2230.4367020604764}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2019-26/segments/1560627998238.28/warc/CC-MAIN-20190616122738-20190616144738-00076.warc.gz"}