1

I have a problem with apa6, apacite, etc. In the process of creating a mwe, I ran across code here on this site as a mwe, but it doesn't work. When compiled (Texpad on a Mac, using Bibtex), it produces [?] as the citation.

Here's the code:

\documentclass{article}

\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
  @book{Knu86,
    author = {Knuth, Donald E.},
    year = {1986},
    title = {The \TeX book},
  }
\end{filecontents}

\begin{document}

Doesn't work. \cite{Knu86}

\bibliography{\jobname}
\end{document}

Thanks for any help on the mwe so I can post my real problem.

2
  • after running latex, bibtex must run to produce a .bbl file, then latex twice more. (the first latex run puts the reference info into the log file for bibtex to use; bibtex creates the .bbl file, the first post-bibtex latex run reads the .bbl file and puts the biblio labels into the new .aux file, and the last latex run picks up these labels and resolves the \cites. with fewer runs of latex, in the proper sequence with bibtex, there isn't enough information to fill in the \cite info, and you get ?? instead.) Apr 28, 2013 at 3:32
  • See also Question mark instead of citation number.
    – Speravir
    Apr 28, 2013 at 19:45

1 Answer 1

3

You also need a \bibliographystyle. And compile several times, like @barbarabeeton explained. This works:

\documentclass{article}

% Update 2022: Not needed anymore.
%\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
  @book{Knu86,
    author = {Knuth, Donald E.},
    year = {1986},
    title = {The \TeX book},
  }
\end{filecontents}

\begin{document}

This works, yeah! \cite{Knu86}

\bibliographystyle{alpha}
\bibliography{\jobname}
\end{document}
2
  • 1
    \jobname indded is a valid TeX command. It expands to the main file's name (w/o .tex). It can be used in this context. see TeXbook (or texbytopic or source2e)
    – bloodworks
    Apr 28, 2013 at 8:16
  • So i'll reundo my downvote;)
    – bloodworks
    Apr 28, 2013 at 8:18

You must log in to answer this question.

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