Actual Problem
The issue that I'm actually trying to resolve is that TeXstudio gives me Citation 'mykey' on page 9 undefined
(more about the error in the appendix below).
I'm however not bound to TeXstudio but believe that the problem lies somewhere else/below.
Research so far
This seems to be a related question. Following the suggestions in the accepted answer, I ran the bibliography module (bibtex.exe
), which leads to this error: I couldn't open file name 'titlesec.aux'
.
Looking for a way to tackle this (I found almost nothing), I tried this MWE which is provided here:
%File mb-bibtex.tex, then \jobname = mb-bibtex
\documentclass{article}
\usepackage{filecontents} % loading package filecontents
\usepackage[numbers]{natbib} % bibliography style
\usepackage[colorlinks]{hyperref} % better urls in bibliography
\begin{filecontents*}{\jobname.bib} % writing file \jobname.bib
@Book{companion,
author = {Goossens, Michel and Mittelbach, Frank and Samarin, Alexander},
title = {The LaTeX Companion},
edition = {1},
publisher = {Addison-Wesley},
location = {Reading, Mass.},
year = {1994}
}
@Book{adams,
title = {The Restaurant at the End of the Universe},
author = {Douglas Adams},
series = {The Hitchhiker's Guide to the Galaxy},
publisher = {Pan Macmillan},
year = {1980}
}
\end{filecontents*}
\begin{document}
Test of bibliography:
The funny book of Adams~\cite{adams}, the \LaTeX{} companion~\cite{companion}.
\bibliographystyle{plainnat} % needs package natbib
\bibliography{\jobname} % uses \jobname.bib, according to \jobname.tex
\end{document}
I compiled it from console and also using TeXworks. After pressing ENTER to forward from this error output:
! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.7 \begin{filecontents*}{\jobname.bib}
% writing file \jobname.bib
?
a .pdf is generated, but it still lacks correct quoting. The previous output in TeXstudio was something like foo[mykey] bar
, now I get [? ]
:
Coming from the comments section ibidem, this question here arises.
Installed versions:
- TeXstudio 2.12.2 (Qt-Version 5.6.2)
- TeXworks 0.6.5 (MiKTeX 20.7)
- first line of
texput.log
:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.7) (preloaded format=pdflatex 2020.8.18) 19 AUG 2020 11:02
- JabRef 5.0 (should not be relevant)
pdflatex --version
:
MiKTeX-pdfTeX 4.0.1 (MiKTeX 20.7)
© 1982 D. E. Knuth, © 1996-2020 Hàn Thế Thành
TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.6, 6-Sept-2010
compiled with curl version 7.61.1; using libcurl/7.61.1 WinSSL
compiled with expat version 2.2.6; using expat_2.2.6
compiled with jpeg version 9.3
compiled with liblzma version 50020042; using 50020042
compiled with libpng version 1.6.37; using 1.6.37
compiled with libressl version LibreSSL 2.8.2; using LibreSSL 2.8.2
compiled with MiKTeX Application Framework version 4.0; using 4.0
compiled with MiKTeX Core version 4.0; using 4.0
compiled with MiKTeX Archive Extractor version 4.0; using 4.0
compiled with MiKTeX Package Manager version 4.0; using 4.0
compiled with poppler version 0.60.1
compiled with uriparser version 0.9.2
compiled with zlib version 1.2.11; using 1.2.11
Appendix:
Full error that is tooltipped while hovering over a simple \cite{mykey}
Zitat fehlt:
mykey
(engl.: ~"Quotation missing").
filecontents
env is now build in. Your problem goes away for me if I remote that comment after\begin{filecontents*}{\jobname.bib
.\begin{filecontents*}[overwrite]{\jobname.bib}
then the bib file is overwritten each time, thus you vcan make changes to it in thefilecontents
env and it will be added to the.bib
file. Normally, if the file already exists, latex will leave it alone\bibliography{\jobname}
and\end{document}
are missing. If I remove the problematic comment% writing file \jobname.bib
in thefilecontents
environment, things work for me. Can you please make these changes, run the example in a new, empty folder and edit your question accordingly?I couldn't open file name 'titlesec.aux'
sounds a bit odd. It either suggests that you are calling BibTeX ontitlesec.sty
(presumably because your editor has focus ontitlesec.sty
and not your main.tex
document) or that your.tex
file is calledtitlesec.tex
(which should be avoided: I have seen some weird side-effects when people used the name of a common package for their.tex
file. Call itcadoizdoc.tex
and try again.).