On Thu, Aug 12, 2021 at 5:48 PM Hongyi Zhao <[email protected]> wrote: > > On Thu, Aug 12, 2021 at 3:21 PM Vladimir Lomov <[email protected]> wrote: > > > > Hello, > > ** Hongyi Zhao <[email protected]> [2021-08-12 12:40:24 +0800]: > > > > [...] > > > > > What do you mean by saying ``"big" output''? The original description > > > given by Arash is as follows: > > > > > (bib "z:/path/to/test-bib-file.bib") > > > > The output length is bigger than 80 symbols (cf. what Arash shown). > > > > [...] > > > > > But even so, I still can't see the similar result given by Arash as > > > follows: > > > > > (bib "z:/path/to/test-bib-file.bib") > > > > This is output in the buffer > > > > ------------------------------------------------------------------------------ > > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > > (master-dir . "/home/vladimir/tmp/test/emacs/") (label-numbers) (bof > > "/home/vladimir/tmp/test/emacs/doc-samp3.ltx") (eof > > "/home/vladimir/tmp/test/emacs/doc-samp3.ltx")) > > ------------------------------------------------------------------------------ > > > > for my third document after I forced RefTeX to reparse document (I think > > RefTeX parses document only when there is a change in a buffer or after some > > time, didn't check that though). This is output for my second document > > > > ------------------------------------------------------------------------------ > > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > > (master-dir . "/home/vladimir/tmp/test/emacs/") (label-numbers) (bof > > "/home/vladimir/tmp/test/emacs/doc-samp2.ltx") (eof > > "/home/vladimir/tmp/test/emacs/doc-samp2.ltx")) > > ------------------------------------------------------------------------------ > > > > and the first one: > > > > ------------------------------------------------------------------------------ > > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > > (master-dir . "/home/vladimir/tmp/test/emacs/") (label-numbers) (bof > > "/home/vladimir/tmp/test/emacs/doc-samp.ltx") (bib > > "/home/vladimir/tmp/test/emacs/sample.bib") (eof > > "/home/vladimir/tmp/test/emacs/doc-samp.ltx")) > > ------------------------------------------------------------------------------ > > > > As you see, only the first document has 'bib' part. > > > > > See the following result of mine generated by `C-x C-e' on the lisp > > > code line of the TeX document: > > > > > ------------------------------------ > > > \documentclass{article} > > > > > \usepackage{natbib} > > > \bibliography{\string~/Documents/bibliograph/better-bibtex/references-bibtex.bib} > > > > > \begin{document} > > > > > \cite{weiFirstprinciplesCharacterizationBibased2009} > > > > > \begin{verbatim} > > > (insert "\n" > > > (format "%S" (symbol-value reftex-docstruct-symbol))) > > > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > > > (master-dir . > > > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/") > > > (label-numbers) (bof > > > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex") > > > (eof > > > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex")) > > > \end{verbatim} > > > \end{document} > > > > > %%% Local Variables: > > > %%% mode: latex > > > %%% TeX-master: t > > > %%% End: > > > ------------------------------------ > > > > To be sure I made a fourth document in which I moved '\bibliography' into > > preamble and use '\string~' and got > > > > ------------------------------------------------------------------------------ > > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > > (master-dir . "/home/vladimir/tmp/test/emacs/") (label-numbers) (bof > > "/home/vladimir/tmp/test/emacs/doc-samp4.ltx") (eof > > "/home/vladimir/tmp/test/emacs/doc-samp4.ltx")) > > ------------------------------------------------------------------------------ > > > > Funny, I didn't even try to replicate your document, I merely wrote mine as > > example to check what is going on. I read RefTeX manual again and didn't > > find > > any mention where '\bibliography' macro must in document to be taken into > > account. Well, I consulted with source2e (LaTeX source) and found this > > (quoting from source2e.pdf, run texdoc source2e to find section > > "ltbibl.dtx"): > > > > \bibliography{⟨file1,file2, . . . ,filen⟩} : specifies the bibdata files. > > Writes a \bibdata entry on the .aux file and tries to read in > > mainfile.bbl. > > > > in other words, LaTeX will insert bibliography list in place of > > '\bibliography' command. Why someone would issue the command in document > > preamble, it is meaningless. Why you use it there? > > > > I made my examples didn't consulting LaTeX manual but follow some logic: put > > '\bibliography' macro there where I need to insert bibliography list. May > > be I > > read some manual, may be the LaTeX source and remember that but I even > > didn't > > thought to issue '\bibliography' into a preamble. > > > > To conclude: you have problem only because you insert '\bibliography' macro > > in > > WRONG place. Though I'm not sure if RefTeX is "smart" enough but it > > definitely > > ignores that macro and it is right. > > No. Your above conclusion is partially right. See my following testing > results: > > --- > \documentclass{article} > \usepackage{natbib} > \bibliography{/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib} > \begin{document} > > \begin{verbatim} > (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol))) > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > (master-dir . > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/") > (label-numbers) (bof > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex") > (bib "/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib") > (eof > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex")) > \end{verbatim} > > \bibliographystyle{plainnat} > \end{document} > > %%% Local Variables: > %%% mode: latex > %%% TeX-master: t > %%% End: > --- > > But use the `\string~' variable to point to the bib file won't work: > > --- > \documentclass{article} > \usepackage{natbib} > \bibliography{\string~/Documents/bibliograph/better-bibtex/references-bibtex.bib} > \begin{document} > > \begin{verbatim} > (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol))) > ((xr nil "\\\\\\\\\\\\") (index-tags) (is-multi nil) (bibview-cache) > (master-dir . > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/") > (label-numbers) (bof > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex") > (eof > "/home/werner/Desktop/work/emacs-auctex/reftex-docstruct-symbol/reftex-docstruct-symbol.tex")) > \end{verbatim} > > \bibliographystyle{plainnat} > \end{document} > > %%% Local Variables: > %%% mode: latex > %%% TeX-master: t > %%% End: > --- > > The key points and some additional comments: > > 1. When you revise any part relevant to the `\bibliography' macro, the > file must be re-parsed before do the testing discussed here. > 2. The following options set in the init file don't ensure that the > document is parsed automatically when we open it: > (setq reftex-enable-partial-scans t > reftex-save-parse-info t) > 3. The `\string~' variable expansion doesn't work with RefTeX, but it > works smoothly with helm-bibtex. > 4. Put the `\bibliography' macro in preamble will trigger the > xelatex/pdflatex/bibtex error as follows: > > ---- > ERROR: LaTeX Error: Missing \begin{document}. > > --- TeX said --- > > See the LaTeX manual or LaTeX Companion for explanation. > Type H <return> for immediate help. > ... > > l.1 \begin{thebibliography}{1} > > --- HELP --- > LaTeX produced printed output before encountering a \begin{document} > command. Either you forgot the \begin{document} command or there is > something wrong in the preamble. The problem may be a stray character > or an error in a declaration---for example, omitting the braces around > an argument or forgetting the \ in a command name. > ---- > > To conclude: > > 1. If you use helm-bibtex, the following example works smoothly: > > --- > \documentclass{article} > \usepackage{natbib} > > \begin{document} > > \begin{verbatim} > (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol))) > \end{verbatim} > > \cite{weiFirstprinciplesCharacterizationBibased2009} > > \bibliographystyle{plainnat} > \bibliography{\string~/Documents/bibliograph/better-bibtex/references-bibtex.bib} > > \end{document} > > %%% Local Variables: > %%% mode: latex > %%% TeX-master: t > %%% End: > --- > > But the following error will be triggered when using RefTeX to insert > the references: > > reftex-offer-bib-menu: No valid bibliography in this document, and no > default available > > 2. The following example works smoothly with both RefTeX and helm-bibtex: > > --- > \documentclass{article} > \usepackage{natbib} > > \begin{document} > > \begin{verbatim} > (insert "\n" (format "%S" (symbol-value reftex-docstruct-symbol))) > \end{verbatim} > > \bibliographystyle{plainnat} > \bibliography{/home/werner/Documents/bibliograph/better-bibtex/references-bibtex.bib} > > \end{document} > > %%% Local Variables: > %%% mode: latex > %%% TeX-master: t > %%% End: > ---
See <https://groups.google.com/g/comp.text.tex/c/x1FaMPxSRec/m/bezGL31YAgAJ> for some relevant discussion. > > Best regards, > Hongyi
